Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        public void SingleWriteBadReadReturnsNull()
        {
            var  MSD1      = new MSD1();
            uint vesselImo = 1234;

            MSD1.Imo = vesselImo;

            var httpContext = new DefaultHttpContext();
            var tempData    = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            tempData.Put("testKey", MSD1);

            var MSD1_out = tempData.Get <MSD1>("testkey_junk");

            Assert.IsNull(MSD1_out);
        }
Ejemplo n.º 3
0
        public void SingleWriteReadReturnsCorrectValue()
        {
            var  MSD1      = new MSD1();
            uint vesselImo = 1234;

            MSD1.Imo = vesselImo;

            var httpContext = new DefaultHttpContext();
            var tempData    = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            tempData.Put("testKey", MSD1);

            var MSD1_out = tempData.Get <MSD1>("testkey");

            Assert.AreEqual(vesselImo, MSD1_out.Imo);
        }
Ejemplo n.º 4
0
        public async Task WriteReadTypesWithCircularDependency()
        {
            byte testGroupCode  = 99;
            byte testGroupCode2 = 100;


            var CargoCategories = new List <CargoCategory>()
            {
                new CargoCategory {
                    GroupCode           = testGroupCode,
                    CategoryCode        = 23,
                    GroupCodeNavigation = new CargoGroup()
                    {
                        CargoCategory = new List <CargoCategory>(), GroupCode = testGroupCode
                    }
                },

                new CargoCategory {
                    GroupCode           = testGroupCode2,
                    CategoryCode        = 24,
                    GroupCodeNavigation = new CargoGroup()
                    {
                        CargoCategory = new List <CargoCategory>(), GroupCode = testGroupCode2
                    }
                }
            };

            await actualContext.CargoCategory.AddRangeAsync(CargoCategories);

            actualContext.SaveChanges();

            var cargoCategory = actualContext.CargoCategory.Where(x => x.GroupCode == testGroupCode);

            var httpContext = new DefaultHttpContext();
            var tempData    = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            tempData.Put("testKey", cargoCategory);

            var CargoOut = tempData.Get <List <CargoCategory> >("testkey");

            Assert.IsTrue(cargoCategory.Count() == 1);
        }