Ejemplo n.º 1
0
        public async Task ReadById_Success()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

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

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

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpService)))
            .Returns(new HttpTestService());

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

            var data = await _dataUtil(service).GetTestData();

            var result = await service.ReadByIdAsync(data.Id);

            Assert.NotNull(result);
        }
Ejemplo n.º 2
0
        public async Task CheckStockQuantity_Success()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();
            var stockQuantity    = 10;

            stockServiceMock.Setup(s => s.ReadById(It.IsAny <int>()))
            .Returns(new GarmentLeftoverWarehouseStock
            {
                Quantity = stockQuantity
            });

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

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

            var data = await _dataUtil(service).GetTestData();

            foreach (var item in data.Items)
            {
                var result = service.CheckStockQuantity(data.Id, item.StockId);
                Assert.Equal(stockQuantity, result - item.Quantity);
            }
        }
Ejemplo n.º 3
0
        public async Task Should_Success_GetFabricExcelReport()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

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

            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);

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpService)))
            .Returns(new HttpTestService());

            GarmentLeftoverWarehouseStockReportService utilService = new GarmentLeftoverWarehouseStockReportService(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);

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

            GarmentLeftoverWarehouseBalanceStockService _balanceservice = new GarmentLeftoverWarehouseBalanceStockService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            GarmentLeftoverWarehouseReceiptFabricService receiptservice = new GarmentLeftoverWarehouseReceiptFabricService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            var data_Balance = _dataUtilbalanceStock(_balanceservice).GetTestData_FABRIC();

            var dataReceiptFabric = _dataUtilReceiptFabric(receiptservice).GetTestData();

            var dataFabric = await _dataUtilFabric(service).GetTestData();

            GarmentLeftoverWarehouseStockService serviceStock = new GarmentLeftoverWarehouseStockService(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);

            GarmentLeftoverWarehouseStock stock = new GarmentLeftoverWarehouseStock
            {
                ReferenceType = GarmentLeftoverWarehouseStockReferenceTypeEnum.FABRIC,
                UnitId        = 1,
                UnitCode      = "Unit",
                UnitName      = "UnitFromName",
                PONo          = "PONo",
                ProductCode   = "ProductCode",
                ProductName   = "ProductName",
                Quantity      = 1,
                UomId         = 1,
                UomUnit       = "Uom"
            };

            var resultStock = await serviceStock.StockIn(stock, "StockReferenceNo", 1, 1);

            await serviceStock.StockIn(stock, "StockReferenceNo", 1, 1);

            var result = utilService.GenerateExcelFabric(DateTime.Now, DateTime.Now, 1, 7);


            Assert.NotNull(result);
        }
Ejemplo n.º 4
0
        public async Task Update_Success()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

            stockServiceMock.Setup(s => s.StockOut(It.IsAny <GarmentLeftoverWarehouseStock>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(1);
            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);

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpService)))
            .Returns(new HttpTestService());

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

            var dataUtil = _dataUtil(service);
            var oldData  = dataUtil.GetNewData();

            oldData.Items.Add(new GarmentLeftoverWarehouseExpenditureFabricItem
            {
                StockId  = 2,
                UnitId   = 2,
                UnitCode = "Unit",
                UnitName = "Unit",
                PONo     = "PONo2",
                Quantity = 10,
                UomId    = 2,
                UomUnit  = "Uom"
            });

            await service.CreateAsync(oldData);

            var newData = dataUtil.CopyData(oldData);

            newData.ExpenditureDate  = newData.ExpenditureDate.AddDays(-1);
            newData.Remark           = "New" + newData.Remark;
            newData.LocalSalesNoteNo = "New" + newData.LocalSalesNoteNo;
            newData.IsUsed           = true;
            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);
        }
