Skip to content

Commit

Permalink
Merge branch 'main' into feature/dotnet-6-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdexnimble committed Jun 13, 2023
2 parents eda7b06 + 7075cad commit 0fc1c61
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 862 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using TramsDataApi.Factories;
using TramsDataApi.RequestModels;
using TramsDataApi.RequestModels.AcademyTransferProject;
using TramsDataApi.Services;
using Xunit;

namespace TramsDataApi.Test.Factories
Expand All @@ -18,6 +19,8 @@ public class AcademyTransferProjectFactoryTests
public void ReturnsAnAcademyTransferProject_WhenGivenAnInitialAcademyTransferProjectRequest()
{
var randomGenerator = new RandomGenerator();
DateTime expectedCreateDateTime = DateTime.Now;
DateTimeSource.UtcNow = () => expectedCreateDateTime;
var createRequest = Builder<AcademyTransferProjectRequest>.CreateNew()
.With(c => c.OutgoingTrustUkprn = randomGenerator.NextString(8, 8))
.With(c => c.Status = null)
Expand Down Expand Up @@ -69,6 +72,7 @@ public void ReturnsAnAcademyTransferProject_WhenGivenAnInitialAcademyTransferPro
FeatureSectionIsCompleted = null,
BenefitsSectionIsCompleted = null,
LegalRequirementsSectionIsCompleted = null,
CreatedOn = DateTimeSource.UtcNow(),
RationaleSectionIsCompleted = null,
TransferringAcademies = createRequest.TransferringAcademies
.Select(t => new TransferringAcademies
Expand All @@ -92,6 +96,8 @@ public void ReturnsAnAcademyTransferProject_WhenGivenAnInitialAcademyTransferPro
[Fact]
public void ReturnsAnAcademyTransferProject_WhenGivenACompleteAcademyTransferProjectRequest()
{
DateTime expectedCreateDateTime = DateTime.Now;
DateTimeSource.UtcNow = () => expectedCreateDateTime;
var randomGenerator = new RandomGenerator();

var benefitsRequest = Builder<AcademyTransferProjectBenefitsRequest>.CreateNew()
Expand Down Expand Up @@ -128,6 +134,7 @@ public void ReturnsAnAcademyTransferProject_WhenGivenACompleteAcademyTransferPro
.With(c => c.TransferringAcademies =
(List<TransferringAcademiesRequest>) Builder<TransferringAcademiesRequest>
.CreateListOfSize(5).Build())
.With(d => d.CreatedOn = expectedCreateDateTime)
.Build();

var expected = new AcademyTransferProjects
Expand Down Expand Up @@ -176,6 +183,7 @@ public void ReturnsAnAcademyTransferProject_WhenGivenACompleteAcademyTransferPro
BenefitsSectionIsCompleted = createRequest.Benefits?.IsCompleted,
LegalRequirementsSectionIsCompleted = createRequest.LegalRequirements?.IsCompleted,
RationaleSectionIsCompleted = createRequest.Rationale?.IsCompleted,
CreatedOn = createRequest.CreatedOn,
AcademyTransferProjectIntendedTransferBenefits = createRequest.Benefits.IntendedTransferBenefits
.SelectedBenefits
.Select(b => new AcademyTransferProjectIntendedTransferBenefits {SelectedBenefit = b}).ToList(),
Expand Down Expand Up @@ -613,7 +621,6 @@ public void ReturnsOriginalAcademyTransferProjectWithDatesSetToNull_WhenUpdating
AssignedUserEmailAddress = academyTransferProject.AssignedUserEmailAddress,
AssignedUserFullName = academyTransferProject.AssignedUserFullName,
AssignedUserId = academyTransferProject.AssignedUserId,

CreatedOn = academyTransferProject.CreatedOn
};

Expand Down
2 changes: 1 addition & 1 deletion TramsDataApi/DatabaseModels/AcademyTransferProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ public virtual ICollection<AcademyTransferProjectIntendedTransferBenefits>

public virtual ICollection<TransferringAcademies> TransferringAcademies { get; set; }

public DateTime CreatedOn { get; set; }
public DateTime? CreatedOn { get; set; }
}
}
4 changes: 3 additions & 1 deletion TramsDataApi/Factories/AcademyTransferProjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using TramsDataApi.DatabaseModels;
using TramsDataApi.RequestModels;
using TramsDataApi.RequestModels.AcademyTransferProject;
using TramsDataApi.Services;

namespace TramsDataApi.Factories
{
Expand Down Expand Up @@ -59,7 +60,8 @@ public static AcademyTransferProjects Create(AcademyTransferProjectRequest reque
HasTargetDateForTransfer = request.Dates?.HasTargetDateForTransfer,
AssignedUserEmailAddress = request.AssignedUser?.EmailAddress,
AssignedUserFullName = request.AssignedUser?.FullName,
AssignedUserId = request.AssignedUser?.Id
AssignedUserId = request.AssignedUser?.Id,
CreatedOn = DateTimeSource.UtcNow()
};
}

Expand Down
Loading

0 comments on commit 0fc1c61

Please sign in to comment.