示例#1
0
        public async Task Should_Success_GetReportT()
        {
            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());

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


            var dataFinishedGood = await _dataUtilFinishedGood(service).GetTestData();;

            var result = service.GetMonitoring(DateTime.Now, DateTime.Now, 1, 1, "{}", 7);


            Assert.NotNull(result);
        }
        public async Task ReadById_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);


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

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

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

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

            Assert.NotNull(result);
        }
        public async Task Should_Success_GetXlsReportT()
        {
            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());


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


            var dataFinishedGood = _dataUtilFinishedGood(service).GetNewData();

            dataFinishedGood.ReceiptDate = dataFinishedGood.ReceiptDate.AddDays(-1);

            await service.CreateAsync(dataFinishedGood);

            var result = service.GenerateExcel(null, DateTime.Now, 7);


            Assert.NotNull(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);


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

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

            var dataUtil = _dataUtil(service);
            var oldData  = await dataUtil.GetTestData();

            var newData = dataUtil.CopyData(oldData);

            newData.ReceiptDate = DateTimeOffset.Now;
            newData.Description = "New Remark";

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

            Assert.NotEqual(0, result);
        }
        public async Task Should_Success_GetFInishedGoodExcelReport()
        {
            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);

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

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

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

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

            var dataReceiptFInishedGood = _dataUtilReceiptFinishedGood(receiptservice).GetTestData();

            var dataFinishedGood = await _dataUtilFinishedGood(service).GetTestData();

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


            Assert.NotNull(result);
        }
        public async Task Create_Error()
        {
            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);

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

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

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

            await Assert.ThrowsAnyAsync <Exception>(() => service.CreateAsync(data));
        }
 private GarmentLeftoverWarehouseReceiptFinishedGoodDataUtil _dataUtil(GarmentLeftoverWarehouseReceiptFinishedGoodService service)
 {
     return(new GarmentLeftoverWarehouseReceiptFinishedGoodDataUtil(service));
 }
 private GarmentLeftoverWarehouseReceiptFinishedGoodDataUtil _dataUtilFinishedGood(GarmentLeftoverWarehouseReceiptFinishedGoodService service)
 {
     GetServiceProvider();
     return(new GarmentLeftoverWarehouseReceiptFinishedGoodDataUtil(service));
 }
        public void MapToModel()
        {
            GarmentLeftoverWarehouseReceiptFinishedGoodService service = new GarmentLeftoverWarehouseReceiptFinishedGoodService(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);

            var data = new GarmentLeftoverWarehouseReceiptFinishedGoodViewModel
            {
                UnitFrom = new UnitViewModel
                {
                    Id   = "1",
                    Code = "Unit",
                    Name = "Unit"
                },
                ExpenditureDate = DateTimeOffset.Now,
                ReceiptDate     = DateTimeOffset.Now,
                Description     = "Remark",
                Carton          = 1,
                ContractNo      = "noContract",
                ExpenditureDesc = "desc",
                Invoice         = "inv",
                Items           = new List <GarmentLeftoverWarehouseReceiptFinishedGoodItemViewModel>
                {
                    new GarmentLeftoverWarehouseReceiptFinishedGoodItemViewModel
                    {
                        ExpenditureGoodItemId = Guid.NewGuid(),
                        Size = new SizeViewModel {
                            Id   = 1,
                            Name = "Size",
                            Code = "Code"
                        },
                        Remark   = "Remark",
                        Quantity = 1,
                        Uom      = new UomViewModel
                        {
                            Id   = "1",
                            Unit = "Uom"
                        },
                        LeftoverComodity = new LeftoverComodityViewModel
                        {
                            Id   = 1,
                            Name = "como",
                            Code = "como"
                        },
                        ExpenditureGoodId = Guid.NewGuid(),
                        ExpenditureGoodNo = "no",
                        Buyer             = new BuyerViewModel
                        {
                            Id   = 1,
                            Code = "Buyer",
                            Name = "Buyer"
                        },
                        Comodity = new ComodityViewModel
                        {
                            Id   = 1,
                            Code = "Comodity",
                            Name = "Comodity"
                        },
                        RONo    = "roNo",
                        Article = "art",
                    }
                }
            };

            var result = service.MapToModel(data);

            Assert.NotNull(result);
        }
 public async Task Delete_Error()
 {
     GarmentLeftoverWarehouseReceiptFinishedGoodService service = new GarmentLeftoverWarehouseReceiptFinishedGoodService(_dbContext(GetCurrentMethod()), GetServiceProvider().Object);
     await Assert.ThrowsAnyAsync <Exception>(() => service.DeleteAsync(0));
 }
 public GarmentLeftoverWarehouseReceiptFinishedGoodDataUtil(GarmentLeftoverWarehouseReceiptFinishedGoodService service)
 {
     Service = service;
 }
