コード例 #1
0
        public void VisibleFrom_Should_Throw_ArgumentNullException_If_Categories_Is_Null()
        {
            IQueryable<Category> categories = null;
            DateTime fromDate = DateTime.Today;

            var ex = Assert.Throws<ArgumentNullException>(() => CategoryExtensions.VisibleFrom(categories, fromDate));
            Assert.Equal(nameof(categories), ex.ParamName);
        }
コード例 #2
0
        public void VisibleFrom_Should_Returns_Only_Categories_With_VisibleFrom_Date_Greater_Than_The_Specified_Date()
        {
            DateTime fromDate = DateTime.Today;

            var c1 = Category.Create("c1", "c1", "c1");
            var c2 = Category.Create("c2", "c2", "c2");
            var c3 = Category.Create("c3", "c3", "c3");

            c1.SetAsVisible(fromDate, null);
            c2.SetAsVisible();

            IQueryable<Category> categories = new Category[]
            {
                c1, c2, c3
            }.AsQueryable();

            var categoriesVisible = CategoryExtensions.VisibleFrom(categories, fromDate).ToArray();
            Assert.True(categoriesVisible.All(c => c.VisibleFrom >= fromDate && c.IsVisible));
        }
コード例 #3
0
        public void VisibleTill_Should_Returns_Only_Categories_With_VisibleTo_Date_Previous_Than_The_Specified_Date()
        {
            DateTime tillDate = DateTime.Today.AddDays(3);

            var c1 = Category.Create("c1", "c1", "c1");
            var c2 = Category.Create("c2", "c2", "c2");
            var c3 = Category.Create("c3", "c3", "c3");

            c1.SetAsVisible(DateTime.Today, tillDate);
            c2.SetAsVisible(DateTime.Today, DateTime.Today.AddDays(1));

            IQueryable<Category> categories = new Category[]
            {
                c1, c2, c3
            }.AsQueryable();

            var categoriesVisible = CategoryExtensions.VisibleFrom(categories, tillDate).ToArray();
            Assert.True(categoriesVisible.All(c => c.VisibleTo <= tillDate && c.IsVisible));
        }