Skip to content

Commit d26b90d

Browse files
committed
differentiate between text body and html body
1 parent 9c6ca43 commit d26b90d

18 files changed

Lines changed: 74 additions & 29 deletions

Source/spamfilter/spamfilter.BL.Tests/Actions/MoveEmailToFolderActionFactoryTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using MailKit;
12
using spamfilter.BL.Actions;
3+
using spamfilter.BL.Entities;
24
using Xunit;
35

46
namespace spamfilter.BL.Tests.Actions;
@@ -9,7 +11,7 @@ public class MoveEmailToFolderActionFactoryTests
911
public void Instanciates_a_class_of_type_MoveEmailToFolderAction()
1012
{
1113
var factory = new MoveEmailToFolderActionFactory("targetfolder");
12-
var action = factory.CreateFromEmail(null);
14+
var action = factory.CreateFromEmail(new Email("", "", UniqueId.Invalid, "", "", ""));
1315
Assert.IsType<MoveEmailToFolderAction>(action);
1416
}
1517
}

Source/spamfilter/spamfilter.BL.Tests/Actions/MoveEmailToFolderActionTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using spamfilter.BL.Actions;
2+
using spamfilter.BL.Entities;
23
using spamfilter.BL.Tests.Mocks;
34
using Xunit;
45

@@ -10,7 +11,9 @@ public class MoveEmailToFolderActionTests
1011
public void Execute_calls_the_MoveEmailToFolder_method_of_the_emailrepository()
1112
{
1213
var emailrepository = new EmailRepositoryMock();
13-
var action = new MoveEmailToFolderAction(null, "SomeFolder");
14+
var action = new MoveEmailToFolderAction(
15+
Email.Empty(),
16+
"SomeFolder");
1417
action.Execute(emailrepository);
1518

1619
Assert.True(emailrepository.MoveMailsToFolderHasBeenCalled);

Source/spamfilter/spamfilter.BL.Tests/Detectors/BelowSizeDetectorTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public void When_an_email_is_below_a_specified_size_it_is_detected()
2222
"",
2323
UniqueId.Invalid,
2424
"This is a subject",
25-
"This body has a size below 1000 bytes."
25+
"This body has a size below 1000 bytes.",
26+
""
2627
);
2728

2829
var detector = BelowSizeDetector(1000);
@@ -38,7 +39,8 @@ public void When_an_email_is_bigger_than_a_specified_size_it_is_not_detected()
3839
"",
3940
UniqueId.Invalid,
4041
"This is a subject",
41-
"This body is bigger than 20 bytes."
42+
"This body is bigger than 20 bytes.",
43+
""
4244
);
4345

4446
var detector = BelowSizeDetector(20);

Source/spamfilter/spamfilter.BL.Tests/Detectors/ContentBasedDetectorTests.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public void When_Hello_is_in_the_subject_and_we_search_for_it_it_detects()
2727
"",
2828
UniqueId.Invalid,
2929
"Hello",
30+
"",
3031
""
3132
);
3233

@@ -43,6 +44,7 @@ public void When_Hello_is_not_in_the_subject_and_we_search_for_it_it_does_not_de
4344
"",
4445
UniqueId.Invalid,
4546
"------",
47+
"",
4648
""
4749
);
4850

@@ -59,7 +61,8 @@ public void When_hello_is_in_the_body_but_we_search_in_the_subject_it_is_not_det
5961
"",
6062
UniqueId.Invalid,
6163
"Here is some other text",
62-
"Hello"
64+
"Hello",
65+
""
6366
);
6467

6568
var detector = Detector(true, false);
@@ -75,7 +78,8 @@ public void When_hello_is_in_the_subject_but_we_search_in_the_body_it_is_not_det
7578
"",
7679
UniqueId.Invalid,
7780
"Hello",
78-
"Some other text"
81+
"Some other text",
82+
""
7983
);
8084

8185
var detector = Detector(false, true);
@@ -91,7 +95,8 @@ public void When_hello_is_in_the_body_and_we_search_in_the_body_it_is_detected()
9195
"",
9296
UniqueId.Invalid,
9397
"Some other Text",
94-
"Hello"
98+
"Hello",
99+
""
95100
);
96101

97102
var detector = Detector(false, true);

Source/spamfilter/spamfilter.BL.Tests/Detectors/DetectionResultTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public void ConstructionTest()
1818
"",
1919
UniqueId.Invalid,
2020
"Subject",
21-
"Body"),
21+
"Body",
22+
""),
2223
Array.Empty<IIsMatchOpinion>());
2324

