public void WillNotIncludeThePackageWhenItDependsOnAPackageThatIsExcludedInTheFeed()
            {
                var stubFeed          = new CuratedFeed();
                var dependencyPackage = new CuratedPackage
                {
                    AutomaticallyCurated = false,
                    Included             = false,
                    PackageRegistration  = new PackageRegistration {
                        Id = "ManuallyExcludedPackage"
                    }
                };

                stubFeed.Packages.Add(dependencyPackage);
                var stubNuGetPackage   = CreateStubNuGetPackage().Object;
                var stubGalleryPackage = CreateStubGalleryPackage();

                stubGalleryPackage.Dependencies.Add(
                    new PackageDependency {
                    Id = "ManuallyExcludedPackage"
                });

                bool result = WebMatrixPackageCurator.ShouldCuratePackage(
                    stubFeed,
                    stubGalleryPackage,
                    stubNuGetPackage);

                Assert.False(result);
            }
            public TestableCuratedFeedService()
            {
                StubCuratedFeed = new CuratedFeed { Key = 0, Name = "aName" };
                StubPackageRegistration = new PackageRegistration { Key = 1066, Id = "aPackageId" };

                StubCuratedPackage = new CuratedPackage
                {
                    Key = 0,
                    CuratedFeedKey = StubCuratedFeed.Key,
                    CuratedFeed = StubCuratedFeed,
                    PackageRegistration = StubPackageRegistration,
                    PackageRegistrationKey = StubPackageRegistration.Key
                };
                StubCuratedFeed.Packages.Add(StubCuratedPackage);

                StubCuratedFeedRepository = new Mock<IEntityRepository<CuratedFeed>>();
                StubCuratedFeedRepository
                    .Setup(repo => repo.GetAll())
                    .Returns(new CuratedFeed[] { StubCuratedFeed }.AsQueryable());

                StubCuratedPackageRepository = new Mock<IEntityRepository<CuratedPackage>>();
                StubCuratedPackageRepository
                    .Setup(repo => repo.GetAll())
                    .Returns(new CuratedPackage[] { StubCuratedPackage }.AsQueryable());
            }
예제 #3
0
            public TestableCuratedFeedService()
                : base()
            {
                StubCuratedFeed = new CuratedFeed {
                    Key = 0, Name = "aName"
                };
                StubPackageRegistration = new PackageRegistration {
                    Key = 1066, Id = "aPackageId"
                };

                StubCuratedPackage = new CuratedPackage
                {
                    Key                    = 0,
                    CuratedFeedKey         = StubCuratedFeed.Key,
                    CuratedFeed            = StubCuratedFeed,
                    PackageRegistration    = StubPackageRegistration,
                    PackageRegistrationKey = StubPackageRegistration.Key
                };
                StubCuratedFeed.Packages.Add(StubCuratedPackage);

                StubCuratedFeedRepository = new Mock <IEntityRepository <CuratedFeed> >();
                StubCuratedFeedRepository
                .Setup(repo => repo.GetAll())
                .Returns(new CuratedFeed[] { StubCuratedFeed }.AsQueryable());

                StubCuratedPackageRepository = new Mock <IEntityRepository <CuratedPackage> >();
                StubCuratedPackageRepository
                .Setup(repo => repo.GetAll())
                .Returns(new CuratedPackage[] { StubCuratedPackage }.AsQueryable());
            }
            public TestableCuratedFeedService()
            {
                StubCuratedFeed = new CuratedFeed { Key = 0, Name = "aName" };
                StubCuratedFeed2 = new CuratedFeed {Key = 1, Name = "AnotherFeed"};
                StubPackageRegistration_ForFeed1 = new PackageRegistration { Key = 1066, Id = "aPackageId" };
                StubPackageRegistration_ForFeed2 = new PackageRegistration { Key = 1067, Id = "aPackageId2" };
                StubPackageRegistration_ForFeed1_NotIncluded = new PackageRegistration { Key = 1068, Id = "aPackageId2" };
                StubPackage = new Package { PackageRegistration = StubPackageRegistration_ForFeed1, PackageRegistrationKey = StubPackageRegistration_ForFeed1.Key, Version = "1.0.0" };
                StubPackage_IncompatibleVersion = new Package { PackageRegistration = StubPackageRegistration_ForFeed1, PackageRegistrationKey = StubPackageRegistration_ForFeed1.Key, Version = "2.0.0" };
                StubPackage_ForFeed1_NotIncluded = new Package { PackageRegistration = StubPackageRegistration_ForFeed1_NotIncluded, PackageRegistrationKey = StubPackageRegistration_ForFeed1_NotIncluded.Key };

                StubCuratedPackageRegistration_ForFeed1 = new CuratedPackage
                {
                    Key = 1, 
                    CuratedFeedKey = StubCuratedFeed.Key, 
                    CuratedFeed = StubCuratedFeed, 
                    PackageRegistration = StubPackageRegistration_ForFeed1,
                    PackageRegistrationKey = StubPackageRegistration_ForFeed1.Key,
                    Included = true
                };
                StubCuratedFeed.Packages.Add(StubCuratedPackageRegistration_ForFeed1);

                StubCuratedPackageRegistration_ForFeed2 = new CuratedPackage
                {
                    Key = 2,
                    CuratedFeedKey = StubCuratedFeed2.Key,
                    CuratedFeed = StubCuratedFeed2,
                    PackageRegistration = StubPackageRegistration_ForFeed2,
                    PackageRegistrationKey = StubPackageRegistration_ForFeed2.Key,
                    Included = true
                };
                StubCuratedFeed2.Packages.Add(StubCuratedPackageRegistration_ForFeed2);

                StubCuratedPackageRegistration_ForFeed1_NotIncluded = new CuratedPackage
                {
                    Key = 3,
                    CuratedFeedKey = StubCuratedFeed.Key,
                    CuratedFeed = StubCuratedFeed,
                    PackageRegistration = StubPackageRegistration_ForFeed1_NotIncluded,
                    PackageRegistrationKey = StubPackageRegistration_ForFeed1_NotIncluded.Key,
                    Included = false
                };
                StubCuratedFeed.Packages.Add(StubCuratedPackageRegistration_ForFeed1_NotIncluded);

                StubCuratedFeedRepository = new Mock<IEntityRepository<CuratedFeed>>();
                StubCuratedFeedRepository
                    .Setup(repo => repo.GetAll())
                    .Returns(new CuratedFeed[] { StubCuratedFeed, StubCuratedFeed2 }.AsQueryable());

                StubCuratedPackageRepository = new Mock<IEntityRepository<CuratedPackage>>();
                StubCuratedPackageRepository
                    .Setup(repo => repo.GetAll())
                    .Returns(new CuratedPackage[] { StubCuratedPackageRegistration_ForFeed1, StubCuratedPackageRegistration_ForFeed2, StubCuratedPackageRegistration_ForFeed1_NotIncluded }.AsQueryable());
            }
