Exemple #1
0
        public async Task CannotDeleteStepWithAccommodation()
        {
            TestTrekStoriesContext tc = new TestTrekStoriesContext();
            Step stepA = new Step {
                StepId        = 11,
                SequenceNo    = 1,
                TripId        = 2,
                Accommodation = new Accommodation {
                    AccommodationId = 1, Name = "Hotel Zuki"
                },
                Trip = new Trip {
                    TripOwner = "ABC123"
                }
            };

            tc.Steps.Add(stepA);

            var controller = new StepController(tc).WithAuthenticatedUser("ABC123");
            var result     = await controller.Delete(11) as RedirectToRouteResult;

            Assert.AreEqual("Details", result.RouteValues["action"]);
            Assert.AreEqual("Step", result.RouteValues["controller"]);
            Assert.AreEqual(
                "Step 1 cannot be deleted because it is linked to an accommodation. Please first edit or delete the accommodation for the step.",
                controller.TempData["message"]);
        }
Exemple #2
0
        public async Task DeleteNonExistingStepReturnsNotFound()
        {
            TestTrekStoriesContext tc = new TestTrekStoriesContext();
            var controller            = new StepController(tc);

            var badResult = await controller.Delete(12) as ViewResult;

            Assert.AreEqual("CustomisedError", badResult.ViewName);
        }
Exemple #3
0
        public async Task DeleteReturnsCorrectStep()
        {
            TestTrekStoriesContext tc = new TestTrekStoriesContext();
            Step step = new Step {
                StepId = 10, SequenceNo = 3, Trip = new Trip {
                    TripOwner = "ABC123"
                }
            };

            tc.Steps.Add(step);
            var controller = new StepController(tc).WithAuthenticatedUser("ABC123");

            var result = await controller.Delete(10) as ViewResult;

            var resultStep = (Step)result.ViewData.Model;

            Assert.AreEqual(10, resultStep.StepId);
            Assert.AreEqual(3, resultStep.SequenceNo);
        }