public void CreateCompositeAndSelectorTest() { List <Message> messages = new List <Message>() { new Message("text1", "num1", true, new DateTime(1991, 01, 11, 2, 21, 31)), new Message("text_2", "_num2", true, new DateTime(1992, 02, 12, 2, 22, 32)), new Message("text_3", "num3", true, new DateTime(1993, 03, 13, 2, 23, 33)), new Message("text4", "_num4", true, new DateTime(1994, 04, 14, 2, 24, 34)), new Message("text5", "num5", true, new DateTime(1995, 05, 15, 2, 25, 35)) }; var data = new SMSSelectorData("text_", "_num", new DateTime(1991, 02, 12, 2, 22, 32), new DateTime(1994, 07, 17, 2, 27, 37)); var factory = new SMSSelectorSimpleFactory(); SMSSelectorComposite selector = (SMSSelectorComposite)factory.CreateSelector("CompositeSelector"); selector.SelectorBooleanFunction = SMSSelectorComposite.SelectorBoolFunc.And; Assert.IsTrue(selector.IsUsed(data)); Assert.IsFalse(selector.Predicate(messages[0], data)); Assert.IsTrue(selector.Predicate(messages[1], data)); Assert.IsFalse(selector.Predicate(messages[2], data)); Assert.IsFalse(selector.Predicate(messages[3], data)); Assert.IsFalse(selector.Predicate(messages[4], data)); }
public void CreateTrivialTest() { List <Message> messages = new List <Message>() { new Message("text1", "num1", true, new DateTime(1991, 01, 11, 2, 21, 31)), new Message("text_2", "_num2", true, new DateTime(1992, 02, 12, 2, 22, 32)), new Message("text_3", "num3", true, new DateTime(1993, 03, 13, 2, 23, 33)), new Message("text4", "_num4", true, new DateTime(1994, 04, 14, 2, 24, 34)), new Message("text5", "num5", true, new DateTime(1995, 05, 15, 2, 25, 35)) }; var factory = new SMSSelectorSimpleFactory(); SMSSelector selector = factory.CreateSelector(null); Assert.IsNull(selector); }
public void CreateFromDateSelectorTest() { List <Message> messages = new List <Message>() { new Message("text1", "num1", true, new DateTime(1991, 01, 11, 2, 21, 31)), new Message("text_2", "_num2", true, new DateTime(1992, 02, 12, 2, 22, 32)), new Message("text_3", "num3", true, new DateTime(1993, 03, 13, 2, 23, 33)), new Message("text4", "_num4", true, new DateTime(1994, 04, 14, 2, 24, 34)), new Message("text5", "num5", true, new DateTime(1995, 05, 15, 2, 25, 35)) }; var data = new SMSSelectorData("text_", "_num", new DateTime(1993, 03, 13, 2, 23, 33), new DateTime(1994, 07, 17, 2, 27, 37)); var factory = new SMSSelectorSimpleFactory(); SMSSelector selector = factory.CreateSelector("RecievedAfterSelector"); Assert.IsTrue(selector.IsUsed(data)); Assert.IsFalse(selector.Predicate(messages[0], data)); Assert.IsFalse(selector.Predicate(messages[1], data)); Assert.IsTrue(selector.Predicate(messages[2], data)); Assert.IsTrue(selector.Predicate(messages[3], data)); Assert.IsTrue(selector.Predicate(messages[4], data)); }