当前位置: 首页>>代码示例>>C#>>正文


C# NuGetGallery.PackageRegistration类代码示例

本文整理汇总了C#中NuGetGallery.PackageRegistration的典型用法代码示例。如果您正苦于以下问题:C# PackageRegistration类的具体用法?C# PackageRegistration怎么用?C# PackageRegistration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PackageRegistration类属于NuGetGallery命名空间,在下文中一共展示了PackageRegistration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePackageWillSavePackageFileToFileStorage

            public async Task CreatePackageWillSavePackageFileToFileStorage()
            {
                // Arrange
                var user = new User() { EmailAddress = "[email protected]" };
                var packageRegistration = new PackageRegistration();
                packageRegistration.Id = "theId";
                packageRegistration.Owners.Add(user);
                var package = new Package();
                package.PackageRegistration = packageRegistration;
                package.Version = "1.0.42";
                packageRegistration.Packages.Add(package);

                var controller = new TestableApiController();
                controller.SetCurrentUser(user);
                controller.MockPackageFileService.Setup(p => p.SavePackageFileAsync(It.IsAny<Package>(), It.IsAny<Stream>()))
                    .Returns(Task.CompletedTask).Verifiable();
                controller.MockPackageService.Setup(p => p.FindPackageRegistrationById(It.IsAny<string>()))
                    .Returns(packageRegistration);
                controller.MockPackageService.Setup(p => p.CreatePackageAsync(It.IsAny<PackageArchiveReader>(), It.IsAny<PackageStreamMetadata>(), It.IsAny<User>(), false))
                    .Returns(Task.FromResult(package));

                var nuGetPackage = TestPackage.CreateTestPackageStream("theId", "1.0.42");
                controller.SetupPackageFromInputStream(nuGetPackage);

                // Act
                await controller.CreatePackagePut();

                // Assert
                controller.MockPackageFileService.Verify();
            }
开发者ID:goitsk,项目名称:NuGetGallery,代码行数:30,代码来源:ApiControllerFacts.cs

示例2: CreatePackageWillSavePackageFileToFileStorage

            public async Task CreatePackageWillSavePackageFileToFileStorage()
            {
                // Arrange
                var guid = Guid.NewGuid().ToString();

                var fakeUser = new User();
                var userService = new Mock<IUserService>();
                userService.Setup(x => x.FindByApiKey(It.IsAny<Guid>())).Returns(fakeUser);

                var packageRegistration = new PackageRegistration();
                packageRegistration.Owners.Add(fakeUser);

                var packageService = new Mock<IPackageService>();
                packageService.Setup(p => p.FindPackageRegistrationById(It.IsAny<string>())).Returns(packageRegistration);

                var packageFileService = new Mock<IPackageFileService>();
                packageFileService.Setup(p => p.SavePackageFileAsync(It.IsAny<Package>(), It.IsAny<Stream>())).Returns(Task.FromResult(0)).Verifiable();

                var nuGetPackage = new Mock<INupkg>();
                nuGetPackage.Setup(x => x.Metadata.Id).Returns("theId");
                nuGetPackage.Setup(x => x.Metadata.Version).Returns(new SemanticVersion("1.0.42"));

                var controller = CreateController(
                    fileService: packageFileService,
                    userService: userService,
                    packageService: packageService,
                    packageFromInputStream: nuGetPackage);

                // Act
                await controller.CreatePackagePut(guid);

                // Assert
                packageFileService.Verify();
            }
开发者ID:bnicoloff,项目名称:NuGetGallery,代码行数:34,代码来源:ApiControllerFacts.cs

示例3: Execute

        public CuratedPackage Execute(
            CuratedFeed curatedFeed, 
            PackageRegistration packageRegistration, 
            bool included = false, 
            bool automaticallyCurated = false,
            string notes = null,
            bool commitChanges = true)
        {
            if (curatedFeed == null)
            {
                throw new ArgumentNullException("curatedFeed");
            }

            if (packageRegistration == null)
            {
                throw new ArgumentNullException("packageRegistration");
            }

            var curatedPackage = new CuratedPackage
            {
                PackageRegistrationKey = packageRegistration.Key,
                Included = included,
                AutomaticallyCurated = automaticallyCurated,
                Notes = notes,
            };

            curatedFeed.Packages.Add(curatedPackage);

            if (commitChanges)
            {
                Entities.SaveChanges();
            }

            return curatedPackage;
        }
开发者ID:ChrisMissal,项目名称:NuGetGallery,代码行数:35,代码来源:CreateCuratedPackageCommand.cs

