コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task Should_Success_GetXlsReportT()
        {
            var serviceProvider = GetServiceProvider();

            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\"}]}}");

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

            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.OK)
            {
                Content = new StringContent(new UnitDODataUtil().GetMultipleResultBCFormatterOkString())
            });

            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.OK)
            {
                Content = new StringContent(new UnitDODataUtil().GetMultipleResultFormatterOkString())
            });

            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.GenerateExcel(null, DateTime.Now, 7);


            Assert.NotNull(result);
        }