ReportMyPackage() public method

public ReportMyPackage ( ReportPackageRequest request ) : void
request ReportPackageRequest
return void
Exemplo n.º 1
0
            public void WillSendEmailToGalleryOwner()
            {
                var from  = new MailAddress("*****@*****.**", "too");
                var owner = new User
                {
                    Username     = "******",
                    EmailAddress = "*****@*****.**",
                };
                var package = new Package
                {
                    PackageRegistration = new PackageRegistration
                    {
                        Id     = "smangit",
                        Owners = new Collection <User> {
                            owner
                        }
                    },
                    Version = "1.42.0.1"
                };
                var mailSender = new Mock <IMailSender>();
                var config     = new Mock <IConfiguration>();

                config.Setup(x => x.GalleryOwnerName).Returns("NuGet Gallery");
                config.Setup(x => x.GalleryOwnerEmail).Returns("*****@*****.**");
                var         messageService = new MessageService(mailSender.Object, config.Object);
                MailMessage message        = null;

                mailSender.Setup(m => m.Send(It.IsAny <MailMessage>())).Callback <MailMessage>(m => { message = m; });

                messageService.ReportMyPackage(
                    new ReportPackageRequest
                {
                    FromAddress    = from,
                    Message        = "Abuse!",
                    Package        = package,
                    Reason         = "Reason!",
                    RequestingUser = owner,
                    Url            = TestUtility.MockUrlHelper(),
                });

                Assert.Equal("*****@*****.**", message.To[0].Address);
                Assert.Equal("*****@*****.**", message.From.Address);
                Assert.Equal("*****@*****.**", message.ReplyToList.Single().Address);
                Assert.Equal("[NuGet Gallery] Owner Support Request for 'smangit' version 1.42.0.1 (Reason: Reason!)", message.Subject);
                Assert.Contains("Reason!", message.Body);
                Assert.Contains("Abuse!", message.Body);
                Assert.Contains("too ([email protected])", message.Body);
                Assert.Contains("smangit", message.Body);
                Assert.Contains("1.42.0.1", message.Body);
            }
Exemplo n.º 2
0
            public void WillSendEmailToGalleryOwner()
            {
                var from = new MailAddress("*****@*****.**", "too");
                var owner = new User
                {
                    Username = "******",
                    EmailAddress = "*****@*****.**",
                };
                var package = new Package
                {
                    PackageRegistration = new PackageRegistration
                    {
                        Id = "smangit", 
                        Owners = new Collection<User> { owner }
                    },
                    Version = "1.42.0.1"
                };
                var mailSender = new Mock<IMailSender>();
                var config = new Mock<IAppConfiguration>();
                config.Setup(x => x.GalleryOwner).Returns(TestGalleryOwner);
                var messageService = new MessageService(mailSender.Object, config.Object);
                MailMessage message = null;
                mailSender.Setup(m => m.Send(It.IsAny<MailMessage>())).Callback<MailMessage>(m => { message = m; });

                messageService.ReportMyPackage(
                    new ReportPackageRequest
                    {
                        FromAddress = from,
                        Message = "Abuse!",
                        Package = package,
                        Reason = "Reason!",
                        RequestingUser = owner,
                        Url = TestUtility.MockUrlHelper(),
                    });

                Assert.Equal(TestGalleryOwner.Address, message.To[0].Address);
                Assert.Equal(TestGalleryOwner.Address, message.From.Address);
                Assert.Equal("*****@*****.**", message.ReplyToList.Single().Address);
                Assert.Equal("[Joe Shmoe] Owner Support Request for 'smangit' version 1.42.0.1 (Reason: Reason!)", message.Subject);
                Assert.Contains("Reason!", message.Body);
                Assert.Contains("Abuse!", message.Body);
                Assert.Contains("too ([email protected])", message.Body);
                Assert.Contains("smangit", message.Body);
                Assert.Contains("1.42.0.1", message.Body);
            }