Skip to content

Commit

Permalink
Merge pull request #29 from LBHackney-IT/feature/OptionalTempAccomInfo
Browse files Browse the repository at this point in the history
Add "Booking Status" and "Assigned Officer" under a sub-model within Create, Update & Layer Tenure models.
  • Loading branch information
Duslerke authored Apr 15, 2024
2 parents e40390d + 00f245d commit ad01b70
Show file tree
Hide file tree
Showing 19 changed files with 437 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Token to access locked Hackney Shared Github packages
LBHPACKAGESTOKEN=ghp_YourPATWithDownloadGithubPackagesPrivileges
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public void CanMapARequestToADatabaseObject()
databaseEntity.TenuredAsset.Should().BeEquivalentTo(request.TenuredAsset);
databaseEntity.TenureType.Should().Be(request.TenureType);
databaseEntity.Terminated.Should().Be(request.Terminated);
databaseEntity.TempAccommodationInfo.Should().BeEquivalentTo(request.TempAccommodationInfo);
databaseEntity.FurtherAccountInformation.Should().BeEquivalentTo(request.FurtherAccountInformation);
}

[Fact]
Expand Down
151 changes: 148 additions & 3 deletions Hackney.Shared.Tenure.Tests/Factories/EntityFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,46 @@ public class EntityFactoryTest
{
private readonly Fixture _fixture = new Fixture();

#region Tenure Information
[Fact]
public void NullTenureDomainMapsToNullTenureDatabaseEntity()
{
// arrange
TenureInformation domainTenure = null;

// act
var entityTenure = domainTenure.ToDatabase();

// assert
entityTenure.Should().BeNull();
}

[Fact]
public void NullTenureDatabaseEntityMapsToNullTenureDomain()
{
// arrange
TenureInformationDb entityTenure = null;

// act
var domainTenure = entityTenure.ToDomain();

// assert
domainTenure.Should().BeNull();
}

[Fact]
public void CanMapADatabaseEntityToADomainObject()
{
var databaseEntity = _fixture.Create<TenureInformationDb>();
databaseEntity.EndOfTenureDate = DateTime.UtcNow;

var entity = databaseEntity.ToDomain();
var domainTenure = databaseEntity.ToDomain();

databaseEntity.Should().BeEquivalentTo(entity, config => config.Excluding(x => x.IsActive));
}
// If it is null, cross-static-method calls are not properly covered.
domainTenure.TempAccommodationInfo.Should().NotBeNull();

databaseEntity.Should().BeEquivalentTo(domainTenure, config => config.Excluding(x => x.IsActive));
}

[Fact]
public void CanMapADomainEntityToADatabaseObject()
Expand All @@ -32,7 +61,123 @@ public void CanMapADomainEntityToADatabaseObject()

var databaseEntity = entity.ToDatabase();

// If it is null, cross-static-method calls are not properly covered.
databaseEntity.TempAccommodationInfo.Should().NotBeNull();

