public async Task GetClientArgumentNullFailure() { // Arrange var clientDataAccessMock = new Mock <IClientDataAccess>(); clientDataAccessMock .Setup(dataAccess => dataAccess.Get(null)) .ThrowsAsync(new ArgumentNullException()); var getClientService = new GetClientService(clientDataAccessMock.Object); // Act var action = new Func <Task>(() => getClientService.GetClient(null)); // Assert await action.Should().ThrowAsync <ArgumentNullException>("Null params"); }
public async Task GetClientInvalidOperationFailure() { // Arrange var clientIdentityMock = new Mock <IClientIdentity>(); var clientDataAccessMock = new Mock <IClientDataAccess>(); clientDataAccessMock .Setup(dataAccess => dataAccess.Get(clientIdentityMock.Object)) .ReturnsAsync((Client)null); var getClientService = new GetClientService(clientDataAccessMock.Object); // Act var action = new Func <Task>(() => getClientService.GetClient(clientIdentityMock.Object)); // Assert await action.Should().ThrowAsync <InvalidOperationException>("Not found by id"); }
public async Task GetClientSuccess() { // Arrange var clientIdentityMock = new Mock <IClientIdentity>(); var client = new Client(); var clientDataAccessMock = new Mock <IClientDataAccess>(); clientDataAccessMock .Setup(dataAccess => dataAccess.Get(clientIdentityMock.Object)) .ReturnsAsync(client); var getClientService = new GetClientService(clientDataAccessMock.Object); // Act var action = await getClientService.GetClient(clientIdentityMock.Object); // Assert action.Should().Be(client); clientDataAccessMock.Verify(); }
public async Task <IEnumerable <ClientDTO> > Get() { var result = await GetClientService.GetClient(); return(Mapper.Map <IEnumerable <ClientDTO> >(result)); }
public async Task <ClientDTO> Get(int id) { var result = await GetClientService.GetClient(new ClientIdentityModel(id)); return(Mapper.Map <ClientDTO>(result)); }