Skip to content

Commit

Permalink
optimize unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Jan 13, 2025
1 parent 26904bd commit e20c581
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Nager.EmailAuthentication.UnitTest/DmarcRecordParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,21 @@ public void TryParse_ValidDmarcString2_ReturnsTrueAndPopulatesDmarcRecord()
}

[TestMethod]
public void TryParse_CorruptDmarcString1_ReturnsTrueAndPopulatesDmarcRecord()
public void TryParse_ValidDmarcString3_ReturnsTrueAndPopulatesDmarcRecord()
{
var isSuccessful = DmarcRecordParser.TryParse("v=DMARC1; p=reject; rua=mailto:[email protected], mailto:[email protected]; pct=100; adkim=s; aspf=s", out var dmarcDataFragment, out var parseErrors);
Assert.IsTrue(isSuccessful);
Assert.IsNotNull(dmarcDataFragment);
Assert.AreEqual("reject", dmarcDataFragment.DomainPolicy);
Assert.AreEqual("mailto:[email protected], mailto:[email protected]", dmarcDataFragment.AggregateReportUri);
Assert.AreEqual("100", dmarcDataFragment.PolicyPercentage);
Assert.AreEqual("s", dmarcDataFragment.DkimAlignmentMode);
Assert.AreEqual("s", dmarcDataFragment.SpfAlignmentMode);
Assert.IsNull(parseErrors);
}

[TestMethod]
public void TryParse_CorruptDmarcString1_ReturnsTrueAndParseErrors()
{
var isSuccessful = DmarcRecordParser.TryParse("verification=123456789", out var dmarcDataFragment, out var parseErrors);
Assert.IsTrue(isSuccessful);
Expand All @@ -74,7 +88,7 @@ public void TryParse_CorruptDmarcString1_ReturnsTrueAndPopulatesDmarcRecord()
}

[TestMethod]
public void TryParse_CorruptDmarcString2_ReturnsTrueAndPopulatesDmarcRecord()
public void TryParse_CorruptDmarcString2_ReturnsFalse()
{
var isSuccessful = DmarcRecordParser.TryParse(" ", out var dmarcDataFragment, out var parseErrors);
Assert.IsFalse(isSuccessful);
Expand Down

0 comments on commit e20c581

Please sign in to comment.