Beispiel #1
0
        public void Index_get_correct_assignedHobbie_list()
        {
            //Arrange
            IEnumerable <AssignedHobbie> assignedHobbie = new List <AssignedHobbie>
            {
                new AssignedHobbie(),
                new AssignedHobbie(),
                new AssignedHobbie()
            };

            _queryBuilder
            .For <Task <IEnumerable <AssignedHobbie> > >()
            .With(Arg.Is <GetAssignedHobbiesCriterion>(p => p.EntrantId == EntrantId))
            .Returns(Task.FromResult(assignedHobbie));

            //Act
            var controller = new HobbieController(_queryBuilder, _commandBuilder, _infoExtractor);

            controller.ControllerContext =
                new ControllerContext(_requestContext, controller);
            var task = controller.Index();

            task.Wait();
            var result = (ViewResult)task.Result;

            //Assert
            Assert.AreEqual(assignedHobbie, result.Model);
        }
Beispiel #2
0
        public void Index_post_assignedHobbieList_sucsess_and_redirect_to_index()
        {
            var selectedHobbies = new string[10];

            _commandBuilder
            .ExecuteAsync(new UpdateEntrantHobbieContext {
                EntrantId = EntrantId, SelectedHobbies = selectedHobbies
            })
            .Returns(Task.Delay(1));

            //Act
            var controller = new HobbieController(_queryBuilder, _commandBuilder, _infoExtractor);

            controller.ControllerContext =
                new ControllerContext(_requestContext, controller);
            var task = controller.Index(selectedHobbies);

            task.Wait();
            var result = ((RedirectToRouteResult)task.Result).RouteValues.Single();

            //Assert

            Assert.IsTrue(result.Key == "action" && (string)result.Value == "Index");
        }