public ReportAbuse ( NuGetGallery.ReportPackageRequest request ) : void | ||
request | NuGetGallery.ReportPackageRequest | |
리턴 | void |
public void WillSendEmailToGalleryOwner() { var from = new MailAddress("*****@*****.**", "too"); var package = new Package { PackageRegistration = new PackageRegistration { Id = "smangit" }, 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.ReportAbuse( new ReportPackageRequest { AlreadyContactedOwners = true, FromAddress = from, Message = "Abuse!", Package = package, Reason = "Reason!", RequestingUser = null, Url = TestUtility.MockUrlHelper(), }); Assert.Equal("*****@*****.**", message.To[0].Address); Assert.Equal("*****@*****.**", message.From.Address); Assert.Equal("*****@*****.**", message.ReplyToList.Single().Address); Assert.Equal("[NuGet Gallery] 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); Assert.Contains("Yes", message.Body); }
public void WillSendEmailToGalleryOwner() { var from = new MailAddress("*****@*****.**", "too"); var package = new Package { PackageRegistration = new PackageRegistration { Id = "smangit" }, Version = "1.42.0.1" }; var mailSender = new Mock<IMailSender>(); var setting = new GallerySetting { GalleryOwnerName = "NuGet Gallery", GalleryOwnerEmail = "*****@*****.**" }; var messageService = new MessageService(mailSender.Object, setting); MailMessage message = null; mailSender.Setup(m => m.Send(It.IsAny<MailMessage>())).Callback<MailMessage>(m => { message = m; }); messageService.ReportAbuse(from, package, "Abuse!"); Assert.Equal("*****@*****.**", message.To[0].Address); Assert.Equal("[NuGet Gallery] Abuse Report for Package 'smangit' Version '1.42.0.1'", message.Subject); Assert.Contains("Abuse!", message.Body); Assert.Contains("User too ([email protected]) reports the package 'smangit' version '1.42.0.1' as abusive", message.Body); }
public void WillSendEmailToGalleryOwner() { var from = new MailAddress("*****@*****.**", "too"); var package = new Package { PackageRegistration = new PackageRegistration { Id = "smangit" }, 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.ReportAbuse( new ReportPackageRequest { AlreadyContactedOwners = true, FromAddress = from, Message = "Abuse!", Package = package, Reason = "Reason!", RequestingUser = null, Url = TestUtility.MockUrlHelper(), }); Assert.Equal("*****@*****.**", message.To[0].Address); Assert.Equal("*****@*****.**", message.From.Address); Assert.Equal("*****@*****.**", message.ReplyToList.Single().Address); Assert.Equal("[NuGet Gallery] 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); Assert.Contains("Yes", message.Body); }