示例4: ConfirmPackageOwner

        public bool ConfirmPackageOwner(PackageRegistration package, User pendingOwner, string token)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            if (pendingOwner == null)
            {
                throw new ArgumentNullException("pendingOwner");
            }

            if (String.IsNullOrEmpty(token))
            {
                throw new ArgumentNullException("token");
            }

            if (package.IsOwner(pendingOwner))
            {
                return true;
            }

            var request = FindExistingPackageOwnerRequest(package, pendingOwner);
            if (request != null && request.ConfirmationCode == token)
            {
                AddPackageOwner(package, pendingOwner);
                return true;
            }

            return false;
        }
开发者ID:micahlmartin,项目名称:NuGetGallery,代码行数:31,代码来源:PackageService.cs

示例5: WillReturnConflictIfAPackageWithTheIdAndSemanticVersionAlreadyExists

            public void WillReturnConflictIfAPackageWithTheIdAndSemanticVersionAlreadyExists()
            {
                var version = new SemanticVersion("1.0.42");
                var nuGetPackage = new Mock<IPackage>();
                nuGetPackage.Setup(x => x.Id).Returns("theId");
                nuGetPackage.Setup(x => x.Version).Returns(version);

                var user = new User();

                var packageRegistration = new PackageRegistration
                {
                    Packages = new List<Package> { new Package { Version = version.ToString() } },
                    Owners = new List<User> { user }
                };

                var packageSvc = new Mock<IPackageService>();
                packageSvc.Setup(x => x.FindPackageRegistrationById(It.IsAny<string>())).Returns(packageRegistration);
                var userSvc = new Mock<IUserService>();
                userSvc.Setup(x => x.FindByApiKey(It.IsAny<Guid>())).Returns(user);
                var controller = CreateController(userSvc: userSvc, packageSvc: packageSvc, packageFromInputStream: nuGetPackage.Object);

                // Act
                var result = controller.CreatePackagePut(Guid.NewGuid().ToString());

                // Assert
                Assert.IsType<HttpStatusCodeWithBodyResult>(result);
                var statusCodeResult = (HttpStatusCodeWithBodyResult)result;
                Assert.Equal(409, statusCodeResult.StatusCode);
                Assert.Equal(String.Format(Strings.PackageExistsAndCannotBeModified, "theId", "1.0.42"), statusCodeResult.StatusDescription);
            }
开发者ID:Redsandro,项目名称:chocolatey.org,代码行数:30,代码来源:ApiControllerFacts.cs

示例6: IdConflictsWithExistingPackageTitleTests

        public void IdConflictsWithExistingPackageTitleTests(string existingPackageId, string existingPackageTitle, string newPackageId, bool shouldBeConflict)
        {
            // Arrange
            var existingPackageRegistration = new PackageRegistration
            {
                Id = existingPackageId,
                Owners = new HashSet<User>()
            };
            var existingPackage = new Package
            {
                PackageRegistration = existingPackageRegistration,
                Version = "1.0.0",
                Title = existingPackageTitle
            };

            var packageRegistrationRepository = new Mock<IEntityRepository<PackageRegistration>>();
            packageRegistrationRepository.Setup(r => r.GetAll()).Returns(new[] { existingPackageRegistration }.AsQueryable());

            var packageRepository = new Mock<IEntityRepository<Package>>();
            packageRepository.Setup(r => r.GetAll()).Returns(new[] { existingPackage }.AsQueryable());

            var target = new PackageNamingConflictValidator(packageRegistrationRepository.Object, packageRepository.Object);
            
            // Act
            var result = target.IdConflictsWithExistingPackageTitle(newPackageId);

            // Assert
            Assert.True(result == shouldBeConflict);
        }
开发者ID:igor-rif-shevchenko,项目名称:NuGetGallery,代码行数:29,代码来源:PackageNamingConflictValidatorFacts.cs

示例7: TestableCuratedPackagesController

            public TestableCuratedPackagesController()
            {
                Fakes = new Fakes();

                StubCuratedFeed = new CuratedFeed
                    { Key = 0, Name = "aFeedName", Managers = new HashSet<User>(new[] { Fakes.User }) };
                StubPackageRegistration = new PackageRegistration { Key = 0, Id = "anId" };

                OwinContext = Fakes.CreateOwinContext();

                EntitiesContext = new FakeEntitiesContext();
                EntitiesContext.CuratedFeeds.Add(StubCuratedFeed);
                EntitiesContext.PackageRegistrations.Add(StubPackageRegistration);

                var curatedFeedRepository = new EntityRepository<CuratedFeed>(
                    EntitiesContext);

                var curatedPackageRepository = new EntityRepository<CuratedPackage>(
                    EntitiesContext);

                base.CuratedFeedService = new CuratedFeedService(
                    curatedFeedRepository,
                    curatedPackageRepository);

                var httpContext = new Mock<HttpContextBase>();
                TestUtility.SetupHttpContextMockForUrlGeneration(httpContext, this);
            }