Ejemplo n.º 5
0
        public void MapToModel()
        {
            GarmentLeftoverWarehouseExpenditureFabricService service = new GarmentLeftoverWarehouseExpenditureFabricService(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);

            var data = new GarmentLeftoverWarehouseExpenditureFabricViewModel
            {
                ExpenditureDate        = DateTimeOffset.Now,
                ExpenditureDestination = "SAMPLE",
                UnitExpenditure        = new UnitViewModel
                {
                    Id   = "1",
                    Code = "Unit",
                    Name = "Unit"
                },
                Buyer = new BuyerViewModel
                {
                    Id   = 1,
                    Code = "Code",
                    Name = "Name"
                },
                EtcRemark = "Remark",
                Remark    = "Remark",
                Items     = new List <GarmentLeftoverWarehouseExpenditureFabricItemViewModel>
                {
                    new GarmentLeftoverWarehouseExpenditureFabricItemViewModel
                    {
                        StockId = 1,
                        Unit    = new UnitViewModel {
                            Id   = "1",
                            Code = "Unit",
                            Name = "Unit"
                        },
                        PONo     = "PONo",
                        Quantity = 1,
                        Uom      = new UomViewModel
                        {
                            Id   = "1",
                            Unit = "Uom"
                        }
                    }
                }
            };

            var result = service.MapToModel(data);

            Assert.NotNull(result);
        }
        public async Task Should_Success_GetRecapStockReportTypeFabric()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

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

            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);

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpService)))
            .Returns(new HttpTestService());

            GarmentLeftoverWarehouseRecapStockReportService utilService = new GarmentLeftoverWarehouseRecapStockReportService(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);

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

            GarmentLeftoverWarehouseBalanceStockService _balanceservice = new GarmentLeftoverWarehouseBalanceStockService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            GarmentLeftoverWarehouseReceiptFabricService receiptFabservice = new GarmentLeftoverWarehouseReceiptFabricService(_dbContext(GetCurrentMethod()), serviceProvider.Object);

            var dataFabric = await _dataUtilFabric(service).GetTestData();

            var data_Balance = _dataUtilbalanceStock(_balanceservice).GetTestData_FABRIC();

            var dataReceiptAcc = _dataUtilReceiptFabric(receiptFabservice).GetTestData();

            var result = utilService.GetReportQuery(DateTime.Now, DateTime.Now, 7);


            Assert.NotNull(result);
        }
Ejemplo n.º 7
0
        public async Task Create_Error()
        {
            var serviceProvider = GetServiceProvider();

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

            stockServiceMock.Setup(s => s.StockOut(It.IsAny <GarmentLeftoverWarehouseStock>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .ThrowsAsync(new Exception());

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

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpService)))
            .Returns(new HttpFailTestService());

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

            var data = _dataUtil(service).GetNewData();

            await Assert.ThrowsAnyAsync <Exception>(() => service.CreateAsync(data));
        }
 private GarmentLeftoverWarehouseExpenditureFabricDataUtil _dataUtilFabric(GarmentLeftoverWarehouseExpenditureFabricService service)
 {
     GetServiceProvider();
     return(new GarmentLeftoverWarehouseExpenditureFabricDataUtil(service));
 }
