Example #1
0
        public void FilteredResultCreatedAfterTest()
        {
            using (var testDb = new TestDB(DbConnectionFactory.CreatePersistent("Test")))
            {
                var threeMonthsAgo = DateTime.UtcNow.AddMonths(-3).Ticks;
                var items          = FilteredResultHelpers.ProcessFilters <TestModel>(linqToObjects, new JObject()
                {
                    { "Created_after", threeMonthsAgo }
                });

                Assert.AreEqual(2, items.Count());
            }
        }
Example #2
0
        public void FilteredResultCreatedBeforeTest()
        {
            using (var testDb = new TestDB(DbConnectionFactory.CreatePersistent("Test")))
            {
                var today = DateTime.UtcNow.Ticks;
                var items = FilteredResultHelpers.ProcessFilters <TestModel>(linqToObjects, new JObject()
                {
                    { "Created_before", today }
                });

                Assert.AreEqual(5, items.Count());
            }
        }
Example #3
0
        public void FilteredResultCreatedBetweenTest()
        {
            using (var testDb = new TestDB(DbConnectionFactory.CreatePersistent("Test")))
            {
                var oneMonthAgo   = DateTime.UtcNow.AddMonths(-1).Ticks;
                var fiveMonthsAgo = DateTime.UtcNow.AddMonths(-5).AddDays(-1).Ticks;

                var items = FilteredResultHelpers.ProcessFilters <TestModel>(linqToObjects, new JObject()
                {
                    { "Created_after", fiveMonthsAgo },
                    { "Created_before", oneMonthAgo }
                });

                Assert.AreEqual(3, items.Count());
            }
        }
Example #4
0
        public static void SetupTests(TestContext context)
        {
            using (var testDb = new TestDB(DbConnectionFactory.CreatePersistent("Test")))
            {
                testDb.Models.Add(new TestModel()
                {
                    Name    = "John",
                    Class   = "Ranger",
                    Created = DateTime.UtcNow
                });

                testDb.Models.Add(new KryptonDotNetTests.TestModel()
                {
                    Name    = "Sam",
                    Class   = "Warrior",
                    Created = DateTime.UtcNow.AddMonths(-1)
                });

                testDb.Models.Add(new KryptonDotNetTests.TestModel()
                {
                    Name    = "Sally",
                    Class   = "Warrior",
                    Created = DateTime.UtcNow.AddMonths(-6)
                });

                testDb.Models.Add(new KryptonDotNetTests.TestModel()
                {
                    Name    = "Josh",
                    Class   = "Mage",
                    Created = DateTime.UtcNow.AddMonths(-5)
                });

                testDb.Models.Add(new KryptonDotNetTests.TestModel()
                {
                    Name    = "Alyssa",
                    Class   = "Mage",
                    Created = DateTime.UtcNow.AddMonths(-4)
                });
                testDb.SaveChanges();
            }
        }