开发者ID:rhysawilliams2010,项目名称:NuGetGallery,代码行数:27,代码来源:CuratedPackagesControllerFacts.cs

示例8: CallsSendContactOwnersMessageWithUserInfo

            public void CallsSendContactOwnersMessageWithUserInfo()
            {
                var messageService = new Mock<IMessageService>();
                messageService.Setup(s => s.SendContactOwnersMessage(
                    It.IsAny<MailAddress>(),
                    It.IsAny<PackageRegistration>(),
                    "I like the cut of your jib", It.IsAny<string>()));
                var package = new PackageRegistration { Id = "factory" };

                var packageSvc = new Mock<IPackageService>();
                packageSvc.Setup(p => p.FindPackageRegistrationById("factory")).Returns(package);
                var httpContext = new Mock<HttpContextBase>();
                httpContext.Setup(h => h.User.Identity.Name).Returns("Montgomery");
                var userSvc = new Mock<IUserService>();
                userSvc.Setup(u => u.FindByUsername("Montgomery")).Returns(new User { EmailAddress = "[email protected]", Username = "Montgomery" });
                var controller = CreateController(packageSvc: packageSvc,
                    messageSvc: messageService,
                    userSvc: userSvc,
                    httpContext: httpContext);
                var model = new ContactOwnersViewModel
                {
                    Message = "I like the cut of your jib",
                };

                var result = controller.ContactOwners("factory", model) as RedirectToRouteResult;

                Assert.NotNull(result);
            }
开发者ID:sdamian,项目名称:chocolatey.org,代码行数:28,代码来源:PackagesControllerFacts.cs

示例9: WillSendEmailToAllOwners

            public void WillSendEmailToAllOwners()
            {
                var from = new MailAddress("[email protected]", "flossy");
                var package = new PackageRegistration { Id = "smangit" };
                package.Owners = new[]
                    {
                        new User { EmailAddress = "[email protected]", EmailAllowed = true },
                        new User { EmailAddress = "[email protected]", EmailAllowed = true }
                    };
                var mailSender = new Mock<IMailSender>();
                var setting = new GallerySetting { GalleryOwnerName = "NuGet Gallery", GalleryOwnerEmail = "[email protected]" };
                var messageService = new MessageService(mailSender.Object, setting);
                MailMessage message = null;
                mailSender.Setup(m => m.Send(It.IsAny<MailMessage>())).Callback<MailMessage>(m => { message = m; });

                messageService.SendContactOwnersMessage(from, package, "Test message", "http://someurl/");

                mailSender.Verify(m => m.Send(It.IsAny<MailMessage>()));
                Assert.Equal("[email protected]", message.To[0].Address);
                Assert.Equal("[email protected]", message.To[1].Address);
                Assert.Contains("[NuGet Gallery] Message for owners of the package 'smangit'", message.Subject);
                Assert.Contains("Test message", message.Body);
                Assert.Contains(
                    "User flossy &lt;[email protected]&gt; sends the following message to the owners of Package 'smangit'.", message.Body);
            }
开发者ID:ChrisMissal,项目名称:NuGetGallery,代码行数:25,代码来源:MessageServiceFacts.cs

示例10: TestableCreateCuratedPackageCommand

 public TestableCreateCuratedPackageCommand()
     : base(null)
 {
     StubCuratedFeed = new CuratedFeed { Key = 0, Name = "aName", };
     StubEntitiesContext = new Mock<IEntitiesContext>();
     StubPackageRegistration = new PackageRegistration { Key = 0, };
     Entities = StubEntitiesContext.Object;
 }
开发者ID:ChrisMissal,项目名称:NuGetGallery,代码行数:8,代码来源:CreatedCuratedPackageCommandFacts.cs

示例11: AddPackageOwner

        public void AddPackageOwner(PackageRegistration package, User user)
        {
            package.Owners.Add(user);
            packageRepo.CommitChanges();

            var request = FindExistingPackageOwnerRequest(package, user);
            if (request != null)
            {
                packageOwnerRequestRepository.DeleteOnCommit(request);
                packageOwnerRequestRepository.CommitChanges();
            }
        }
开发者ID:micahlmartin,项目名称:NuGetGallery,代码行数:12,代码来源:PackageService.cs

