Skip to content

Commit

Permalink
bugfix and extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martyn-w committed Jan 27, 2025
1 parent 01dd3d0 commit f67cb49
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
5 changes: 4 additions & 1 deletion GetIntoTeachingApi/Jobs/ApplyCandidateSyncJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public void Run(ApplyCandidate applyCandidate)

public void SyncCandidate(ApplyCandidate applyCandidate)
{
ContactChannelCandidateWrapper wrappedCandidate = new(applyCandidate.ToCrmModel());
ContactChannelCandidateWrapper wrappedCandidate = new(applyCandidate.ToCrmModel())
{
CreationChannelSourceId = (int?) ContactChannelCreation.CreationChannelSource.Apply
};

var match = _crm.MatchCandidate(wrappedCandidate.ScopedCandidate.Email, applyCandidate.Id);

Expand Down
20 changes: 12 additions & 8 deletions GetIntoTeachingApi/Jobs/ContactChannelCandidateWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using GetIntoTeachingApi.Models.Crm;

namespace GetIntoTeachingApi.Jobs;

public class ContactChannelCandidateWrapper : ICreateContactChannel
namespace GetIntoTeachingApi.Jobs
{

public class ContactChannelCandidateWrapper : ICreateContactChannel
{
/// <summary>
/// Provides the default read-only contact creation channel integer value.
/// </summary>
Expand All @@ -26,12 +25,17 @@ public class ContactChannelCandidateWrapper : ICreateContactChannel
/// </summary>
public int? CreationChannelActivityId { get; set; }


/// <summary>
/// Provides the ability to retrieve the underlying CRM candidate record.
/// </summary>
public Candidate ScopedCandidate { get; }

// Todo: add some documentation

/// <summary>
/// Initialises the instance with an underlying CRM candidate record.
/// </summary>
public ContactChannelCandidateWrapper(Candidate candidate)
{
ScopedCandidate = candidate;
ScopedCandidate = candidate;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using FluentAssertions;
using GetIntoTeachingApi.Jobs;
using GetIntoTeachingApi.Models.Crm;
using Xunit;

namespace GetIntoTeachingApiTests.Jobs
{
public class ContactChannelCandidateWrapperTests
{
private readonly Candidate _candidate;

public ContactChannelCandidateWrapperTests()
{
_candidate = new Candidate();
}

[Fact]
public void Constructor_WithCandidate_MapsToScopedCandidate()
{
var contactChannelCandidateWrapper = new ContactChannelCandidateWrapper(_candidate);
contactChannelCandidateWrapper.ScopedCandidate.Should().Be(_candidate);
}
}
}

0 comments on commit f67cb49

Please sign in to comment.