Skip to content

Commit

Permalink
Update CandidateUpserterTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
martyn-w committed Sep 5, 2024
1 parent 9b68690 commit 5913452
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions GetIntoTeachingApiTests/Services/CandidateUpserterTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using GetIntoTeachingApi.Jobs;
using GetIntoTeachingApi.Services;
Expand All @@ -8,8 +8,8 @@
using Moq;
using Xunit;
using GetIntoTeachingApi.Utils;
using GetIntoTeachingApi.Models.Crm;

using GetIntoTeachingApi.Models.Crm;

namespace GetIntoTeachingApiTests.Services
{
public class CandidateUpserterTests
Expand Down Expand Up @@ -99,11 +99,8 @@ public void Upsert_WithQualifications_SavesQualifications()
_upserter.Upsert(_candidate);

qualification.CandidateId = candidateId;

_mockJobClient.Verify(x => x.Create(
It.Is<Job>(job => job.Type == typeof(UpsertModelWithCandidateIdJob<CandidateQualification>) && job.Method.Name == "Run" &&
IsMatch(qualification, (string)job.Args[0])),
It.IsAny<EnqueuedState>()));

_mockCrm.Verify(mock => mock.Save(It.Is<CandidateQualification>(q => q.CandidateId == candidateId)), Times.Once);
}

[Fact]
Expand Down Expand Up @@ -140,8 +137,8 @@ public void Upsert_WithApplicationForms_SavesApplicationForms()
It.Is<Job>(job => job.Type == typeof(UpsertApplicationFormJob) && job.Method.Name == "Run" &&
IsMatch(applicationForm, (string)job.Args[0])),
It.IsAny<EnqueuedState>()));
}

}

[Fact]
public void Upsert_WithSchoolExperiences_SavesSchoolExperiences()
{
Expand Down Expand Up @@ -274,11 +271,11 @@ private static bool IsMatch(object objectA, object objectB)
return true;
}

private static bool IsMatch<T>(T modelA, string modelBJson)
private static bool IsMatch<T>(T modelA, string modelBJson)
{
var candidateB = modelBJson.DeserializeChangeTracked<T>();
modelA.Should().BeEquivalentTo(candidateB);
return true;
var candidateB = modelBJson.DeserializeChangeTracked<T>();
modelA.Should().BeEquivalentTo(candidateB);
return true;
}
}
}

0 comments on commit 5913452

Please sign in to comment.