entity.Should().BeEquivalentTo(databaseEntity);
}
#endregion
#region Temporary Accommodation Information
#region Domain to Entity
[Fact]
public void NullTAOfficerDomainMapsToNullTAOfficerDatabase()
{
// arrange
TemporaryAccommodationOfficer domainTAOfficer = null;

// act
var taOfficerEntity = domainTAOfficer.ToDatabase();

// assert
taOfficerEntity.Should().BeNull();
}
[Fact]
public void NullTAInfoDomainMapsToNullTAInfoDatabase()
{
// arrange
TemporaryAccommodationInfo domainTAInfo = null;

// act
var taInfoEntity = domainTAInfo.ToDatabase();

// assert
taInfoEntity.Should().BeNull();
}
[Fact]
public void TAInfoDomainMapsFieldsCorrectlyToTAInfoDatabase()
{
// arrange
var domainTAInfo = _fixture.Create<TemporaryAccommodationInfo>();

// act
var taInfoEntity = domainTAInfo.ToDatabase();

// assert
taInfoEntity.BookingStatus.Should().Be(domainTAInfo.BookingStatus);
// If it is null, cross-static-method calls were not properly covered.
taInfoEntity.AssignedOfficer.Should().NotBeNull();
taInfoEntity.AssignedOfficer.Should().BeEquivalentTo(domainTAInfo.AssignedOfficer);
}
[Fact]
public void TAOfficerDomainMapsFieldsCorrectlyToTAOfficerDatabase()
{
// arrange
var domainTAOfficer = _fixture.Create<TemporaryAccommodationOfficer>();

// act
var taOfficerEntity = domainTAOfficer.ToDatabase();

// assert
taOfficerEntity.FirstName.Should().Be(domainTAOfficer.FirstName);
taOfficerEntity.LastName.Should().Be(domainTAOfficer.LastName);
taOfficerEntity.Email.Should().Be(domainTAOfficer.Email);
}
#endregion
#region Entity to Domain
[Fact]
public void NullTAOfficerEntityMapsToNullTAOfficerDomain()
{
// arrange
TemporaryAccommodationOfficerDb entityTAOfficer = null;

// act
var taOfficerDomain = entityTAOfficer.ToDomain();

// assert
taOfficerDomain.Should().BeNull();
}
[Fact]
public void NullTAInfoEntityMapsToNullTAInfoDomain()
{
// arrange
TemporaryAccommodationInfoDb entityTAInfo = null;

// act
var taInfoDomain = entityTAInfo.ToDomain();

// assert
taInfoDomain.Should().BeNull();
}
[Fact]
public void TAInfoEntityMapsFieldsCorrectlyToTAInfoDomain()
{
// arrange
var entityTAInfo = _fixture.Create<TemporaryAccommodationInfoDb>();

// act
var taInfoDomain = entityTAInfo.ToDomain();

// assert
taInfoDomain.BookingStatus.Should().Be(entityTAInfo.BookingStatus);
// If it is null, cross-static-method calls were not properly covered.
taInfoDomain.AssignedOfficer.Should().NotBeNull();
taInfoDomain.AssignedOfficer.Should().BeEquivalentTo(entityTAInfo.AssignedOfficer);
}
[Fact]
public void TAOfficerEntityMapsFieldsCorrectlyToTAOfficerDomain()
{
// arrange
var entityTAOfficer = _fixture.Create<TemporaryAccommodationOfficerDb>();

// act
var taOfficerDomain = entityTAOfficer.ToDomain();

// assert
taOfficerDomain.FirstName.Should().Be(entityTAOfficer.FirstName);
taOfficerDomain.LastName.Should().Be(entityTAOfficer.LastName);
taOfficerDomain.Email.Should().Be(entityTAOfficer.Email);
}
#endregion
#endregion
}
}
60 changes: 60 additions & 0 deletions Hackney.Shared.Tenure.Tests/Factories/ResponseFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ResponseFactoryTest
{
private readonly Fixture _fixture = new Fixture();

#region Tenure Information
[Fact]
public void CanMapANullTenureInfoToAResponseObject()
{
Expand All @@ -26,8 +27,11 @@ public void CanMapATenureInfoToAResponseObject()
{
var domain = _fixture.Create<TenureInformation>();
var response = domain.ToResponse();

domain.Should().BeEquivalentTo(response);

// If it is null, cross-static-method calls were not properly covered.
response.TempAccommodationInfo.Should().NotBeNull();
}

[Fact]
Expand All @@ -48,5 +52,61 @@ public void CanMapNullDomainTenureInfoListToAnEmptyResponsesList()

responseNotes.Should().BeEmpty();
}
#endregion
#region Temporary Accommodation details
[Fact]
public void NullTAOfficerDomainMapsToNullTAOfficerResponse()
{
// arrange
TemporaryAccommodationOfficer domainTAOfficer = null;

// act
var taOfficerPresentation = domainTAOfficer.ToResponse();

// assert
taOfficerPresentation.Should().BeNull();
}
[Fact]
public void NullTAInfoDomainMapsToNullTAInfoResponse()
{
// arrange
TemporaryAccommodationInfo domainTAInfo = null;

// act
var taInfoPresentation = domainTAInfo.ToResponse();

// assert
taInfoPresentation.Should().BeNull();
}
[Fact]
public void TAInfoDomainMapsFieldsCorrectlyToTAInfoResponse()
{
// arrange
var domainTAInfo = _fixture.Create<TemporaryAccommodationInfo>();

// act
var taInfoPresentation = domainTAInfo.ToResponse();

// assert
taInfoPresentation.BookingStatus.Should().Be(domainTAInfo.BookingStatus);
// If it is null, cross-static-method calls were not properly covered.
taInfoPresentation.AssignedOfficer.Should().NotBeNull();
taInfoPresentation.AssignedOfficer.Should().BeEquivalentTo(domainTAInfo.AssignedOfficer);
}
[Fact]
public void TAOfficerDomainMapsFieldsCorrectlyToTAOfficerResponse()
{
// arrange
var domainTAOfficer = _fixture.Create<TemporaryAccommodationOfficer>();

// act
var taOfficerPresentation = domainTAOfficer.ToResponse();

// assert
taOfficerPresentation.FirstName.Should().Be(domainTAOfficer.FirstName);
taOfficerPresentation.LastName.Should().Be(domainTAOfficer.LastName);
taOfficerPresentation.Email.Should().Be(domainTAOfficer.Email);
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class CreateTenureRequestObject
public int NumberOfAdultsInProperty { get; set; }
public int NumberOfChildrenInProperty { get; set; }
public bool? HasOffsiteStorage { get; set; }
public TemporaryAccommodationInfo TempAccommodationInfo { get; set; }
public FurtherAccountInformation FurtherAccountInformation { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ public class EditTenureDetailsRequestObject
public Charges Charges { get; set; }
public TenureType TenureType { get; set; }
public string TenureSource { get; set; }
public Terminated Terminated { get; set; }
public DateTime? PotentialEndDate { get; set; }
public Terminated Terminated { get; set; }
public DateTime? PotentialEndDate { get; set; }
public string FundingSource { get; set; }
public int NumberOfAdultsInProperty { get; set; }
public int NumberOfChildrenInProperty { get; set; }
public bool? HasOffsiteStorage { get; set; }
// Using a Domain (instead of Request) model because of limitations & risks imposed by the over-engineered entity updater solution
public TemporaryAccommodationInfo TempAccommodationInfo { get; set; }
public FurtherAccountInformation FurtherAccountInformation { get; set; }
public IEnumerable<LegacyReference> LegacyReferences { get; set; }
public TenuredAsset TenuredAsset { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Hackney.Shared.Tenure.Boundary.Response
{
public class TemporaryAccommodationInfoResponse
{
public string BookingStatus { get; set; }
public TemporaryAccommodationOfficerResponse AssignedOfficer { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace Hackney.Shared.Tenure.Boundary.Response
{
public class TemporaryAccommodationOfficerResponse
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class TenureResponseObject
public int NumberOfAdultsInProperty { get; set; }
public int NumberOfChildrenInProperty { get; set; }
public bool? HasOffsiteStorage { get; set; }
public TemporaryAccommodationInfoResponse TempAccommodationInfo { get; set; }
public FurtherAccountInformation FurtherAccountInformation { get; set; }
}
}
10 changes: 10 additions & 0 deletions Hackney.Shared.Tenure/Domain/TemporaryAccommodationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Hackney.Shared.Tenure.Domain
{
public class TemporaryAccommodationInfo
{
public string BookingStatus { get; set; }
public TemporaryAccommodationOfficer AssignedOfficer { get; set; }
}
}
11 changes: 11 additions & 0 deletions Hackney.Shared.Tenure/Domain/TemporaryAccommodationOfficer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace Hackney.Shared.Tenure.Domain
{
public class TemporaryAccommodationOfficer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
}
1 change: 1 addition & 0 deletions Hackney.Shared.Tenure/Domain/TenureInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class TenureInformation
public int NumberOfAdultsInProperty { get; set; }
public int NumberOfChildrenInProperty { get; set; }
public bool? HasOffsiteStorage { get; set; }
public TemporaryAccommodationInfo TempAccommodationInfo { get; set; }
public FurtherAccountInformation FurtherAccountInformation { get; set; }

}
Expand Down
1 change: 1 addition & 0 deletions Hackney.Shared.Tenure/Factories/CreateRequestFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static TenureInformationDb ToDatabase(this CreateTenureRequestObject crea
NumberOfAdultsInProperty = createTenureRequestObject.NumberOfAdultsInProperty,
NumberOfChildrenInProperty = createTenureRequestObject.NumberOfChildrenInProperty,
HasOffsiteStorage = createTenureRequestObject.HasOffsiteStorage,
TempAccommodationInfo = createTenureRequestObject.TempAccommodationInfo.ToDatabase(),
FurtherAccountInformation = createTenureRequestObject.FurtherAccountInformation
};
}
Expand Down
Loading

0 comments on commit ad01b70

Please sign in to comment.