示例#12
0
        public async Task Should_Failed_GetFInishedGoodExcelReport()
        {
            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());



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

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

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

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

            var dataReceiptFInishedGood = _dataUtilReceiptFinishedGood(receiptservice).GetTestData();

            var httpClientService = new Mock <IHttpService>();

            var ExpendGood = new List <ExpendGoodViewModel> {
                new ExpendGoodViewModel
                {
                    RONo     = "roNo",
                    Comodity = new GarmentComodity
                    {
                        Code = "Code",
                        Id   = 10,
                        Name = "Name"
                    }
                }
            };

            Dictionary <string, object> result2 =
                new ResultFormatter("1.0", WebApi.Helpers.General.OK_STATUS_CODE, WebApi.Helpers.General.OK_MESSAGE)
                .Ok(ExpendGood);

            httpClientService
            .Setup(x => x.SendAsync(It.IsAny <HttpMethod>(), It.Is <string>(s => s.Contains("expenditure-goods/traceable-by-ro")), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(result2))
            });

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



            var dataFinishedGood = await _dataUtilFinishedGood(service).GetTestData();

            GarmentLeftoverWarehouseStockReportService utilService = new GarmentLeftoverWarehouseStockReportService(_dbContext(GetCurrentMethod()), serviceProvider.Object);
            var result = utilService.GenerateExcelFinishedGood(DateTime.Now, DateTime.Now, 10, 7);


            Assert.NotNull(result);
        }
        public async Task Should_Success_GetReportT_InternalServerError()
        {
            var serviceProvider1 = 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);



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

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

            var serviceProvider = new Mock <IServiceProvider>();

            var httpClientService             = new Mock <IHttpService>();
            HttpResponseMessage messageunitdo = new HttpResponseMessage(System.Net.HttpStatusCode.OK);

            messageunitdo.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":[{\"POSerialNumber\":\"PONo\",\"ProductCode\":\"ProductCode\",\"ProductName\":\"FABRIC\",\"BeacukaiDate\":\"2018/10/20\"},{\"POSerialNumber\":\"PONo123\",\"ProductCode\":\"ProductCode\",\"ProductName\":\"FABRIC\",\"BeacukaiDate\":\"2018/10/20\"}]}}");


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

            messagebc.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":[{\"POSerialNumber\":\"PONo\",\"customnos\":[{}]\"ProductCode\",\"ProductName\":\"FABRIC\",\"BeacukaiDate\":\"2018/10/20\"},{\"POSerialNumber\":\"PONo123\",\"ProductCode\":\"ProductCode\",\"ProductName\":\"FABRIC\",\"BeacukaiDate\":\"2018/10/20\"}]}}");

            httpClientService
            .Setup(x => x.SendAsync(It.IsAny <HttpMethod>(), It.Is <string>(s => s.Contains("garment-beacukai/by-poserialnumbers")), It.IsAny <StringContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.InternalServerError));

            httpClientService
            .Setup(x => x.SendAsync(It.IsAny <HttpMethod>(), It.Is <string>(s => s.Contains("garment-unit-delivery-orders/leftoverwarehouse")), It.IsAny <StringContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.InternalServerError));

            httpClientService
            .Setup(x => x.PutAsync(It.Is <string>(s => s.Contains("update-received")), It.IsAny <StringContent>()))
            .ReturnsAsync(messageunitdo);

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

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

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

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


            var dataFinishedGood = _dataUtilFinishedGood(service).GetNewData();

            dataFinishedGood.ReceiptDate = dataFinishedGood.ReceiptDate.AddDays(-1);

            await service.CreateAsync(dataFinishedGood);

            var result = service.GetMonitoring(null, DateTime.Now, 1, 25, "{}", 7);


            Assert.NotNull(result);
        }