11using Nager . EmailAuthentication . FragmentParsers ;
2+ using Nager . EmailAuthentication . Models . Spf ;
3+ using Nager . EmailAuthentication . Models . Spf . Mechanisms ;
4+ using Nager . EmailAuthentication . Models . Spf . Modifiers ;
25
36namespace Nager . EmailAuthentication . UnitTest . SpfRecordParserTest . FragmentParser
47{
@@ -15,6 +18,22 @@ public void Should_Parse_Spf_With_Include_And_All()
1518 Assert . IsNotNull ( spfDataFragment ) ;
1619 Assert . IsNotNull ( spfDataFragment . SpfTerms ) ;
1720 Assert . AreEqual ( 2 , spfDataFragment . SpfTerms . Length ) ;
21+
22+
23+ if ( spfDataFragment . SpfTerms [ 0 ] is SpfModifierBase spfModifier )
24+ {
25+ Assert . Fail ( "Wrong mapping, is not a modifier" ) ;
26+ }
27+
28+ if ( spfDataFragment . SpfTerms [ 0 ] is not SpfMechanismBase spfMechanism )
29+ {
30+ Assert . Fail ( "Wrong mapping, is a mechanism" ) ;
31+ return ;
32+ }
33+
34+ Assert . AreEqual ( MechanismType . Include , spfMechanism . MechanismType ) ;
35+ Assert . AreEqual ( "spf.protection.outlook.com" , spfMechanism . MechanismData ) ;
36+ Assert . AreEqual ( SpfQualifier . Pass , spfMechanism . Qualifier ) ;
1837 }
1938
2039 [ TestMethod ]
@@ -27,6 +46,20 @@ public void Should_Parse_Spf_With_Redirect()
2746 Assert . IsNotNull ( spfDataFragment ) ;
2847 Assert . IsNotNull ( spfDataFragment . SpfTerms ) ;
2948 Assert . AreEqual ( 1 , spfDataFragment . SpfTerms . Length ) ;
49+
50+ if ( spfDataFragment . SpfTerms [ 0 ] is SpfMechanismBase spfMechanism )
51+ {
52+ Assert . Fail ( "Wrong mapping, is not a mechanism" ) ;
53+ }
54+
55+ if ( spfDataFragment . SpfTerms [ 0 ] is not SpfModifierBase spfModifier )
56+ {
57+ Assert . Fail ( "Wrong mapping, is a modifier" ) ;
58+ return ;
59+ }
60+
61+ Assert . AreEqual ( ModifierType . Redirect , spfModifier . ModifierType ) ;
62+ Assert . AreEqual ( "spf.provider.com" , spfModifier . ModifierData ) ;
3063 }
3164
3265 [ TestMethod ]
0 commit comments