コード例 #1
0
        public void NeedDetailsShoudWorkCorrectlyWithCorrenctIdParameter()
        {
            var usersService = new Mock<IUsersService>();
            var needsService = new Mock<INeedService>();
            var dropDownPopulator = new Mock<IDropDownListPopulator>();

            needsService.Setup(x => x.GetAll())
                .Returns(new List<Need>() { new Need() { Id = 1 } }.AsQueryable());

            var controller = new NeedController(usersService.Object, needsService.Object, dropDownPopulator.Object);
            controller.WithCallTo(x => x.Details(1))
                .ShouldRenderView("Details");
        }
コード例 #2
0
        public void ActionAllShoudWorkCorrectlyWithoutParameters()
        {
            var usersService = new Mock<IUsersService>();
            var needsService = new Mock<INeedService>();
            var dropDownPopulator = new Mock<IDropDownListPopulator>();

            needsService.Setup(x => x.GetAll())
                .Returns(new List<Need>().AsQueryable());

            var controller = new NeedController(usersService.Object, needsService.Object, dropDownPopulator.Object);
            controller.WithCallTo(x => x.All(1))
                .ShouldRenderView("All");
        }
コード例 #3
0
        public void NeedDetailsShoudMapViewModelCorrectly()
        {
            var usersService = new Mock<IUsersService>();
            var needsService = new Mock<INeedService>();
            var dropDownPopulator = new Mock<IDropDownListPopulator>();

            needsService.Setup(x => x.GetAll())
                .Returns(new List<Need>() { new Need() { Id = 1, Description = "Some description"} }.AsQueryable());

            var controller = new NeedController(usersService.Object, needsService.Object, dropDownPopulator.Object);
            controller.WithCallTo(x => x.Details(1))
                .ShouldRenderView("Details")
                .WithModel<NeedViewModel>(viewModel =>
                {
                    Assert.AreEqual(viewModel.Description, "Some description");
                });
        }
コード例 #4
0
        public void DetailShoudThrowHttpExceptionWhenIdIsNull()
        {
            var usersService = new Mock<IUsersService>();
            var needsService = new Mock<INeedService>();
            var dropDownPopulator = new Mock<IDropDownListPopulator>();

            needsService.Setup(x => x.GetAll())
                .Returns(new List<Need>().AsQueryable());

            var controller = new NeedController(usersService.Object, needsService.Object, dropDownPopulator.Object);
            controller.WithCallTo(x => x.Details(null))
                .ShouldRenderView("Details");
        }