예제 #5
0
            public void WillDeleteTheCuratedPackage()
            {
                var cmd = new TestableDeleteCuratedPackageCommand();
                var stubCuratedPackage = new CuratedPackage {
                    Key = 1066
                };

                cmd.StubCuratedFeed.Packages = new[] { stubCuratedPackage };

                cmd.Execute(
                    0,
                    1066);

                cmd.StubCuratedPackageDbSet.Verify(stub => stub.Remove(stubCuratedPackage));
                cmd.StubEntitiesContext.Verify(stub => stub.SaveChanges());
            }
            public void WillModifyAndSaveTheCuratedPackage()
            {
                var cmd = new TestableModifyCuratedPackageCommand();
                var stubCuratedPackage = new CuratedPackage {
                    Key = 1066
                };

                cmd.StubCuratedFeed.Packages = new[] { stubCuratedPackage };

                cmd.Execute(
                    0,
                    1066,
                    true);

                Assert.True(stubCuratedPackage.Included);
                cmd.StubEntitiesContext.Verify(stub => stub.SaveChanges());
            }
            public async Task WillNotIncludeThePackageWhenItDependsOnAPackageThatIsExcludedInTheFeed()
            {
                var stubFeed          = new CuratedFeed();
                var dependencyPackage = new CuratedPackage
                {
                    AutomaticallyCurated = false,
                    Included             = false,
                    PackageRegistration  = new PackageRegistration {
                        Id = "ManuallyExcludedPackage"
                    }
                };

                stubFeed.Packages.Add(dependencyPackage);
                var stubNuGetPackage   = CreateStubNuGetPackageReader();
                var stubGalleryPackage = CreateStubGalleryPackage();

                stubGalleryPackage.Dependencies.Add(
                    new PackageDependency {
                    Id = "ManuallyExcludedPackage"
                });

                var curator = TestableWebMatrixPackageCurator.Create(stubCuratedFeedService =>
                {
                    stubCuratedFeedService.Setup(stub => stub.GetFeedByName(It.IsAny <string>(), It.IsAny <bool>())).Returns(stubFeed);
                });

                await curator.CurateAsync(stubGalleryPackage, stubNuGetPackage.Object, commitChanges : true);

                curator.StubCuratedFeedService.Verify(
                    stub => stub.CreatedCuratedPackageAsync(
                        It.IsAny <CuratedFeed>(),
                        It.IsAny <PackageRegistration>(),
                        It.IsAny <bool>(),
                        It.IsAny <bool>(),
                        It.IsAny <string>(),
                        It.IsAny <bool>()),
                    Times.Never());
            }
            public void WillNotIncludeThePackageWhenItDependsOnAPackageThatIsExcludedInTheFeed()
            {
                var stubFeed = new CuratedFeed();
                var dependencyPackage = new CuratedPackage
                {
                    AutomaticallyCurated = false, 
                    Included = false, 
                    PackageRegistration = new PackageRegistration { Id = "ManuallyExcludedPackage" }
                };
                stubFeed.Packages.Add(dependencyPackage);
                var stubNuGetPackage = CreateStubNuGetPackage().Object;
                var stubGalleryPackage = CreateStubGalleryPackage();
                stubGalleryPackage.Dependencies.Add(
                    new PackageDependency { Id = "ManuallyExcludedPackage" });

                bool result = WebMatrixPackageCurator.ShouldCuratePackage(
                    stubFeed,
                    stubGalleryPackage,
                    stubNuGetPackage);

                Assert.False(result);
            }
