Example #1
0
        public void TestThatModifyDataCallsUpdateWithUpdatedHouseholdOnHouseholdDataRepository()
        {
            HouseholdUpdateCommandHandler sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            IHousehold householdMock = DomainObjectMockBuilder.BuildHouseholdMock();

            HouseholdUpdateCommand householdUpdateCommand = _fixture.Build <HouseholdUpdateCommand>()
                                                            .With(m => m.HouseholdIdentifier, Guid.NewGuid())
                                                            .With(m => m.Name, _fixture.Create <string>())
                                                            .With(m => m.Description, _fixture.Create <string>())
                                                            .Create();

            sut.ModifyData(householdMock, householdUpdateCommand);

            _householdDataRepositoryMock.AssertWasCalled(m => m.Update(Arg <IHousehold> .Is.Equal(householdMock)), opt => opt.Repeat.Once());
        }
Example #2
0
        public void TestThatModifyDataReturnsResultFromUpdateWithOnHouseholdDataRepository()
        {
            IHousehold updatedHouseholdMock = DomainObjectMockBuilder.BuildHouseholdMock();

            HouseholdUpdateCommandHandler sut = CreateSut(updatedHouseholdMock);

            Assert.That(sut, Is.Not.Null);

            HouseholdUpdateCommand householdUpdateCommand = _fixture.Build <HouseholdUpdateCommand>()
                                                            .With(m => m.HouseholdIdentifier, Guid.NewGuid())
                                                            .With(m => m.Name, _fixture.Create <string>())
                                                            .With(m => m.Description, _fixture.Create <string>())
                                                            .Create();

            IIdentifiable result = sut.ModifyData(DomainObjectMockBuilder.BuildHouseholdMock(), householdUpdateCommand);

            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.EqualTo(updatedHouseholdMock));
        }
Example #3
0
        public void TestThatModifyDataCallsDescriptionSetterOnHouseholdWithDescriptionFromCommand()
        {
            HouseholdUpdateCommandHandler sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            IHousehold householdMock = DomainObjectMockBuilder.BuildHouseholdMock();

            string description = _fixture.Create <string>();
            HouseholdUpdateCommand householdUpdateCommand = _fixture.Build <HouseholdUpdateCommand>()
                                                            .With(m => m.HouseholdIdentifier, Guid.NewGuid())
                                                            .With(m => m.Name, _fixture.Create <string>())
                                                            .With(m => m.Description, description)
                                                            .Create();

            sut.ModifyData(householdMock, householdUpdateCommand);

            householdMock.AssertWasCalled(m => m.Description = Arg <string> .Is.Equal(description), opt => opt.Repeat.Once());
        }
Example #4
0
        public void TestThatModifyDataThrowsArgumentNullExceptionWhenHouseholdUpdateCommandIsNull()
        {
            HouseholdUpdateCommandHandler sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ModifyData(DomainObjectMockBuilder.BuildHouseholdMock(), null));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "command");
        }
Example #5
0
        public void TestThatModifyDataThrowsArgumentNullExceptionWhenHouseholdIsNull()
        {
            HouseholdUpdateCommandHandler sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ModifyData(null, _fixture.Create <HouseholdUpdateCommand>()));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "household");
        }