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"); }
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"); }
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"); }); }
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"); }