예제 #9
0
            public TestableCuratedFeedService()
            {
                StubCuratedFeed = new CuratedFeed {
                    Key = 0, Name = "aName"
                };
                StubCuratedFeed2 = new CuratedFeed {
                    Key = 1, Name = "AnotherFeed"
                };
                StubPackageRegistration_ForFeed1 = new PackageRegistration {
                    Key = 1066, Id = "aPackageId"
                };
                StubPackageRegistration_ForFeed2 = new PackageRegistration {
                    Key = 1067, Id = "aPackageId2"
                };
                StubPackageRegistration_ForFeed1_NotIncluded = new PackageRegistration {
                    Key = 1068, Id = "aPackageId2"
                };
                StubPackage = new Package {
                    PackageRegistration = StubPackageRegistration_ForFeed1, PackageRegistrationKey = StubPackageRegistration_ForFeed1.Key, Version = "1.0.0"
                };
                StubPackage_IncompatibleVersion = new Package {
                    PackageRegistration = StubPackageRegistration_ForFeed1, PackageRegistrationKey = StubPackageRegistration_ForFeed1.Key, Version = "2.0.0"
                };
                StubPackage_ForFeed1_NotIncluded = new Package {
                    PackageRegistration = StubPackageRegistration_ForFeed1_NotIncluded, PackageRegistrationKey = StubPackageRegistration_ForFeed1_NotIncluded.Key
                };

                StubCuratedPackageRegistration_ForFeed1 = new CuratedPackage
                {
                    Key                    = 1,
                    CuratedFeedKey         = StubCuratedFeed.Key,
                    CuratedFeed            = StubCuratedFeed,
                    PackageRegistration    = StubPackageRegistration_ForFeed1,
                    PackageRegistrationKey = StubPackageRegistration_ForFeed1.Key,
                    Included               = true
                };
                StubCuratedFeed.Packages.Add(StubCuratedPackageRegistration_ForFeed1);

                StubCuratedPackageRegistration_ForFeed2 = new CuratedPackage
                {
                    Key                    = 2,
                    CuratedFeedKey         = StubCuratedFeed2.Key,
                    CuratedFeed            = StubCuratedFeed2,
                    PackageRegistration    = StubPackageRegistration_ForFeed2,
                    PackageRegistrationKey = StubPackageRegistration_ForFeed2.Key,
                    Included               = true
                };
                StubCuratedFeed2.Packages.Add(StubCuratedPackageRegistration_ForFeed2);

                StubCuratedPackageRegistration_ForFeed1_NotIncluded = new CuratedPackage
                {
                    Key                    = 3,
                    CuratedFeedKey         = StubCuratedFeed.Key,
                    CuratedFeed            = StubCuratedFeed,
                    PackageRegistration    = StubPackageRegistration_ForFeed1_NotIncluded,
                    PackageRegistrationKey = StubPackageRegistration_ForFeed1_NotIncluded.Key,
                    Included               = false
                };
                StubCuratedFeed.Packages.Add(StubCuratedPackageRegistration_ForFeed1_NotIncluded);

                StubCuratedFeedRepository = new Mock <IEntityRepository <CuratedFeed> >();
                StubCuratedFeedRepository
                .Setup(repo => repo.GetAll())
                .Returns(new CuratedFeed[] { StubCuratedFeed, StubCuratedFeed2 }.AsQueryable());

                StubCuratedPackageRepository = new Mock <IEntityRepository <CuratedPackage> >();
                StubCuratedPackageRepository
                .Setup(repo => repo.GetAll())
                .Returns(new CuratedPackage[] { StubCuratedPackageRegistration_ForFeed1, StubCuratedPackageRegistration_ForFeed2, StubCuratedPackageRegistration_ForFeed1_NotIncluded }.AsQueryable());
            }