コード例 #1
0
            public void SendsPackageOwnerAddedNotice()
            {
                // Arrange
                var toUser = new User {
                    Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = true
                };
                var newUser = new User {
                    Username = "******", EmailAddress = "*****@*****.**"
                };
                var package = new PackageRegistration {
                    Id = "CoolStuff"
                };

                // Act
                var messageService = new TestableMessageService();

                messageService.SendPackageOwnerAddedNotice(toUser, newUser, package, "packageUrl", "policyMessage");

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

                Assert.Equal("*****@*****.**", message.To[0].Address);
                Assert.Equal(TestGalleryNoReplyAddress.Address, "*****@*****.**");
                Assert.Contains("The user 'Noob' is now an owner of the package 'CoolStuff'.", message.Subject);
                Assert.Contains("This is to inform you that 'Noob' is now an owner of the package", message.Body);
                Assert.Contains("policyMessage", message.Body);
            }
コード例 #2
0
            public void DoesNotSendPackageOwnerAddedNoticeIfUserDoesNotAllowEmails()
            {
                // Arrange
                var toUser = new User {
                    Username = "******", EmailAddress = "*****@*****.**"
                };
                var newUser = new User {
                    Username = "******", EmailAddress = "*****@*****.**", EmailAllowed = false
                };
                var package = new PackageRegistration {
                    Id = "CoolStuff"
                };

                // Act
                var messageService = new TestableMessageService();

                messageService.SendPackageOwnerAddedNotice(toUser, newUser, package, "packageUrl", "policyMessage");

                // Assert
                Assert.Empty(messageService.MockMailSender.Sent);
            }