2425
Assert.Equal("Hello world", detectionResult.Email.SenderName);
@@ -35,7 +36,8 @@ public void When_multiple_opinions_are_there_the_one_with_the_highest_priority_i
3536
"",
3637
UniqueId.Invalid,
3738
"Subject",
38-
"Body"),
39+
"Body",
40+
""),
3941
new IIsMatchOpinion[]
4042
{
4143
new IsMatchOpinion(10, "I am uncertain", "Someone", true),

Source/spamfilter/spamfilter.BL.Tests/Detectors/DetectorGroupTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public void For_every_email_there_is_a_detection_result_based_on_the_detectors()
2525
var results = detectorGroup.Filter(
2626
new IEmail[]
2727
{
28-
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body"),
29-
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body")
28+
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body", ""),
29+
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body", "")
3030
});
3131

3232
Assert.Equal(2, results.Length);
@@ -46,8 +46,8 @@ public void When_an_exception_occurs_in_a_detector_we_detect_nothing()
4646
var results = detectorGroup.Filter(
4747
new IEmail[]
4848
{
49-
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body"),
50-
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body")
49+
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body", ""),
50+
new Email("Sender", "Sender", UniqueId.Invalid, "Subject", "Body", "")
5151
});
5252

5353
Assert.Empty(results);

Source/spamfilter/spamfilter.BL.Tests/Detectors/DomainExpressionBasedDetectorTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public void When_the_domain_is_matching_the_regular_expression_it_detects()
2222
"brian@amazon.de",
2323
UniqueId.Invalid,
2424
"",
25+
"",
2526
""
2627
);
2728

@@ -38,6 +39,7 @@ public void When_the_domain_is_not_matching_the_regular_expression_it_does_not_d
3839
"brian@amazon.de",
3940
UniqueId.Invalid,
4041
"",
42+
"",
4143
""
4244
);
4345

@@ -55,6 +57,7 @@ public void
5557
"brian@amazon.de",
5658
UniqueId.Invalid,
5759
"",
60+
"",
5861
""
5962
);
6063

Source/spamfilter/spamfilter.BL.Tests/Detectors/EmailEndsWithBasedDetectorTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public void When_the_email_address_ends_with_the_string_then_it_detects()
2222
"brian@amazon.de",
2323
UniqueId.Invalid,
2424
"",
25+
"",
2526
""
2627
);
2728

@@ -38,6 +39,7 @@ public void When_the_email_address_does_not_end_with_the_string_it_does_not_dete
3839
"brian@amazon.de",
3940
UniqueId.Invalid,
4041
"",
42+
"",
4143
""
4244
);
4345

Source/spamfilter/spamfilter.BL.Tests/Detectors/ImpersonatorSpamDetectorTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public void A_mail_from_amazon_is_ok_if_it_is_from_amazon_de()
2828
"amazon@amazon.de",
2929
UniqueId.Invalid,
3030
"Your orders",
31-
"Some stuff");
31+
"Some stuff",
32+
"");
3233

3334
Assert.Empty(SpamDetector().GetOpinionsOn(mail));
3435
}
@@ -41,7 +42,8 @@ public void A_mail_from_amazon_is_ok_if_it_is_from_amazon_com()
4142
"amazon@amazon.com",
4243
UniqueId.Invalid,
4344
"Your orders",
44-
"Some stuff");
45+
"Some stuff",
46+
"");
4547

4648
Assert.Empty(SpamDetector().GetOpinionsOn(mail));
4749
}
@@ -54,7 +56,8 @@ public void A_mail_from_amazon_is_NOT_ok_if_domain_is_wrong()
5456
"amazon@someimpersonator.com",
5557
UniqueId.Invalid,
5658
"Your orders",
57-
"some stuff");
59+
"some stuff",
60+
"");
5861

5962
var result = SpamDetector().GetOpinionsOn(mail);
6063
Assert.Single(result);

Source/spamfilter/spamfilter.BL.Tests/Detectors/InvalidSenderEmailAddressSpamDetectorTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void When_the_attached_emailvalidator_is_satisfied_we_get_OK()
2626
"amazon@amazon.de",
2727
UniqueId.Invalid,
2828
"Your orders",
29+
"",
2930
"");
3031

3132
Assert.Empty(SpamDetector().GetOpinionsOn(mail));
@@ -39,6 +40,7 @@ public void When_the_attached_emailvalidator_is_not_satisfied_it_is_spam()
3940
"Not-an-email",
4041
UniqueId.Invalid,
4142
"Your orders",
43+
"",
4244
"");
4345

4446
Assert.NotEmpty(SpamDetector().GetOpinionsOn(mail));

0 commit comments

Comments
 (0)