public async Task <GarmentLeftoverWarehouseReceiptAval> GetTestData()
        {
            GarmentLeftoverWarehouseReceiptAval data = GetNewData();

            await Service.CreateAsync(data);

            return(data);
        }
コード例 #2
0
        public async Task Create_Success_FABRIC()
        {
            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());

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

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

            var result = await service.CreateAsync(data);

            Assert.NotEqual(0, result);
        }
コード例 #3
0
        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());

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

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

            await Assert.ThrowsAnyAsync <Exception>(() => service.CreateAsync(data));
        }