public void Run_ShouldCorrectlyParseMailFromAndAddDisplayNameFromHeaders() { //arrange var expectedAddress = new MailAddress("*****@*****.**"); var commandStub = "not empty string"; var headers = new NameValueCollection(); var fromAddressesCollection = new List <MailAddress> { new MailAddress("*****@*****.**"), new MailAddress("*****@*****.**"), new MailAddress("*****@*****.**", "Valentin Display Name") }; _clientController.Read().Returns(commandStub, commandStub, commandStub, _mailDataSection, commandStub); _requestCommandsConverter.ToRequestCommandCode(Arg.Any <string>()) .Returns(RequestCommands.Hello, RequestCommands.MailFrom, RequestCommands.Data, RequestCommands.Quit); _emailParser.ParseEmailFromString(commandStub).Returns(expectedAddress); _emailParser.ParseHeadersFromDataSection(_mailDataSection).Returns(headers); _emailParser.ParseEmailsFromDataFrom(headers).Returns(fromAddressesCollection); //act var message = _clientProcessor.Run(); //assert message.From.Address.Should().Be("*****@*****.**"); message.From.DisplayName.Should().Be("Valentin Display Name"); }
public void ParseEmailsFromDataFrom_ShouldParsFromAddress() { //arrange var headers = new NameValueCollection(); headers.Add("From", "\"To Name\" <*****@*****.**>,\r\n\"To Name\"<*****@*****.**>, \"To \r\nName\"<*****@*****.**>"); //act var result = _emailParser.ParseEmailsFromDataFrom(headers); //assert result.Count.Should().Be(1); result[0].Should().BeOfType <MailAddress>(); result[0].Address.Should().Be("*****@*****.**"); result[0].DisplayName.Should().Be("To Name"); }