Exemplo n.º 1
0
        public async Task When_Remove_Products_Of_Warehouse_Is_Correct_Remove_Product_Warehouse()
        {
            //Arrange
            var loggerMock = new Mock <ILogger <MovementService> >();
            Mock <IGenericRepository <Movement> > repositoryMovementMock = new MockMovementRepository().Queryable();
            Mock <IGenericRepository <Product> >  repositoryProductMock  = new MockProductRepository()
                                                                           .GetProductByIdAsync()
                                                                           .UpdateProductAsync()
                                                                           .Queryable();
            var mockUnitOfWork = new MockUnitOfWork().MovementRepository(repositoryMovementMock)
                                 .ProductRepository(repositoryProductMock)
                                 .SaveChangesAsync();
            var movementService = new MovementService(mockUnitOfWork.Object, loggerMock.Object);

            RemoveProductWarehouse movement = new RemoveProductWarehouse
            {
                Quantity    = 2,
                ProductId   = Guid.Parse("B99BC862-C515-4D61-97D8-4D2B188A19F3"),
                WarehouseId = Guid.Parse("351BA5AA-C78D-4491-931A-76603D729392")
            };

            //Act
            var result = await movementService.RemoveProductsOfWarehouse(movement);

            //Assert
            Assert.True(result.Equals(true));
        }
Exemplo n.º 2
0
        public async Task When_Remove_Products_Of_Warehouse_Is_No_Posible_Remove_Product_Warehouse()
        {
            //Arrange
            var loggerMock = new Mock <ILogger <MovementService> >();
            Mock <IGenericRepository <Movement> > repositoryMovementMock = new MockMovementRepository().Queryable();
            Mock <IGenericRepository <Product> >  repositoryProductMock  = new MockProductRepository()
                                                                           .GetProductByIdAsync()
                                                                           .UpdateProductAsync()
                                                                           .Queryable();
            var mockUnitOfWork = new MockUnitOfWork().MovementRepository(repositoryMovementMock)
                                 .ProductRepository(repositoryProductMock)
                                 .SaveChangesAsync();
            var movementService = new MovementService(mockUnitOfWork.Object, loggerMock.Object);

            RemoveProductWarehouse movement = new RemoveProductWarehouse
            {
                Quantity    = 35,
                ProductId   = Guid.Parse("B99BC862-C515-4D61-97D8-4D2B188A19F3"),
                WarehouseId = Guid.Parse("C347ED5D-1F33-49EE-A58D-B7F2310192A6")
            };
            Exception exception = null;

            //Act
            try
            {
                await movementService.RemoveProductsOfWarehouse(movement);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            //Assert
            Assert.True("It is not possible to remove, the warehouse only contains 14 of this product" == exception.Message);
            Assert.True(typeof(BusinessException) == exception.GetType());
        }