private void addAuction(Auction a) { //Console.WriteLine("add auction with time" + a.time.ToLongTimeString() + a.time.Millisecond); spamFilter.addAuction(a); if (a.offer == Auction.OfferType.BUY) { fullBuyOfferList.Insert(0, a); if (!buyOfferFilter.isFiltered(a) && !this.spamFilter.isFilteredBySpamFilter(a)) { buyOfferListFiltered.Insert(0, a); newBuyOffers = true; } } else if (a.offer == Auction.OfferType.SELL) { fullSellOfferList.Insert(0, a); if (!sellOfferFilter.isFiltered(a) && !this.spamFilter.isFilteredBySpamFilter(a)) { sellOfferListFiltered.Insert(0, a); newSellOffers = true; } } }
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)); }
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)); }