public void OnPost_WhenModelStateIsValid_ReturnsARedirectToPageResult()
        {
            input = new InputModel()
            {
                ReportingPort   = "Newport, Isle of Wight / UNITED KINGDOM (GBNPO)",
                IsInbound       = true,
                AssociatedPort  = "Newcastle-Upon-Tyne / UNITED KINGDOM (GBNCL)",
                NumVoyages      = "4",
                Year            = "2018",
                Quarter         = "1",
                RecordRef       = "qewtweieorpr",
                VoyageDateDay   = 1,
                VoyageDateMonth = 1,
                VoyageDateYear  = 2019
            };

            var model = new VoyageDetailsModel(actualContext, CommonFunction)
            {
                PageContext = pageContext,
                TempData    = tempData,
                Url         = new UrlHelper(actionContext),
                Input       = input
            };

            var result = model.OnPost("Newcastle-Upon-Tyne / UNITED KINGDOM (GBNCL)", "Newport, Isle of Wight / UNITED KINGDOM (GBNPO)");

            Assert.IsInstanceOfType(result, typeof(RedirectToPageResult));
        }
        public void OnPost_WhenModelStateIsInValid_ReturnsPageResult()
        {
            var model = new VoyageDetailsModel(actualContext, CommonFunction)
            {
                PageContext = pageContext,
                TempData    = tempData,
                Url         = new UrlHelper(actionContext),
                Input       = input
            };

            model.ModelState.AddModelError("Input.ReportingPort", "Enter a valid Reporting port");
            model.ModelState.AddModelError("Input.IsInbound", "Select a direction of travel");
            model.ModelState.AddModelError("Input.Year", "Select a year");

            var result = model.OnPost("Newcastle-Upon-Tyne / UNITED KINGDOM (GBNCL)", "Newport, Isle of Wight / UNITED KINGDOM (GBNPO)");

            Assert.IsTrue(viewData.ModelState.ContainsKey("Input.ReportingPort"));
            Assert.IsTrue(viewData.ModelState.ContainsKey("Input.IsInbound"));
            Assert.IsTrue(viewData.ModelState.ContainsKey("Input.Year"));
            Assert.IsTrue(viewData.ModelState.ErrorCount == 3);
            Assert.IsInstanceOfType(result, typeof(PageResult));
        }