Exemple #1
0
        public async Task OnGet_GoodTempData_GoodContext_ReturnsPageResult()
        {
            var CargoGroups = new List <CargoGroup>()
            {
                new CargoGroup {
                    Description = "TEST_DESCRIPTION"
                }
            };

            await actualContext.CargoGroup.AddRangeAsync(CargoGroups);

            actualContext.SaveChanges();
            MSD1 Msd1 = new MSD1();

            tempData["MSD1Key"] = JsonConvert.SerializeObject(Msd1);

            var model = new CargoDetailsModel(actualContext, cargoPortValidateService)
            {
                PageContext = pageContext,
                TempData    = tempData,
                Url         = new UrlHelper(actionContext)
            };

            var result = await model.OnGetAsync();

            Assert.IsInstanceOfType(result, typeof(PageResult));
        }
Exemple #2
0
        public async Task OnGetUiFormat_GoodData_ExpectNoCargo()
        {
            byte       testGroupCode    = 101;
            byte       testGroupCode2   = 102;
            var        testDescription  = "TEST_DESCRIPTION";
            var        testDescription2 = "TEST_DESCRIPTION2";
            string     CargoGroupKey    = "CargoGroupKey";
            string     CargoCategoryKey = "CargoCategoryKey";
            string     expectedResult   = "NoCargo";
            CargoGroup CargoGroup       = new CargoGroup()

            {
                Description = testDescription, IsUnitised = true, GroupCode = testGroupCode, CargoCategory = new List <CargoCategory>()
            };

            var CargoCategories = new List <CargoCategory>()
            {
                new CargoCategory {
                    GroupCode = testGroupCode, CategoryCode = 25, Description = testDescription
                },
                new CargoCategory {
                    GroupCode = testGroupCode2, CategoryCode = 26, Description = testDescription2
                }
            };

            await actualContext.CargoGroup.AddRangeAsync(CargoGroup);

            await actualContext.CargoCategory.AddRangeAsync(CargoCategories);

            actualContext.SaveChanges();

            tempData.Put(CargoGroupKey, CargoGroup);
            tempData.Put(CargoCategoryKey, CargoCategories);

            var model = new CargoDetailsModel(actualContext, cargoPortValidateService)
            {
                PageContext = pageContext,
                TempData    = tempData,
                Url         = new UrlHelper(actionContext)
            };

            var result = model.OnGetUiFormat(testDescription);

            Assert.AreEqual(result.Value, expectedResult);
            Assert.IsInstanceOfType(result, typeof(JsonResult));
        }
Exemple #3
0
        public async Task OnGetCargoCategories_GoodData()
        {
            byte testGroupCode    = 45;
            byte testGroupCode2   = 46;
            var  testDescription  = "TEST_DESCRIPTION";
            var  testDescription2 = "TEST_DESCRIPTION2";

            var CargoGroups = new List <CargoGroup>()
            {
                new CargoGroup {
                    Description = testDescription, GroupCode = testGroupCode, CargoCategory = new List <CargoCategory>()
                },
                new CargoGroup {
                    Description = testDescription2, GroupCode = testGroupCode2, CargoCategory = new List <CargoCategory>()
                }
            };

            var CargoCategories = new List <CargoCategory>()
            {
                new CargoCategory {
                    GroupCode = testGroupCode, CategoryCode = 123
                },
                new CargoCategory {
                    GroupCode = testGroupCode2, CategoryCode = 124
                }
            };

            await actualContext.CargoGroup.AddRangeAsync(CargoGroups);

            await actualContext.CargoCategory.AddRangeAsync(CargoCategories);

            actualContext.SaveChanges();

            var model = new CargoDetailsModel(actualContext, cargoPortValidateService)
            {
                PageContext = pageContext,
                TempData    = tempData,
                Url         = new UrlHelper(actionContext)
            };

            var result = model.OnGetCargoCategories(testDescription);

            Assert.IsInstanceOfType(result, typeof(JsonResult));
        }