Exemplo n.º 1
0
        public async Task DetailsReturnsCorrectStep()
        {
            TestTrekStoriesContext tc         = new TestTrekStoriesContext();
            StepController         controller = new StepController(tc).WithAuthenticatedUser("UserA");
            Step step = new Step()
            {
                StepId          = 123,
                SequenceNo      = 2,
                From            = "B",
                To              = "C",
                WalkingDistance = 0,
                WalkingTime     = 3.5
            };

            step.Trip = new Trip {
                TripId = 1, Steps = new List <Step>()
                {
                    step
                }, TripOwner = "UserB"
            };
            tc.Steps.Add(step);

            ViewResult result = await controller.Details(123) as ViewResult;

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

            Assert.AreEqual(2, step123.SequenceNo);
            Assert.AreEqual("B", step123.From);
            Assert.AreEqual(1, controller.ViewBag.Steps.Length);
            Assert.AreEqual(123, controller.ViewBag.Steps[0]);
        }