-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSpamFilterTestCase.cs
More file actions
73 lines (65 loc) · 3.21 KB
/
Copy pathSpamFilterTestCase.cs
File metadata and controls
73 lines (65 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using NUnit.Framework;
using System;
namespace Auction.mod
{
[TestFixture()]
public class SpamFilterTestCase
{
[Test()]
public void TestSpamFilterBlock()
{
SpamFilter sf = new SpamFilter();
sf.setSpamTime(new TimeSpan(0, 1, 0));
DateTime time1 = new DateTime(2013, 1, 1, 0, 0, 0);
CardType cType = new CardType();
cType.id = 1;
Auction aBob1 = new Auction("bob", time1, Auction.OfferType.BUY, new Card(1, cType, true),"");
Auction aAlice1 = new Auction("alice", new DateTime(2013, 1, 1, 0, 0, 15), Auction.OfferType.BUY, new Card(1, cType, true),"");
DateTime time2 = new DateTime(2013, 1, 1, 0, 0, 30);
Auction aBob2 = new Auction("bob", time2, Auction.OfferType.BUY, new Card(1, cType, true),"");
sf.addAuction(aBob1);
sf.addAuction(aAlice1);
sf.addAuction(aBob2);
Assert.IsFalse(sf.isFilteredBySpamFilter(aBob1)); //Block the newer message and show the older one
Assert.IsFalse(sf.isFilteredBySpamFilter(aAlice1));
Assert.IsTrue(sf.isFilteredBySpamFilter(aBob2));
}
[Test()]
public void TestSpamFilterNotBlock()
{
SpamFilter sf = new SpamFilter();
sf.setSpamTime(new TimeSpan(0, 0, 15));
DateTime time1 = new DateTime(2013, 1, 1, 0, 0, 0);
CardType cType = new CardType();
cType.id = 1;
Auction aBob1 = new Auction("bob", time1, Auction.OfferType.BUY, new Card(1, cType, true),"");
Auction aAlice1 = new Auction("alice", new DateTime(2013, 1, 1, 0, 0, 15), Auction.OfferType.BUY, new Card(1, cType, true),"");
DateTime time2 = new DateTime(2013, 1, 1, 0, 0, 30);
Auction aBob2 = new Auction("bob", time2, Auction.OfferType.BUY, new Card(1, cType, true),"");
sf.addAuction(aBob1);
sf.addAuction(aAlice1);
sf.addAuction(aBob2);
Assert.IsTrue(sf.isFilteredBySpamFilter(aBob1)); //Block the oldest message and show the new
Assert.IsFalse(sf.isFilteredBySpamFilter(aAlice1));
Assert.IsFalse(sf.isFilteredBySpamFilter(aBob2));
}
[Test()]
public void TestSpamFilterDisabled()
{
SpamFilter sf = new SpamFilter(); //No SpamTime set => Show everything
DateTime time1 = new DateTime(2013, 1, 1, 0, 0, 0);
CardType cType = new CardType();
cType.id = 1;
Auction aBob1 = new Auction("bob", time1, Auction.OfferType.BUY, new Card(1, cType, true),"");
Auction aAlice1 = new Auction("alice", new DateTime(2013, 1, 1, 0, 0, 15), Auction.OfferType.BUY, new Card(1, cType, true),"");
DateTime time2 = new DateTime(2013, 1, 1, 0, 0, 30);
Auction aBob2 = new Auction("bob", time2, Auction.OfferType.BUY, new Card(1, cType, true),"");
sf.addAuction(aBob1);
sf.addAuction(aAlice1);
sf.addAuction(aBob2);
Assert.IsFalse(sf.isFilteredBySpamFilter(aBob1));
Assert.IsFalse(sf.isFilteredBySpamFilter(aAlice1));
Assert.IsFalse(sf.isFilteredBySpamFilter(aBob2));
}
}
}