public void GetShoppingListItems_FilterListWithExact(string filters)
        {
            //Arrange
            var dbOptions = new DbContextOptionsBuilder <CarbonKitchenDbContext>()
                            .UseInMemoryDatabase(databaseName: $"ShoppingListItemDb{Guid.NewGuid()}")
                            .Options;
            var sieveOptions = Options.Create(new SieveOptions());

            var fakeShoppingListItemOne = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemOne.Name           = "Alpha";
            fakeShoppingListItemOne.Category       = "Bravo";
            fakeShoppingListItemOne.ShoppingListId = 5;

            var fakeShoppingListItemTwo = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemTwo.Name           = "Charlie";
            fakeShoppingListItemTwo.Category       = "Delta";
            fakeShoppingListItemTwo.ShoppingListId = 6;

            var fakeShoppingListItemThree = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemThree.Name           = "Echo";
            fakeShoppingListItemThree.Category       = "Foxtrot";
            fakeShoppingListItemThree.ShoppingListId = 7;

            //Act
            using (var context = new CarbonKitchenDbContext(dbOptions))
            {
                context.ShoppingListItems.AddRange(fakeShoppingListItemOne, fakeShoppingListItemTwo, fakeShoppingListItemThree);
                context.SaveChanges();

                var service = new ShoppingListItemRepository(context, new SieveProcessor(sieveOptions));

                var ShoppingListItemRepo = service.GetShoppingListItems(new ShoppingListItemParametersDto {
                    Filters = filters
                });

                //Assert
                ShoppingListItemRepo.Should()
                .HaveCount(1);

                context.Database.EnsureDeleted();
            }
        }
        public void GetShoppingListItems_SearchQueryReturnsExpectedRecordCount(string queryString, int expectedCount)
        {
            //Arrange
            var dbOptions = new DbContextOptionsBuilder <CarbonKitchenDbContext>()
                            .UseInMemoryDatabase(databaseName: $"ShoppingListItemDb{Guid.NewGuid()}")
                            .Options;
            var sieveOptions = Options.Create(new SieveOptions());

            var fakeShoppingListItemOne = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemOne.Name     = "Alpha";
            fakeShoppingListItemOne.Category = "Bravo";

            var fakeShoppingListItemTwo = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemTwo.Name     = "Hartsfield";
            fakeShoppingListItemTwo.Category = "White";

            var fakeShoppingListItemThree = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemThree.Name     = "Bravehart";
            fakeShoppingListItemThree.Category = "Jonfav";

            //Act
            using (var context = new CarbonKitchenDbContext(dbOptions))
            {
                context.ShoppingListItems.AddRange(fakeShoppingListItemOne, fakeShoppingListItemTwo, fakeShoppingListItemThree);
                context.SaveChanges();

                var service = new ShoppingListItemRepository(context, new SieveProcessor(sieveOptions));

                var ShoppingListItemRepo = service.GetShoppingListItems(new ShoppingListItemParametersDto {
                    QueryString = queryString
                });

                //Assert
                ShoppingListItemRepo.Should()
                .HaveCount(expectedCount);

                context.Database.EnsureDeleted();
            }
        }
        public void GetShoppingListItems_ListSortedInDescOrder()
        {
            //Arrange
            var dbOptions = new DbContextOptionsBuilder <CarbonKitchenDbContext>()
                            .UseInMemoryDatabase(databaseName: $"ShoppingListItemDb{Guid.NewGuid()}")
                            .Options;
            var sieveOptions = Options.Create(new SieveOptions());

            var fakeShoppingListItemOne = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemOne.Name = "Bravo";

            var fakeShoppingListItemTwo = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemTwo.Name = "Alpha";

            var fakeShoppingListItemThree = new FakeShoppingListItem {
            }.Generate();

            fakeShoppingListItemThree.Name = "Charlie";

            //Act
            using (var context = new CarbonKitchenDbContext(dbOptions))
            {
                context.ShoppingListItems.AddRange(fakeShoppingListItemOne, fakeShoppingListItemTwo, fakeShoppingListItemThree);
                context.SaveChanges();

                var service = new ShoppingListItemRepository(context, new SieveProcessor(sieveOptions));

                var ShoppingListItemRepo = service.GetShoppingListItems(new ShoppingListItemParametersDto {
                    SortOrder = "-Name"
                });

                //Assert
                ShoppingListItemRepo.Should()
                .ContainInOrder(fakeShoppingListItemThree, fakeShoppingListItemOne, fakeShoppingListItemTwo);

                context.Database.EnsureDeleted();
            }
        }
        public void GetShoppingListItems_ReturnExpectedPageSize()
        {
            //Arrange
            var dbOptions = new DbContextOptionsBuilder <CarbonKitchenDbContext>()
                            .UseInMemoryDatabase(databaseName: $"ShoppingListItemDb{Guid.NewGuid()}")
                            .Options;
            var sieveOptions = Options.Create(new SieveOptions());

            var fakeShoppingListItemOne = new FakeShoppingListItem {
            }.Generate();
            var fakeShoppingListItemTwo = new FakeShoppingListItem {
            }.Generate();
            var fakeShoppingListItemThree = new FakeShoppingListItem {
            }.Generate();

            //Act
            using (var context = new CarbonKitchenDbContext(dbOptions))
            {
                context.ShoppingListItems.AddRange(fakeShoppingListItemOne, fakeShoppingListItemTwo, fakeShoppingListItemThree);
                context.SaveChanges();

                var service = new ShoppingListItemRepository(context, new SieveProcessor(sieveOptions));

                var ShoppingListItemRepo = service.GetShoppingListItems(new ShoppingListItemParametersDto {
                    PageSize = 2
                });

                //Assert
                ShoppingListItemRepo.Should()
                .NotBeEmpty()
                .And.HaveCount(2);

                ShoppingListItemRepo.Should().ContainEquivalentOf(fakeShoppingListItemOne);
                ShoppingListItemRepo.Should().ContainEquivalentOf(fakeShoppingListItemTwo);

                context.Database.EnsureDeleted();
            }
        }