Exemplo n.º 1
0
        public void Client_ValidateClient_ShouldBeValid()
        {
            //Arrange
            var client = _clientTestFixture.GenerateValidClient();

            //Act
            var result = client.ValidateClient();

            //Assert
            Assert.True(result.IsValid);
        }
Exemplo n.º 2
0
        public async Task Add_AddNewClient_ShouldAddWithSuccess()
        {
            //Arrange
            var client        = _clientTestFixture.GenerateValidClient();
            var mocker        = new AutoMocker();
            var serviceclient = mocker.CreateInstance <ServiceClient>();

            mocker.GetMock <IUnitOfWork>().Setup(u => u.CommitAsync()).Returns(Task.FromResult(true));

            //Act
            await serviceclient.AddAsyncUow(client);

            //Assert
            Assert.True(client.ValidateClient().IsValid);
            mocker.GetMock <IRepositoryClient>().Verify(r => r.Add(It.IsAny <Client>()), Times.Once);
            mocker.GetMock <IServiceAddress>().Verify(r => r.Add(It.IsAny <Address>()), Times.Exactly(client.Addresses.Count));
            mocker.GetMock <IServiceContact>().Verify(r => r.Add(It.IsAny <Contact>()), Times.Exactly(client.Contacts.Count));
            mocker.GetMock <IUnitOfWork>().Verify(u => u.CommitAsync(), Times.Once);
        }