public void Client_ValidateClient_ShouldBeInvalid() { //Arrange var client = _clientTestFixture.GenerateInvalidClient(); //Act var result = client.ValidateClient(); //Assert Assert.False(result.IsValid); Assert.True(result.Errors.Any()); Assert.Equal(2, result.Errors.Count); Assert.Contains(ClientValidation.NameRequired, result.Errors.Select(e => e.ErrorMessage)); Assert.Contains(ClientValidation.DocumentRequired, result.Errors.Select(e => e.ErrorMessage)); }
public async Task Update_UpdateInvalidClient_ShouldNotUpdateClient() { //Arrange var client = _clientTestFixture.GenerateInvalidClient(); var mocker = new AutoMocker(); var serviceclient = mocker.CreateInstance <ServiceClient>(); //Act await serviceclient.UpdateAsyncUow(client); //Assert mocker.GetMock <IRepositoryClient>().Verify(r => r.Update(It.IsAny <Client>()), Times.Never); mocker.GetMock <IServiceAddress>().Verify(r => r.RemoveAllByClientId(It.IsAny <Guid>()), Times.Never); mocker.GetMock <IServiceAddress>().Verify(r => r.Add(It.IsAny <Address>()), Times.Never); mocker.GetMock <IServiceContact>().Verify(r => r.RemoveAllByClientId(It.IsAny <Guid>()), Times.Never); mocker.GetMock <IServiceContact>().Verify(r => r.Add(It.IsAny <Contact>()), Times.Never); mocker.GetMock <IUnitOfWork>().Verify(u => u.CommitAsync(), Times.Never); mocker.GetMock <INotifier>().Verify(n => n.Handle(It.IsAny <Notification>()), Times.Exactly(2)); }