コード例 #1
0
        public void Address_ValidateAddress_ShouldBeValid()
        {
            //Arrange
            var address = _addressTestFixture.GenerateValidAddress();

            //Act
            var result = address.ValidateAddress();

            //Assert
            Assert.True(result.IsValid);
        }
コード例 #2
0
        public async Task Add_AddNewAddressValid_ShouldAddWithSuccess()
        {
            //Arrange
            var address        = _addressTestFixture.GenerateValidAddress();
            var mocker         = new AutoMocker();
            var serviceAddress = mocker.CreateInstance <ServiceAddress>();

            mocker.GetMock <IUnitOfWork>().Setup(u => u.CommitAsync()).Returns(Task.FromResult(true));
            //Act
            await serviceAddress.AddAsyncUow(address);

            //Assert
            Assert.True(address.ValidateAddress().IsValid);

            mocker.GetMock <IRepositoryAddress>().Verify(n => n.Add(It.IsAny <Address>()), Times.Once);
            mocker.GetMock <IUnitOfWork>().Verify(n => n.CommitAsync(), Times.Once);
        }