예제 #1
0
        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>();
        }
예제 #2
0
        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");
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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());
        }