示例#1
0
        public void HouseholdRepository_ShouldCallAddOnce_WhenCreateHouseholdIsCalled()
        {
            // Arrange
            var householdStub = new Household("_", "_", new byte[0]);

            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <byte[]>())).Returns(householdStub);

            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);

            // Act
            householdService.CreateHousehold("_", "_", new byte[0], "_");

            // Assert
            this.householdRepoMock.Verify(x => x.Add(It.IsAny <Household>()), Times.Once);
        }
示例#2
0
        public void HouseholdUsersCount_ShouldBeIncreasedByOne_WhenCreateHouseholdIsCalled()
        {
            // Arrange
            var householdStub = new Household("_", "_", new byte[0]);

            householdFactoryMock.Setup(x => x.CreateHousehold(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <byte[]>())).Returns(householdStub);
            var expected = householdStub.Users.Count + 1;

            var householdService = new HouseholdService(unitOfWorkMock.Object, householdRepoMock.Object, userRepoMock.Object, householdFactoryMock.Object);

            // Act
            householdService.CreateHousehold("_", "_", new byte[0], "_");

            // Assert
            Assert.That(expected == householdStub.Users.Count);
        }