Esempio n. 1
0
        public void ReturnsStoreWithId10_GivenStoreByIdSpec()
        {
            var spec = new StoreByIdSpec(10);

            var store = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).FirstOrDefault();

            store.Id.Should().Be(10);
        }
Esempio n. 2
0
        public void ReturnsOrderStoresByNameDescThenByIdForCompanyWithId2_GivenStoresByCompanyOrderedDescByNameThenByIdSpec()
        {
            var spec = new StoresByCompanyOrderedDescByNameThenByIdSpec(2);

            var stores = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList();

            stores.First().Id.Should().Be(99);
            stores.Last().Id.Should().Be(98);
        }
Esempio n. 3
0
        public void ReturnsOrderStoresByNameDescForCompanyWithId2_GivenStoresByCompanyOrderedDescByNameSpec()
        {
            var spec = new StoresByCompanyOrderedDescByNameSpec(2);

            var stores = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList();

            stores.First().Id.Should().Be(StoreSeed.ORDERED_BY_NAME_DESC_FOR_COMPANY2_FIRST_ID);
            stores.Last().Id.Should().Be(StoreSeed.ORDERED_BY_NAME_DESC_FOR_COMPANY2_LAST_ID);
        }
Esempio n. 4
0
        public void ReturnsOrderedStores_GivenStoresOrderedDescendingByNameSpec()
        {
            var spec = new StoresOrderedDescendingByNameSpec();

            var stores = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList();

            stores.First().Id.Should().Be(StoreSeed.ORDERED_BY_NAME_DESC_FIRST_ID);
            stores.Last().Id.Should().Be(StoreSeed.ORDERED_BY_NAME_DESC_LAST_ID);
        }
Esempio n. 5
0
        public void ReturnsStoreWithIdFrom15To30_GivenStoresByIdListSpec()
        {
            var ids  = Enumerable.Range(15, 16);
            var spec = new StoresByIdListSpec(ids);

            var stores = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList();

            stores.Count.Should().Be(16);
            stores.OrderBy(x => x.Id).First().Id.Should().Be(15);
            stores.OrderBy(x => x.Id).Last().Id.Should().Be(30);
        }
Esempio n. 6
0
        public void ReturnsSecondPageOfStoresForCompanyWithId2_GivenStoresByCompanyPaginatedOrderedDescByNameSpec()
        {
            int take = 10;           // pagesize 10
            int skip = (2 - 1) * 10; // page 2

            var spec = new StoresByCompanyPaginatedOrderedDescByNameSpec(2, skip, take);

            var stores = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList();

            stores.Count.Should().Be(take);
            stores.First().Id.Should().Be(StoreSeed.ORDERED_BY_NAME_DESC_FOR_COMPANY2_PAGE2_FIRST_ID);
            stores.Last().Id.Should().Be(StoreSeed.ORDERED_BY_NAME_DESC_FOR_COMPANY2_PAGE2_LAST_ID);
        }
Esempio n. 7
0
        public void ReturnsSecondPageOfStores_GivenStoresPaginatedSpec()
        {
            int take = 10;           // pagesize 10
            int skip = (2 - 1) * 10; // page 2

            var spec = new StoresPaginatedSpec(skip, take);

            var stores = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList();

            stores.Count.Should().Be(take);
            stores.OrderBy(x => x.Id).First().Id.Should().Be(11);
            stores.OrderBy(x => x.Id).Last().Id.Should().Be(20);
        }
Esempio n. 8
0
        public void ReturnsSecondPageOfStoreNames_GivenStoreNamesPaginatedSpec()
        {
            int take = 10;           // pagesize 10
            int skip = (2 - 1) * 10; // page 2

            var spec = new StoreNamesPaginatedSpec(skip, take);

            var storeNames = evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList();

            storeNames.Count.Should().Be(take);
            storeNames.First().Should().Be("Store 11");
            storeNames.Last().Should().Be("Store 20");
        }
Esempio n. 9
0
        public void ThrowsDuplicateOrderChainException_GivenSpecWithMultipleOrderChains()
        {
            var spec = new StoresOrderedTwoChainsSpec();

            Assert.Throws <DuplicateOrderChainException>(() => evaluator.GetQuery(StoreSeed.AsQueryable(), spec).ToList());
        }