Esempio n. 1
0
        public async Task When_Move_Product_Other_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);

            MoveProducts moveProducts = new MoveProducts
            {
                Quantity           = 3,
                ProductId          = Guid.Parse("B99BC862-C515-4D61-97D8-4D2B188A19F3"),
                CurrentWarehouseId = Guid.Parse("351BA5AA-C78D-4491-931A-76603D729392"),
                NewWarehouseId     = Guid.Parse("C347ED5D-1F33-49EE-A58D-B7F2310192A6")
            };

            //Act
            var result = await movementService.MoveProductOtherWarehouse(moveProducts);

            //Assert
            Assert.NotNull(result);
            Assert.True(result.ToList().Count > 0);
        }
Esempio n. 2
0
        public async Task When_Error_Move_Product_Other_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);

            MoveProducts moveProducts = new MoveProducts
            {
                Quantity           = 23,
                ProductId          = Guid.Parse("A16C605C-0A1A-4E63-857F-68019CE2575C"),
                CurrentWarehouseId = Guid.Parse("351BA5AA-C78D-4491-931A-76603D729392"),
                NewWarehouseId     = Guid.Parse("C347ED5D-1F33-49EE-A58D-B7F2310192A6")
            };

            Exception exception = null;

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

            //Assert
            Assert.True("product not found in the selected warehouse" == exception.Message);
            Assert.True(typeof(BusinessException) == exception.GetType());
        }