示例12: TestableCuratedPackagesController

            public TestableCuratedPackagesController()
            {
                StubCuratedFeed = new CuratedFeed
                    { Key = 0, Name = "aFeedName", Managers = new HashSet<User>(new[] { Fakes.User }) };
                StubPackageRegistration = new PackageRegistration { Key = 0, Id = "anId" };
                StubPackage = new Package
                {
                    Key = 34,
                    PackageRegistration = StubPackageRegistration,
                    PackageRegistrationKey = StubPackageRegistration.Key,
                    Version = "1.0.0"
                };
                StubLatestPackage = new Package
                {
                    Key = 42,
                    PackageRegistration = StubPackageRegistration,
                    PackageRegistrationKey = StubPackageRegistration.Key,
                    Version = "2.0.1-alpha",
                    IsLatest = true,
                    IsPrerelease = true
                };
                StubLatestStablePackage = new Package
                {
                    Key = 41,
                    PackageRegistration = StubPackageRegistration,
                    PackageRegistrationKey = StubPackageRegistration.Key,
                    Version = "2.0.0",
                    IsLatestStable = true
                };

                OwinContext = Fakes.CreateOwinContext();

                EntitiesContext = new FakeEntitiesContext();
                EntitiesContext.CuratedFeeds.Add(StubCuratedFeed);
                EntitiesContext.PackageRegistrations.Add(StubPackageRegistration);

                StubPackageRegistration.Packages.Add(StubPackage);
                StubPackageRegistration.Packages.Add(StubLatestPackage);
                StubPackageRegistration.Packages.Add(StubLatestStablePackage);

                var curatedFeedRepository = new EntityRepository<CuratedFeed>(
                    EntitiesContext);

                var curatedPackageRepository = new EntityRepository<CuratedPackage>(
                    EntitiesContext);

                base.CuratedFeedService = new CuratedFeedService(
                    curatedFeedRepository,
                    curatedPackageRepository);

                var httpContext = new Mock<HttpContextBase>();
                TestUtility.SetupHttpContextMockForUrlGeneration(httpContext, this);
            }
开发者ID:JetBrains,项目名称:ReSharperGallery,代码行数:53,代码来源:CuratedPackagesControllerFacts.cs

示例13: ToJson_PackageRegistration

        private static JObject ToJson_PackageRegistration(PackageRegistration packageRegistration)
        {
            JArray owners = ToJson_Owners(packageRegistration.Owners);

            JObject obj = new JObject();

            obj.Add("Key", packageRegistration.Key);
            obj.Add("Id", packageRegistration.Id);
            obj.Add("DownloadCount", packageRegistration.DownloadCount);
            obj.Add("Owners", owners);

            return obj;
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:13,代码来源:PackageJson.cs

示例14: InterceptPackageRegistrationMaterialized

        protected void InterceptPackageRegistrationMaterialized(PackageRegistration packageRegistration)
        {
            if (packageRegistration == null)
            {
                return;
            }

            int downloadCount;
            if (_downloadCountService.TryGetDownloadCountForPackageRegistration(packageRegistration.Id, out downloadCount))
            {
                packageRegistration.DownloadCount = downloadCount;
            }
        }
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:13,代码来源:DownloadCountObjectMaterializedInterceptor.cs

示例15: V1FeedSearchDoesNotReturnPrereleasePackages

                public void V1FeedSearchDoesNotReturnPrereleasePackages()
                {
                    // Arrange
                    var packageRegistration = new PackageRegistration { Id = "Foo" };
                    var repo = new Mock<IEntityRepository<Package>>(MockBehavior.Strict);
                    repo.Setup(r => r.GetAll()).Returns(
                        new[]
                    {
                        new Package
                            {
                                PackageRegistration = packageRegistration,
                                Version = "1.0.0",
                                IsPrerelease = false,
                                Listed = true,
                                DownloadStatistics = new List<PackageStatistics>()
                            },
                        new Package
                            {
                                PackageRegistration = packageRegistration,
                                Version = "1.0.1-a",
                                IsPrerelease = true,
                                Listed = true,
                                DownloadStatistics = new List<PackageStatistics>()
                            },
                    }.AsQueryable());
                    var configuration = new Mock<ConfigurationService>(MockBehavior.Strict);
                    configuration.Setup(c => c.GetSiteRoot(It.IsAny<bool>())).Returns("https://localhost:8081/");
                    var searchService = new Mock<ISearchService>(MockBehavior.Strict);
                    searchService.Setup(s => s.Search(It.IsAny<SearchFilter>())).Returns
                        <IQueryable<Package>, string>((_, __) => Task.FromResult(new SearchResults(_.Count(), DateTime.UtcNow, _)));
                    searchService.Setup(s => s.ContainsAllVersions).Returns(false);
                    var v1Service = new TestableV1Feed(repo.Object, configuration.Object, searchService.Object);

                    // Act
                    var result = v1Service.Search(null, null);

                    // Assert
                    Assert.Equal(1, result.Count());
                    Assert.Equal("Foo", result.First().Id);
                    Assert.Equal("1.0.0", result.First().Version);
                    Assert.Equal("https://localhost:8081/packages/Foo/1.0.0", result.First().GalleryDetailsUrl);
                }
开发者ID:henrycomein,项目名称:NuGetGallery,代码行数:42,代码来源:FeedServiceFacts.cs


注:本文中的NuGetGallery.PackageRegistration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。