public void WillPassTheIncludedPackagesToTheView() { var controller = new TestableCuratedFeedsController(); controller.StubCuratedFeed.Packages = new HashSet <CuratedPackage>(new[] { new CuratedPackage { AutomaticallyCurated = true, Included = true, PackageRegistration = new PackageRegistration { Id = "theAutomaticallyCuratedId" } }, new CuratedPackage { AutomaticallyCurated = false, Included = true, PackageRegistration = new PackageRegistration { Id = "theManuallyCuratedId" } }, new CuratedPackage { AutomaticallyCurated = true, Included = false, PackageRegistration = new PackageRegistration { Id = "theExcludedId" } }, }); var viewModel = (controller.CuratedFeed("aFeedName") as ViewResult).Model as CuratedFeedViewModel; Assert.NotNull(viewModel); Assert.Equal(2, viewModel.IncludedPackages.Count()); Assert.Equal("theAutomaticallyCuratedId", viewModel.IncludedPackages.ElementAt(0).Id); Assert.Equal("theManuallyCuratedId", viewModel.IncludedPackages.ElementAt(1).Id); }
public void WillPassTheCuratedFeedManagersToTheView() { var controller = new TestableCuratedFeedsController(); var viewModel = (controller.CuratedFeed("aName") as ViewResult).Model as CuratedFeedViewModel; Assert.NotNull(viewModel); Assert.Equal(controller.Fakes.User, viewModel.Managers.First()); }
public void WillPassTheCuratedFeedNameToTheView() { var controller = new TestableCuratedFeedsController(); var viewModel = (controller.CuratedFeed("aName") as ViewResult).Model as CuratedFeedViewModel; Assert.NotNull(viewModel); Assert.Equal("aName", viewModel.Name); }
public void WillReturn404IfTheCuratedFeedDoesNotExist() { var controller = new TestableCuratedFeedsController(); controller.StubCuratedFeedService.Setup(stub => stub.GetFeedByName(It.IsAny <string>(), It.IsAny <bool>())).Returns((CuratedFeed)null); var result = controller.CuratedFeed("aName"); Assert.IsType <HttpNotFoundResult>(result); }
public void WillReturn403IfTheCurrentUsersIsNotAManagerOfTheCuratedFeed() { var controller = new TestableCuratedFeedsController(); controller.SetCurrentUser(controller.Fakes.Owner); var result = controller.CuratedFeed("aName") as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(403, result.StatusCode); }
public void WillReturn403IfTheCurrentUsersIsNotAManagerOfTheCuratedFeed() { var controller = new TestableCuratedFeedsController(); controller.StubIdentity.Setup(stub => stub.Name).Returns("notAManager"); var result = controller.CuratedFeed("aFeedName") as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(403, result.StatusCode); }
public void WillPassTheCuratedFeedManagersToTheView() { var controller = new TestableCuratedFeedsController(); controller.StubIdentity.Setup(stub => stub.Name).Returns("theManager"); controller.StubCuratedFeed.Managers = new HashSet <User>(new[] { new User { Username = "******" } }); var viewModel = (controller.CuratedFeed("aFeedName") as ViewResult).Model as CuratedFeedViewModel; Assert.NotNull(viewModel); Assert.Equal("theManager", viewModel.Managers.First()); }