public async void StockManagementControllerTest()
        {
            mockHttpContext.Setup(c => c.Request).Returns(new Mock <HttpRequest>().Object);
            mockHttpContext.Setup(c => c.Request.Query).Returns(new Mock <IQueryCollection>().Object);
            mockStockservice.Setup(x => x.GetStockDetails(true));
            var controllerContext = new ControllerContext()
            {
                HttpContext = mockHttpContext.Object
            };
            StockManagementController testControllerObject = new StockManagementController(mockStockservice.Object)
            {
                ControllerContext = controllerContext
            };
            IActionResult result = await testControllerObject.GetStockDetails();

            var jsonResult = result as JsonResult;
            var response   = (StockDetails)jsonResult.Value;

            Assert.AreEqual(response != null, true);
        }
示例#2
0
        public void Init()
        {
            var userProfiles = new List <UserProfile>
            {
                new UserProfile {
                    UserProfileID = 1, UserName = "******", Password = "******", Email = "*****@*****.**"
                },
                new UserProfile {
                    UserProfileID = 2, UserName = "******", Password = "******", Email = "*****@*****.**"
                },
            };
            var userProfileService = new Mock <IUserProfileService>();

            userProfileService.Setup(t => t.GetAllUserProfile()).Returns(userProfiles);

            var programs = new List <Program>
            {
                new Program {
                    ProgramID = 1, Name = "Relief"
                },
                new Program {
                    ProgramID = 2, Name = "PSNP"
                }
            };
            var programService = new Mock <IProgramService>();

            programService.Setup(t => t.GetAllProgram()).Returns(programs);

            var commodityTypes = new List <CommodityType>
            {
                new CommodityType {
                    CommodityTypeID = 1, Name = "Food"
                },
                new CommodityType {
                    CommodityTypeID = 2, Name = "Non Food"
                }
            };
            var commodityTypeService = new Mock <ICommodityTypeService>();

            commodityTypeService.Setup(t => t.GetAllCommodityType()).Returns(commodityTypes);

            var commoditySource = new List <CommoditySource>
            {
                new CommoditySource {
                    CommoditySourceID = 1, Name = "Donation"
                },
                new CommoditySource {
                    CommoditySourceID = 2, Name = "Loan"
                },
                new CommoditySource {
                    CommoditySourceID = 3, Name = "Local Purchase"
                },
            };
            var commoditySourceService = new Mock <ICommoditySourceService>();

            commoditySourceService.Setup(t => t.GetAllCommoditySource()).Returns(commoditySource);

            var projectCodes = new List <ProjectCode>
            {
                new ProjectCode {
                    ProjectCodeID = 76, Value = "10685 MT"
                },
                new ProjectCode {
                    ProjectCodeID = 77, Value = "1314.3"
                }
            };
            var projectCodeService = new Mock <IProjectCodeService>();

            projectCodeService.Setup(t => t.GetAllProjectCode()).Returns(projectCodes);

            var shippingInstructions = new List <ShippingInstruction>
            {
                new ShippingInstruction {
                    ShippingInstructionID = 104, Value = "00013753"
                },
                new ShippingInstruction {
                    ShippingInstructionID = 102, Value = "00014110"
                }
            };
            var shippingInstructionService = new Mock <IShippingInstructionService>();

            shippingInstructionService.Setup(t => t.GetAllShippingInstruction()).Returns(shippingInstructions);
            var receiveService           = new Mock <IReceiveService>();
            var storeService             = new Mock <IStoreService>();
            var hubService               = new Mock <IHubService>();
            var adminUnitService         = new Mock <IAdminUnitService>();
            var dispatchAllocationServie = new Mock <IDispatchAllocationService>();
            var donorService             = new Mock <IDonorService>();

            _stockManagementController = new StockManagementController(
                userProfileService.Object,
                programService.Object,
                commodityTypeService.Object,
                commoditySourceService.Object,
                projectCodeService.Object,
                shippingInstructionService.Object,
                receiveService.Object,
                storeService.Object,
                hubService.Object,
                adminUnitService.Object,
                dispatchAllocationServie.Object,
                donorService.Object);
        }