public void WhenIsMainCarerIsNullItDoesNotThrowANullException() { var(person, otherPerson) = PersonalRelationshipsHelper.SavePersonAndOtherPersonToDatabase(DatabaseContext); var type = DatabaseContext.PersonalRelationshipTypes.FirstOrDefault(prt => prt.Description == "parent"); var request = PersonalRelationshipsHelper.CreatePersonalRelationshipRequest( person.Id, otherPerson.Id, type.Id, type.Description ); request.IsMainCarer = null; Action act = () => _databaseGateway.CreatePersonalRelationship(request); act.Should().NotThrow <NullReferenceException>(); }
public void WhenIsMainCarerIsLowercaseConvertsItToUppercase() { var(person, otherPerson) = PersonalRelationshipsHelper.SavePersonAndOtherPersonToDatabase(DatabaseContext); var type = DatabaseContext.PersonalRelationshipTypes.FirstOrDefault(prt => prt.Description == "parent"); var request = PersonalRelationshipsHelper.CreatePersonalRelationshipRequest( person.Id, otherPerson.Id, type.Id, type.Description, isMainCarer: "y" ); _databaseGateway.CreatePersonalRelationship(request); var personalRelationship = DatabaseContext.PersonalRelationships.FirstOrDefault(); personalRelationship?.IsMainCarer.Should().Be("Y"); }
public void AuditsThePersonalRelationshipDetails() { var(person, otherPerson) = PersonalRelationshipsHelper.SavePersonAndOtherPersonToDatabase(DatabaseContext); var type = DatabaseContext.PersonalRelationshipTypes.FirstOrDefault(prt => prt.Description == "parent"); var request = PersonalRelationshipsHelper.CreatePersonalRelationshipRequest( person.Id, otherPerson.Id, type.Id, type.Description ); var response = _databaseGateway.CreatePersonalRelationship(request); var details = DatabaseContext.PersonalRelationshipDetails.FirstOrDefault(); details?.CreatedAt.Should().NotBeNull(); details?.CreatedBy.Should().Be(request.CreatedBy); }
public void SetsStartDateToNow() { var fakeTime = new DateTime(2000, 1, 1, 15, 30, 0); _mockSystemTime.Setup(time => time.Now).Returns(fakeTime); var(person, otherPerson) = PersonalRelationshipsHelper.SavePersonAndOtherPersonToDatabase(DatabaseContext); var type = DatabaseContext.PersonalRelationshipTypes.FirstOrDefault(prt => prt.Description == "parent"); var request = PersonalRelationshipsHelper.CreatePersonalRelationshipRequest( person.Id, otherPerson.Id, type.Id, type.Description ); _databaseGateway.CreatePersonalRelationship(request); var personalRelationship = DatabaseContext.PersonalRelationships.FirstOrDefault(); personalRelationship?.StartDate.Should().Be(fakeTime); }
public void CreatesAPersonalRelationship() { var(person, otherPerson) = PersonalRelationshipsHelper.SavePersonAndOtherPersonToDatabase(DatabaseContext); var type = DatabaseContext.PersonalRelationshipTypes.FirstOrDefault(prt => prt.Description == "parent"); var request = PersonalRelationshipsHelper.CreatePersonalRelationshipRequest( person.Id, otherPerson.Id, type.Id, type.Description ); _databaseGateway.CreatePersonalRelationship(request); var personalRelationship = DatabaseContext.PersonalRelationships.FirstOrDefault(); personalRelationship?.PersonId.Should().Be(request.PersonId); personalRelationship?.OtherPersonId.Should().Be(request.OtherPersonId); personalRelationship?.TypeId.Should().Be(request.TypeId); personalRelationship?.IsMainCarer.Should().Be(request.IsMainCarer.ToUpper()); personalRelationship?.IsInformalCarer.Should().Be(request.IsInformalCarer.ToUpper()); }