public void WillModifyTheCuratedPackageWhenRequestIsValid() { var controller = new TestableCuratedPackagesController(); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, Included = true, }); Assert.False(controller.StubCuratedFeed.Packages.Any( cp => cp.Included == false)); var result = controller.PatchCuratedPackage( "aFeedName", "anId", new ModifyCuratedPackageRequest { Included = false }) as HttpStatusCodeResult; Assert.True(controller.StubCuratedFeed.Packages.Any( cp => cp.Included == false)); }
public void WillModifyTheCuratedPackageWhenRequestIsValid() { var controller = new TestableCuratedPackagesController(); controller.StubCuratedFeed.Key = 42; controller.StubCuratedFeed.Packages = new[] { new CuratedPackage { Key = 1066, PackageRegistration = new PackageRegistration { Id = "theCuratedPackageId" } } }; controller.PatchCuratedPackage("theCuratedFeedName", "theCuratedPackageId", new ModifyCuratedPackageRequest { Included = true }); controller.StubModifyCuratedPackageCmd.Verify( stub => stub.Execute( 42, 1066, true)); }
public void WillReturn404IfTheCuratedPackageDoesNotExist() { var controller = new TestableCuratedPackagesController(); var result = controller.PatchCuratedPackage("aFeedName", "aWrongId", new ModifyCuratedPackageRequest()); Assert.IsType <HttpNotFoundResult>(result); }
public void WillReturn204AfterModifyingTheCuratedPackage() { var controller = new TestableCuratedPackagesController(); var result = controller.PatchCuratedPackage("aCuratedFeedName", "aCuratedPackageId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(204, result.StatusCode); }
public void WillReturn404IfTheCuratedFeedDoesNotExist() { var controller = new TestableCuratedPackagesController(); controller.StubCuratedFeedByNameQry.Setup(stub => stub.Execute(It.IsAny <string>(), It.IsAny <bool>())).Returns((CuratedFeed)null); var result = controller.PatchCuratedPackage("aCuratedFeedName", "aCuratedPackageId", new ModifyCuratedPackageRequest()); Assert.IsType <HttpNotFoundResult>(result); }
public async Task WillReturn404IfTheCuratedPackageDoesNotExist() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(controller.Fakes.User); var result = await controller.PatchCuratedPackage("aFeedName", "aWrongId", new ModifyCuratedPackageRequest()); Assert.IsType <HttpNotFoundResult>(result); }
public void WillReturn400IfTheModelStateIsInvalid() { var controller = new TestableCuratedPackagesController(); controller.ModelState.AddModelError("", "anError"); var result = controller.PatchCuratedPackage("aCuratedFeedName", "aCuratedPackageId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(400, result.StatusCode); }
public void WillReturn404IfTheCuratedPackageDoesNotExist() { var controller = new TestableCuratedPackagesController(); controller.StubCuratedFeed.Packages = new[] { new CuratedPackage { PackageRegistration = new PackageRegistration() } }; var result = controller.PatchCuratedPackage("aCuratedFeedName", "aCuratedPackageId", new ModifyCuratedPackageRequest()); Assert.IsType <HttpNotFoundResult>(result); }
public void WillReturn403IfTheCuratedPackageDoesNotExist() { var controller = new TestableCuratedPackagesController(); controller.StubCuratedFeed.Managers = new[] { new User { Username = "******" } }; var result = controller.PatchCuratedPackage("aCuratedFeedName", "aCuratedPackageId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(403, result.StatusCode); }
public async Task WillReturn403IfNotAFeedManager() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(controller.Fakes.Owner); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, }); var result = await controller.PatchCuratedPackage("aFeedName", "anId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(403, result.StatusCode); }
public void WillReturn204AfterModifyingTheCuratedPackage() { var controller = new TestableCuratedPackagesController(); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, Included = true, }); var result = controller.PatchCuratedPackage("aFeedName", "anId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(204, result.StatusCode); }
public void WillReturn400IfTheModelStateIsInvalid() { var controller = new TestableCuratedPackagesController(); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, }); controller.ModelState.AddModelError("", "anError"); var result = controller.PatchCuratedPackage( "aFeedName", "anId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(400, result.StatusCode); }
public void WillReturn403IfNotAFeedManager() { var controller = new TestableCuratedPackagesController(); controller.StubIdentity .Setup(i => i.Name) .Returns("notAManager"); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, }); var result = controller.PatchCuratedPackage("aFeedName", "anId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(403, result.StatusCode); }
public async Task WillModifyTheCuratedPackageWhenRequestIsValid() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(controller.Fakes.User); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, Included = true, }); Assert.DoesNotContain(controller.StubCuratedFeed.Packages, cp => !cp.Included); var result = await controller.PatchCuratedPackage( "aFeedName", "anId", new ModifyCuratedPackageRequest { Included = false }) as HttpStatusCodeResult; Assert.Contains(controller.StubCuratedFeed.Packages, cp => !cp.Included); }
public async Task WillReturn204AfterModifyingTheCuratedPackage() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(controller.Fakes.User); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, Included = true, }); var result = await controller.PatchCuratedPackage("aFeedName", "anId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(204, result.StatusCode); }
public async Task WillModifyTheCuratedPackageWhenRequestIsValid() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(controller.Fakes.User); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, Included = true, }); Assert.False(controller.StubCuratedFeed.Packages.Any( cp => cp.Included == false)); var result = await controller.PatchCuratedPackage( "aFeedName", "anId", new ModifyCuratedPackageRequest { Included = false }) as HttpStatusCodeResult; Assert.True(controller.StubCuratedFeed.Packages.Any( cp => cp.Included == false)); }
public async Task WillReturn400IfTheModelStateIsInvalid() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(controller.Fakes.User); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, }); controller.ModelState.AddModelError("", "anError"); var result = await controller.PatchCuratedPackage( "aFeedName", "anId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(400, result.StatusCode); }
public async Task WillReturn404IfTheCuratedPackageDoesNotExist() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(controller.Fakes.User); var result = await controller.PatchCuratedPackage("aFeedName", "aWrongId", new ModifyCuratedPackageRequest()); Assert.IsType<HttpNotFoundResult>(result); }
public async Task WillReturn403IfNotAFeedManager() { var controller = new TestableCuratedPackagesController(); controller.SetCurrentUser(Fakes.Owner); controller.StubCuratedFeed.Packages.Add( new CuratedPackage { CuratedFeed = controller.StubCuratedFeed, CuratedFeedKey = controller.StubCuratedFeed.Key, PackageRegistration = controller.StubPackageRegistration, PackageRegistrationKey = controller.StubPackageRegistration.Key, }); var result = await controller.PatchCuratedPackage("aFeedName", "anId", new ModifyCuratedPackageRequest()) as HttpStatusCodeResult; Assert.NotNull(result); Assert.Equal(403, result.StatusCode); }
public void WillReturn404IfTheCuratedPackageDoesNotExist() { var controller = new TestableCuratedPackagesController(); var result = controller.PatchCuratedPackage("aFeedName", "aWrongId", new ModifyCuratedPackageRequest()); Assert.IsType<HttpNotFoundResult>(result); }