public void SendsPackageOwnerRequestConfirmationUrl()
            {
                var to = new User {
                    Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = true
                };
                var from = new User {
                    Username = "******", EmailAddress = "*****@*****.**"
                };
                var package = new PackageRegistration {
                    Id = "CoolStuff"
                };
                const string confirmationUrl = "http://example.com/confirmation-token-url";

                var messageService = new TestableMessageService();

                messageService.SendPackageOwnerRequest(from, to, package, confirmationUrl);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal("*****@*****.**", message.To[0].Address);
                Assert.Equal(TestGalleryNoReplyAddress.Address, message.From.Address);
                Assert.Equal("*****@*****.**", message.ReplyToList.Single().Address);
                Assert.Equal("[Joe Shmoe] The user 'Existing' wants to add you as an owner of the package 'CoolStuff'.", message.Subject);
                Assert.Contains(confirmationUrl, message.Body);
                Assert.Contains("The user 'Existing' wants to add you as an owner of the package 'CoolStuff'.", message.Body);
            }
            public void DoesNotSendRequestIfUserDoesNotAllowEmails()
            {
                var to = new User {
                    Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = false
                };
                var from = new User {
                    Username = "******", EmailAddress = "*****@*****.**"
                };
                var package = new PackageRegistration {
                    Id = "CoolStuff"
                };
                const string confirmationUrl = "http://example.com/confirmation-token-url";

                var messageService = new TestableMessageService();

                messageService.SendPackageOwnerRequest(from, to, package, confirmationUrl);

                Assert.Empty(messageService.MockMailSender.Sent);
            }
Exemple #3
0
            public void SendsPackageOwnerRequestConfirmationUrlWithoutUserMessage()
            {
                var to = new User {
                    Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = true
                };
                var from = new User {
                    Username = "******", EmailAddress = "*****@*****.**"
                };
                var package = new PackageRegistration {
                    Id = "CoolStuff"
                };
                const string confirmationUrl = "http://example.com/confirmation-token-url";
                var          messageService  = new TestableMessageService();

                messageService.SendPackageOwnerRequest(from, to, package, confirmationUrl, string.Empty);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.DoesNotContain("The user 'Existing' added the following message for you", message.Body);
            }
            public void DoesNotSendRequestIfUserDoesNotAllowEmails()
            {
                var to = new User { Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = false };
                var from = new User { Username = "******", EmailAddress = "*****@*****.**" };
                var package = new PackageRegistration { Id = "CoolStuff" };
                const string confirmationUrl = "http://example.com/confirmation-token-url";

                var messageService = new TestableMessageService();
                messageService.SendPackageOwnerRequest(from, to, package, confirmationUrl);

                Assert.Empty(messageService.MockMailSender.Sent);
            }
            public void SendsPackageOwnerRequestConfirmationUrl()
            {
                var to = new User { Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = true };
                var from = new User { Username = "******", EmailAddress = "*****@*****.**" };
                var package = new PackageRegistration { Id = "CoolStuff" };
                const string confirmationUrl = "http://example.com/confirmation-token-url";

                var messageService = new TestableMessageService();
                messageService.SendPackageOwnerRequest(from, to, package, confirmationUrl);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal("*****@*****.**", message.To[0].Address);
                Assert.Equal(TestGalleryOwner.Address, message.From.Address);
                Assert.Equal("*****@*****.**", message.ReplyToList.Single().Address);
                Assert.Equal("[Joe Shmoe] The user 'Existing' wants to add you as an owner of the package 'CoolStuff'.", message.Subject);
                Assert.Contains(confirmationUrl, message.Body);
                Assert.Contains("The user 'Existing' wants to add you as an owner of the package 'CoolStuff'.", message.Body);
            }
            public void SendsPackageOwnerRequestConfirmationUrlWithoutUserMessage()
            {
                var to = new User { Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = true };
                var from = new User { Username = "******", EmailAddress = "*****@*****.**" };
                var package = new PackageRegistration { Id = "CoolStuff" };
                const string confirmationUrl = "http://example.com/confirmation-token-url";
                var messageService = new TestableMessageService();
                messageService.SendPackageOwnerRequest(from, to, package, confirmationUrl, string.Empty);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.DoesNotContain("The user 'Existing' added the following message for you", message.Body);
            }