public async Task When_Exist_Warehouse_Service(string id) { //Arrange var loggerMock = new Mock <ILogger <WarehouseService> >(); Mock <IGenericRepository <Warehouse> > repositoryMock = new MockWarehouseRespository().WarehouseExistsAsync(); var mockUnitOfWork = new MockUnitOfWork().WarehoueseRepository(repositoryMock); var warehouseService = new WarehouseService(mockUnitOfWork.Object, loggerMock.Object); //Act var result = await warehouseService.ExistWarehouseAsync(Guid.Parse(id)); //Assert Assert.True(result.Equals(true)); }
public async Task When_Not_Exist_Warehouse_Service(string id) { //Arrange Exception exception = null; var loggerMock = new Mock <ILogger <WarehouseService> >(); Mock <IGenericRepository <Warehouse> > repositoryMock = new MockWarehouseRespository().WarehouseExistsAsync(); var mockUnitOfWork = new MockUnitOfWork().WarehoueseRepository(repositoryMock); var warehouseService = new WarehouseService(mockUnitOfWork.Object, loggerMock.Object); //Act try { await warehouseService.ExistWarehouseAsync(Guid.Parse(id)); } catch (Exception ex) { exception = ex; } //Assert Assert.True("Warehouse doesn't exist" == exception.Message); }