Ejemplo n.º 9
0
        public async Task GetReportFabric_Success()
        {
            var serviceProvider21 = new Mock <IServiceProvider>();

            var httpClientService = new Mock <IHttpService>();

            //httpClientService
            //    .Setup(x => x.GetAsync(It.Is<string>(s => s.Contains("garment-shipping/local-cover-letters"))))
            //    .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(JsonConvert.SerializeObject(new List<Dictionary<string, Object>>())) });

            //httpClientService
            //    .Setup(x => x.GetAsync(It.Is<string>(s => s.Contains("master/garmentProducts"))))
            //    .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(JsonConvert.SerializeObject(new List<Dictionary<string, Object>>())) });

            //serviceProvider21
            //    .Setup(x => x.GetService(typeof(IIdentityService)))
            //    .Returns(new IdentityService() { Token = "Token", Username = "******" });

            //serviceProvider21
            //    .Setup(x => x.GetService(typeof(IHttpService)))
            //    .Returns(httpClientService.Object);

            HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            message.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":[{\"Id\":7,\"POSerialNumber\":\"PONo\",\"BeacukaiNo\":\"BC001\",\"CustomsType\":\"A\",\"BeacukaiDate\":\"2018/10/20\"}],\"info\":{\"count\":1,\"page\":1,\"size\":1,\"total\":2,\"order\":{\"date\":\"desc\"},\"select\":[\"Id\",\"CustomsType\",\"BeacukaiDate\",\"BeacukaiNo\",,\"POSerialNumber\"]}}");

            HttpResponseMessage message2 = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            message2.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":{\"Id\":\"7\",\"Composition\":\"Composition\",\"Const\":\"Const\",\"Yarn\":\"Yarn\",\"Width\":\"Width\"},\"info\":{\"count\":1,\"page\":1,\"size\":1,\"total\":2,\"order\":{\"date\":\"desc\"},\"select\":[\"Id\",\"CustomsType\",\"BeacukaiDate\",\"BeacukaiNo\",,\"POSerialNumber\"]}}");

            HttpResponseMessage message3 = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            message3.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":[{\"Id\":\"7\",\"bcNo\":\"bcNo\",\"bcDate\":\"2018/10/20\",\"noteNo\":\"LocalSalesNoteNo\"}],\"info\":{\"count\":1,\"page\":1,\"size\":1,\"total\":2,\"order\":{\"date\":\"desc\"},\"select\":[\"Id\",\"CustomsType\",\"BeacukaiDate\",\"BeacukaiNo\",,\"POSerialNumber\"]}}");

            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("garment-beacukai/by-poserialnumber"))))
            .ReturnsAsync(message);

            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garmentProducts"))))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new List <Dictionary <string, Object> >()))
            });

            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("garment-shipping/local-cover-letters"))))
            .ReturnsAsync(message3);



            httpClientService
            .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garmentProducts"))))
            .ReturnsAsync(message2);


            serviceProvider21
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(new IdentityService()
            {
                Token = "Token", Username = "******"
            });

            serviceProvider21
            .Setup(x => x.GetService(typeof(IHttpService)))
            .Returns(httpClientService.Object);

            var stockServiceMock = new Mock <IGarmentLeftoverWarehouseStockService>();

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

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

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

            //serviceProvider21
            //    .Setup(x => x.GetService(typeof(IHttpService)))
            //    .Returns(new HttpTestService());

            GarmentLeftoverWarehouseReportExpenditureService service = new GarmentLeftoverWarehouseReportExpenditureService(serviceProvider21.Object, _dbContext(GetCurrentMethod()));

            GarmentLeftoverWarehouseExpenditureFabricService serviceexpend = new GarmentLeftoverWarehouseExpenditureFabricService(_dbContext(GetCurrentMethod()), serviceProvider21.Object);


            var dataFabric = _dataUtilFabric(serviceexpend).GetNewData();

            await serviceexpend.CreateAsync(dataFabric);

            //GarmentLeftoverWarehouseReportExpenditureService service = new GarmentLeftoverWarehouseReportExpenditureService(serviceProvider21.Object,_dbContext(GetCurrentMethod()));

            var result = service.GetReport(DateTime.Now.AddDays(-1), DateTime.Now, "FABRIC", 1, 25, "{}", 1);

            Assert.NotNull(result);
        }
Ejemplo n.º 10
0
 private GarmentLeftoverWarehouseExpenditureFabricDataUtil _dataUtil(GarmentLeftoverWarehouseExpenditureFabricService service)
 {
     return(new GarmentLeftoverWarehouseExpenditureFabricDataUtil(service));
 }
Ejemplo n.º 11
0
 public async Task Delete_Error()
 {
     GarmentLeftoverWarehouseExpenditureFabricService service = new GarmentLeftoverWarehouseExpenditureFabricService(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);
     await Assert.ThrowsAnyAsync <Exception>(() => service.DeleteAsync(0));
 }
Ejemplo n.º 12
0
 public GarmentLeftoverWarehouseExpenditureFabricDataUtil(GarmentLeftoverWarehouseExpenditureFabricService service)
 {
     Service = service;
 }