Ejemplo n.º 1
0
            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));
            }
Ejemplo n.º 2
0
            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));
            }
Ejemplo n.º 3
0
            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);
            }
Ejemplo n.º 5
0
            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);
            }
Ejemplo n.º 8
0
            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);
            }
Ejemplo n.º 11
0
            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);
            }
Ejemplo n.º 12
0
            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);
            }
Ejemplo n.º 13
0
            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);
            }
Ejemplo n.º 14
0
            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);
            }
            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);
            }