コード例 #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 messageService = new TestableMessageService();

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

                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(TestGalleryOwner, message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                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);
            }
コード例 #2
0
            public void WillCopySenderIfAsked()
            {
                var from    = new MailAddress("*****@*****.**", "too");
                var package = new Package
                {
                    PackageRegistration = new PackageRegistration {
                        Id = "smangit"
                    },
                    Version = "1.42.0.1",
                };
                var messageService = new TestableMessageService();

                var reportPackageRequest = new ReportPackageRequest
                {
                    AlreadyContactedOwners = true,
                    FromAddress            = from,
                    Message        = "Abuse!",
                    Package        = package,
                    Reason         = "Reason!",
                    RequestingUser = new User
                    {
                        Username     = "******",
                        EmailAddress = "*****@*****.**"
                    },
                    Signature  = "Joe Schmoe",
                    Url        = TestUtility.MockUrlHelper(),
                    CopySender = true,
                };

                messageService.ReportMyPackage(reportPackageRequest);

                var message = messageService.MockMailSender.Sent.Single();

                Assert.Equal(TestGalleryOwner, message.To.Single());
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal(reportPackageRequest.FromAddress, message.ReplyToList.Single());
                Assert.Equal(reportPackageRequest.FromAddress, message.CC.Single());
                Assert.DoesNotContain("Owners", message.Body);
            }
コード例 #3
0
            public void WillCopySenderIfAsked()
            {
                var from = new MailAddress("*****@*****.**", "too");
                var package = new Package
                {
                    PackageRegistration = new PackageRegistration { Id = "smangit" },
                    Version = "1.42.0.1",
                };
                var messageService = new TestableMessageService();

                var reportPackageRequest = new ReportPackageRequest
                {
                    AlreadyContactedOwners = true,
                    FromAddress = from,
                    Message = "Abuse!",
                    Package = package,
                    Reason = "Reason!",
                    RequestingUser = new User
                    {
                        Username = "******",
                        EmailAddress = "*****@*****.**"
                    },
                    Signature = "Joe Schmoe",
                    Url = TestUtility.MockUrlHelper(),
                    CopySender = true,
                };
                messageService.ReportMyPackage(reportPackageRequest);

                var message = messageService.MockMailSender.Sent.Single();
                Assert.Equal(TestGalleryOwner, message.To.Single());
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal(reportPackageRequest.FromAddress, message.ReplyToList.Single());
                Assert.Equal(reportPackageRequest.FromAddress, message.CC.Single());
                Assert.DoesNotContain("Owners", message.Body);
            }
コード例 #4
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 messageService = new TestableMessageService();

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

                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(TestGalleryOwner, message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                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);
            }