public async Task <GarmentLeftoverWarehouseExpenditureAval> GetTestDataFabric()
        {
            GarmentLeftoverWarehouseExpenditureAval data = await GetNewDataFabric();

            await Service.CreateAsync(data);

            return(data);
        }
        public async Task Create_Error()
        {
            var serviceProvider = GetServiceProvider();

            GarmentLeftoverWarehouseExpenditureAvalService service = new GarmentLeftoverWarehouseExpenditureAvalService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            var data = await _dataUtil(service, GetCurrentMethod()).GetNewDataFabric();

            await Assert.ThrowsAnyAsync <Exception>(() => service.CreateAsync(data));
        }
        public async Task Update_Success_Acc()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

            stockServiceMock.Setup(s => s.StockIn(It.IsAny <GarmentLeftoverWarehouseStock>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(1);

            serviceProvider
            .Setup(x => x.GetService(typeof(IGarmentLeftoverWarehouseStockService)))
            .Returns(stockServiceMock.Object);


            GarmentLeftoverWarehouseExpenditureAvalService service = new GarmentLeftoverWarehouseExpenditureAvalService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            var dataUtil = _dataUtil(service, GetCurrentMethod());
            var oldData  = dataUtil.GetNewDataAcc();

            oldData.Items.Add(new GarmentLeftoverWarehouseExpenditureAvalItem
            {
                StockId     = 1,
                UnitId      = 1,
                UnitCode    = "Unit",
                UnitName    = "Unit",
                Quantity    = 1,
                UomId       = 1,
                UomUnit     = "Uom",
                ProductCode = "code",
                ProductId   = 1,
                ProductName = "product"
            });

            await service.CreateAsync(oldData);

            var newData = dataUtil.CopyData(oldData);

            newData.Description      = "New" + newData.Description;
            newData.LocalSalesNoteNo = "New" + newData.LocalSalesNoteNo;
            var firsItem = newData.Items.First();

            firsItem.Quantity++;
            var lastItem = newData.Items.Last();

            lastItem.Id = 0;

            var result = await service.UpdateAsync(newData.Id, newData);

            Assert.NotEqual(0, result);
        }
        public async Task Create_Success_ACC()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

            stockServiceMock.Setup(s => s.StockIn(It.IsAny <GarmentLeftoverWarehouseStock>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(1);

            serviceProvider
            .Setup(x => x.GetService(typeof(IGarmentLeftoverWarehouseStockService)))
            .Returns(stockServiceMock.Object);


            GarmentLeftoverWarehouseExpenditureAvalService service = new GarmentLeftoverWarehouseExpenditureAvalService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            var data = _dataUtil(service, GetCurrentMethod()).GetNewDataAcc();

            var result = await service.CreateAsync(data);

            Assert.NotEqual(0, result);
        }
        public async Task Update_Success()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

            stockServiceMock.Setup(s => s.StockIn(It.IsAny <GarmentLeftoverWarehouseStock>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(1);

            serviceProvider
            .Setup(x => x.GetService(typeof(IGarmentLeftoverWarehouseStockService)))
            .Returns(stockServiceMock.Object);


            GarmentLeftoverWarehouseExpenditureAvalService service = new GarmentLeftoverWarehouseExpenditureAvalService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            var dataUtil = _dataUtil(service, GetCurrentMethod());
            var oldData  = await dataUtil.GetNewDataFabric();

            var newItem = await dataUtil.GetNewDataItemFabric();

            await service.CreateAsync(oldData);

            var newData = dataUtil.CopyData(oldData);

            newData.ExpenditureDate  = newData.ExpenditureDate.AddDays(-1);
            newData.Description      = "New" + newData.Description;
            newData.LocalSalesNoteNo = "New" + newData.LocalSalesNoteNo;
            newData.Items.Add(newItem);
            var lastItem = newData.Items.Last();

            lastItem.Id = 0;

            var result = await service.UpdateAsync(newData.Id, newData);

            Assert.NotEqual(0, result);
        }