Esempio n. 1
0
        public void Create_WithNonExistentUser_ShouldReturnFalse()
        {
            string errorMessagePrefix = "ReviewsService Create() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.reviewsService = new ReviewsService(context, new UniShopUsersService(context));

            string userId = context.Users.First().Id + new Guid();

            int productId = context.Products.Last().Id + 1;

            ReviewServiceModel testReview = new ReviewServiceModel
            {
                Raiting   = 2,
                ProductId = productId,
                Comment   = "Test Comment Test"
            };

            int expectedCount = context.Reviews.Count();

            bool actualResult = this.reviewsService.Create(testReview, userId);
            int  actualCount  = context.Reviews.Count();

            Assert.False(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 2
0
        public void GetOrderByIdAndUserId_WithNonCorrectData_ShouldReturnNull()
        {
            string errorMessagePrefix = "OrdersService GetOrderByIdAndUserId() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);

            string userId = context.Users.First().Id;

            string nonExistentUserId = userId + new Guid();

            Order order = new Order
            {
                OrderStatus   = OrderStatus.Processed,
                UniShopUserId = userId,
            };

            context.Add(order);
            context.SaveChanges();

            ShoppingCartsService shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            this.orderService = new OrdersService(context, new UniShopUsersService(context), shoppingCartsService, new SuppliersService(context),
                                                  new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            OrderServiceModel actualResults = this.orderService.GetOrderByIdAndUserId(order.Id, nonExistentUserId);


            Assert.True(actualResults == null, errorMessagePrefix);
        }
Esempio n. 3
0
        public void GetReviewsByProductId_WithDummyData_ShouldReturnCorrectResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.reviewsService = new ReviewsService(context, new UniShopUsersService(context));

            string        userId      = context.Users.First().Id;
            int           productId   = context.Products.First().Id;
            List <Review> testReviews = new List <Review>
            {
                new Review
                {
                    Raiting       = 4,
                    ProductId     = productId,
                    Comment       = "Test Comment Test",
                    UniShopUserId = userId
                },
                new Review
                {
                    Raiting       = 5,
                    ProductId     = productId,
                    Comment       = "Test Comment Test2",
                    UniShopUserId = userId
                }
            };

            context.AddRange(testReviews);
            context.SaveChanges();

            List <ReviewServiceModel> actualResults = this.reviewsService.GetReviewsByProductId(productId).ToList();
            int expectedResults = 2;

            Assert.Equal(expectedResults, actualResults.Count());
        }
        public void Create_WithNonExistentParentCategory_ShouldReturnFalse()
        {
            string errorMessagePrefix = "ProductsService Create() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));

            int nonExistentChildCategoryId = context.ChildCategories.Last().Id + 1;

            ProductServiceModel testProduct = new ProductServiceModel
            {
                Name            = "Lenovo",
                ChildCategoryId = nonExistentChildCategoryId
            };

            int expectedCount = context.ChildCategories.Count();

            bool actualResult = this.productsService.Create(testProduct);
            int  actualCount  = context.ChildCategories.Count();

            Assert.False(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 5
0
        public void AddAddress_WithCorrectData_ShouldSuccessfullyCreate()
        {
            string errorMessagePrefix = "AddressesService AddAddress() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.addressesService = new AddressesService(context, new UniShopUsersService(context));

            UniShopUser user = context.Users.First();

            AddressServiceModel testAddress = new AddressServiceModel
            {
                City           = "SofiqTestCraete",
                Street         = "TesterCreate",
                BuildingNumber = "223"
            };

            int expectedCount = user.Addresses.Count() + 1;

            bool actualResult = this.addressesService.AddAddress(testAddress, user.Id);
            int  actualCount  = user.Addresses.Count();

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 6
0
        public void ReduceQuantity_WithShoppingCartProductQuantityOne_ShouldReturnFalse()
        {
            string errorMessagePrefix = "ShoppingCartsService ReduceQuantity() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user      = context.Users.First();
            int         productId = context.Products.Where(p => p.Quantity == 0).First().Id;

            ShoppingCartProduct testShoppingCartProduct = new ShoppingCartProduct
            {
                ProductId      = productId,
                ShoppingCartId = user.ShoppingCartId,
                Quantity       = 1
            };

            context.Add(testShoppingCartProduct);
            context.SaveChanges();

            int expectedCount = testShoppingCartProduct.Quantity;

            bool actualResult = this.shoppingCartsService.ReduceQuantity(productId, user.UserName);
            int  actualCount  = testShoppingCartProduct.Quantity;

            Assert.False(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
        public void Edit_WithCorrectData_ShouldPassSuccessfully()
        {
            string errorMessagePrefix = "ProductsService Edit() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));


            ProductServiceModel productFromDb = context.Products.First().To <ProductServiceModel>();

            ProductServiceModel expectedProduct = productFromDb;

            expectedProduct.Name          = "Edit";
            expectedProduct.Price         = 0.01M;
            expectedProduct.Description   = "TestProductEdit";
            expectedProduct.Specification = "TestProductEdit";


            bool actualResult = this.productsService.Edit(expectedProduct);

            ProductServiceModel actualProduct = context.Products.FirstOrDefault(p => p.Id == productFromDb.Id).To <ProductServiceModel>();

            Assert.True(actualProduct.Name == expectedProduct.Name, errorMessagePrefix + " " + "Name not editted properly.");
            Assert.True(actualProduct.Price == expectedProduct.Price, errorMessagePrefix + " " + "Price not editted properly.");
            Assert.True(actualProduct.Description == expectedProduct.Description, errorMessagePrefix + " " + "Description not editted properly.");
            Assert.True(actualProduct.Specification == expectedProduct.Specification, errorMessagePrefix + " " + "Specification not editted properly.");
            Assert.True(actualResult, errorMessagePrefix);
        }
Esempio n. 8
0
        public void AddShoppingCartProduct_WithExistentShoppingCartProductAndProductQuantityMoreThenOne_ShouldSuccessfullyIncreaseQuantity()
        {
            string errorMessagePrefix = "ShoppingCartsService AddShoppingCartProduct() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user      = context.Users.First();
            int         productId = context.Products.First().Id;

            ShoppingCartProduct testShoppingCartProduct = new ShoppingCartProduct
            {
                ProductId      = productId,
                ShoppingCartId = user.ShoppingCartId,
                Quantity       = 1
            };

            context.Add(testShoppingCartProduct);
            context.SaveChanges();

            ShoppingCartProduct shoppingCartProduct = context.ShoppingCartProducts
                                                      .First(s => s.ShoppingCartId == user.ShoppingCartId && s.ProductId == productId);

            int expectedCount = shoppingCartProduct.Quantity + 1;

            bool actualResult = this.shoppingCartsService.AddShoppingCartProduct(productId, user.UserName);
            int  actualCount  = shoppingCartProduct.Quantity;

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 9
0
        public void Delete_WithCorrectData_ShouldSuccessfullyDelete()
        {
            string errorMessagePrefix = "ReviewsService Delete() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.reviewsService = new ReviewsService(context, new UniShopUsersService(context));

            string userId    = context.Users.First().Id;
            int    productId = context.Products.First().Id;

            Review testReview = new Review
            {
                UniShopUserId = userId,
                Raiting       = 4,
                ProductId     = productId,
                Comment       = "Test Comment Test"
            };

            context.Reviews.Add(testReview);
            context.SaveChanges();

            int  expectedCount = context.Reviews.Count() - 1;
            bool actualResult  = this.reviewsService.Delete(testReview.Id);
            int  actualCount   = context.Reviews.Count();

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 10
0
        public void DeliverOrder_WithCorrectData_ShouldChangeOrderStatusToDelivered()
        {
            string errorMessagePrefix = "OrdersService DeliverOrder() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);

            ShoppingCartsService shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            this.orderService = new OrdersService(context, new UniShopUsersService(context), shoppingCartsService, new SuppliersService(context),
                                                  new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user = context.Users.First();

            Order order = new Order
            {
                OrderStatus   = OrderStatus.Processed,
                UniShopUserId = user.Id,
            };

            context.Add(order);
            context.SaveChanges();

            OrderStatus expectedOrderStatus = OrderStatus.Delivered;

            bool        actualResult      = this.orderService.DeliverOrder(order.Id);
            OrderStatus actualOrderStatus = order.OrderStatus;

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedOrderStatus, actualOrderStatus);
        }
Esempio n. 11
0
        public void CreateOrder_WithoutProductsInShoppingCart_ShouldReturnFalse()
        {
            string errorMessagePrefix = "OrdersService CreateOrder() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);

            ShoppingCartsService shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            this.orderService = new OrdersService(context, new UniShopUsersService(context), shoppingCartsService, new SuppliersService(context),
                                                  new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user       = context.Users.First();
            int         supplierId = context.Suppliers.First().Id;
            int         addressId  = user.Addresses.First().Id;

            int expectedCount = user.Orders.Count();

            bool actualResult = this.orderService.CreateOrder(user.UserName, supplierId, 1, addressId);
            int  actualCount  = user.Orders.Count();

            Assert.False(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
Esempio n. 12
0
        public void GetOrderByIdAndUserId_WithExistentId_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "OrdersService GetOrderByIdAndUserId() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);

            ShoppingCartsService shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            this.orderService = new OrdersService(context, new UniShopUsersService(context), shoppingCartsService, new SuppliersService(context),
                                                  new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user = context.Users.First();

            Order order = new Order
            {
                OrderStatus   = OrderStatus.Processed,
                UniShopUserId = user.Id,
            };

            context.Add(order);
            context.SaveChanges();

            OrderServiceModel expectedResults = user.Orders.First().To <OrderServiceModel>();
            OrderServiceModel actualResults   = this.orderService.GetOrderByIdAndUserId(expectedResults.Id, user.Id);


            Assert.True(expectedResults.Id == actualResults.Id, errorMessagePrefix + " " + "Id is not returned properly.");
            Assert.True(expectedResults.OrderStatus == actualResults.OrderStatus, errorMessagePrefix + " " + "OrderStatus is not returned properly.");
            Assert.True(expectedResults.UniShopUserId == actualResults.UniShopUserId, errorMessagePrefix + " " + "UniShopUserId Count is not returned properly.");
        }
Esempio n. 13
0
        public void RemoveShoppingCartProduct_WithCorrectData_ShouldSuccessfullyRemove()
        {
            string errorMessagePrefix = "ShoppingCartsService RemoveShoppingCartProduct() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.shoppingCartsService = new ShoppingCartsService(context, new UniShopUsersService(context),
                                                                 new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context))));

            UniShopUser user      = context.Users.First();
            int         productId = context.Products.First().Id;

            ShoppingCartProduct testShoppingCartProduct = new ShoppingCartProduct
            {
                ProductId      = productId,
                ShoppingCartId = user.ShoppingCartId,
                Quantity       = 2
            };

            context.Add(testShoppingCartProduct);
            context.SaveChanges();

            int expectedCount = user.ShoppingCart.ShoppingCartProducts.Count() - 1;

            bool actualResult = this.shoppingCartsService.RemoveShoppingCartProduct(productId, user.UserName);
            int  actualCount  = user.ShoppingCart.ShoppingCartProducts.Count();

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
        public void GetAllFavoriteProductsByUserId_WithDummyData_ShouldReturnCorrectResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.favoriteProductsService = new FavoriteProductsService(context, new UniShopUsersService(context));

            string userId          = context.Users.First().Id;
            int    firstProductId  = context.Products.First().Id;
            int    secondProductId = context.Products.Last().Id;
            List <UniShopUserFavoriteProduct> testfavoriteProducts = new List <UniShopUserFavoriteProduct>
            {
                new UniShopUserFavoriteProduct
                {
                    UniShopUserId = userId,
                    ProductId     = firstProductId
                },
                new UniShopUserFavoriteProduct
                {
                    UniShopUserId = userId,
                    ProductId     = secondProductId
                }
            };

            context.AddRange(testfavoriteProducts);
            context.SaveChanges();

            List <UniShopUserFavoriteProductServiceModel> actualResults = this.favoriteProductsService.GetAllFavoriteProductsByUserId(userId).ToList();
            int expectedResults = 2;

            Assert.Equal(expectedResults, actualResults.Count());
        }
        public void AddFavoriteProduct_WithExistentSameFavoriteProduct_ShouldReturnFalse()
        {
            string errorMessagePrefix = "FavoriteProductsService AddFavoriteProduct() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.favoriteProductsService = new FavoriteProductsService(context, new UniShopUsersService(context));

            UniShopUser user      = context.Users.First();
            int         productId = context.Products.First().Id;

            UniShopUserFavoriteProduct testFavoriteProduct = new UniShopUserFavoriteProduct
            {
                UniShopUserId = user.Id,
                ProductId     = productId
            };

            context.Add(testFavoriteProduct);
            context.SaveChanges();

            int expectedCount = user.FavoriteProducts.Count();

            bool actualResult = this.favoriteProductsService.AddFavoriteProduct(productId, user.UserName);
            int  actualCount  = user.FavoriteProducts.Count();

            Assert.False(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
        public void Create_WithCorrectData_ShouldSuccessfullyCreate()
        {
            string errorMessagePrefix = "ChildCategoriesService Create() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.childCategoriesService = new ChildCategoriesService(context, new ParentCategoriesService(context));

            int parentCategoryId = context.ParentCategories.First().Id;

            ChildCategoryServiceModel testChildCategory = new ChildCategoryServiceModel
            {
                Name             = "Настолни компютри",
                ParentCategoryId = parentCategoryId
            };

            int expectedCount = context.ChildCategories.Count() + 1;

            bool actualResult = this.childCategoriesService.Create(testChildCategory);
            int  actualCount  = context.ChildCategories.Count();

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(expectedCount, actualCount);
        }
        public void GetAllSuppliers_WithZeroData_ShouldReturnEmptyResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.suppliersService = new SuppliersService(context);

            List <SupplierServiceModel> actualResults = this.suppliersService.GetAllSuppliers().ToList();
            int expectedResults = 0;

            Assert.Equal(expectedResults, actualResults.Count());
        }
        public void GetAllChildCategories_WithZeroData_ShouldReturnEmptyResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.childCategoriesService = new ChildCategoriesService(context, new ParentCategoriesService(context));

            List <ChildCategoryServiceModel> actualResults = this.childCategoriesService.GetAllChildCategories().ToList();
            int expectedResults = 0;

            Assert.Equal(expectedResults, actualResults.Count());
        }
Esempio n. 19
0
        public void GetAllParentCategories_WithDummyData_ShouldReturnCorrectResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.parentCategoriesService = new ParentCategoriesService(context);

            List <ParentCategoryServiceModel> actualResults = this.parentCategoriesService.GetAllParentCategories().ToList();
            int expectedResults = 3;

            Assert.Equal(expectedResults, actualResults.Count());
        }
Esempio n. 20
0
        public void GetUserById_WithNonExistentId_ShouldReturnNull()
        {
            string errorMessagePrefix = "UniShopUserService GetUserById() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            SeedData(context);
            this.uniShopUsersService = new UniShopUsersService(context);

            UniShopUserServiceModel actualData = this.uniShopUsersService.GetUserById("bd6b5598-2704-4786-8db17e214db5ba864");

            Assert.True(actualData == null, errorMessagePrefix);
        }
Esempio n. 21
0
        public void GetUserByUsername_WithNonExistentUserName_ShouldReturnNull()
        {
            string errorMessagePrefix = "UniShopUserService GetUserByUsername() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            SeedData(context);
            this.uniShopUsersService = new UniShopUsersService(context);

            UniShopUserServiceModel actualResults = this.uniShopUsersService.GetUserByUsername("UserName");

            Assert.True(actualResults == null, errorMessagePrefix);
        }
Esempio n. 22
0
        public void Delete_WithNonExistentReview_ShouldReturnFalse()
        {
            string errorMessagePrefix = "ReviewsService Delete() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.reviewsService = new ReviewsService(context, new UniShopUsersService(context));

            bool actualResult = this.reviewsService.Delete(1000);

            Assert.False(actualResult, errorMessagePrefix);
        }
Esempio n. 23
0
        public void SortProducts_WithZeroData_ShouldReturnEmptyResult()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));

            IQueryable <ProductServiceModel> dataFromDb   = context.Products.To <ProductServiceModel>();
            List <ProductServiceModel>       actualData   = this.productsService.SortProducts(dataFromDb, ProductsSort.PriceAscending).ToList();
            List <ProductServiceModel>       expectedData = dataFromDb.OrderBy(p => p.Price).ToList();


            Assert.True(actualData.Count() == expectedData.Count());
        }
Esempio n. 24
0
        public void GetAllProducts_WithChildCategoryIdWithoutSearchStringWithDummyData_ShouldReturnCorrectResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));

            var testChildCategory = context.ChildCategories.FirstOrDefault(c => c.Name == "Мебели");

            List <ProductServiceModel> actualResults = this.productsService.GetAllProducts(testChildCategory.Id, null).ToList();
            int expectedResults = 1;

            Assert.Equal(expectedResults, actualResults.Count());
        }
Esempio n. 25
0
        public void GetAllProducts_WithoutChildCategoryIdWithSearchStringWithDummyData_ShouldReturnCorrectResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.productsService = new ProductsService(context, new ChildCategoriesService(context, new ParentCategoriesService(context)));



            List <ProductServiceModel> actualResults = this.productsService.GetAllProducts(null, "Lenovo").ToList();
            int expectedResults = 2;

            Assert.Equal(expectedResults, actualResults.Count());
        }
        public void GetAllFavoriteProductsByUserId_WithNonExistentUser_ShouldReturnEmptyResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.favoriteProductsService = new FavoriteProductsService(context, new UniShopUsersService(context));

            string nonExistentuserId = context.Users.Last().Id + new Guid();

            List <UniShopUserFavoriteProductServiceModel> actualResults = this.favoriteProductsService.GetAllFavoriteProductsByUserId(nonExistentuserId).ToList();
            int expectedResults = 0;

            Assert.Equal(expectedResults, actualResults.Count());
        }
Esempio n. 27
0
        public void GetAddressesByUserName_WithNonExistentUser_ShouldReturnEmptyResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.addressesService = new AddressesService(context, new UniShopUsersService(context));

            UniShopUser user = context.Users.Last();

            List <AddressServiceModel> actualResults = this.addressesService.GetAddressesByUserName(user.UserName + "Test").ToList();
            int expectedResults = 0;

            Assert.Equal(expectedResults, actualResults.Count());
        }
Esempio n. 28
0
        public void GetReviewsByProductId_WithNonExistentProduct_ShouldReturnEmptyResults()
        {
            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            this.SeedData(context);
            this.reviewsService = new ReviewsService(context, new UniShopUsersService(context));

            int productId = context.Products.Last().Id + 1;

            List <ReviewServiceModel> actualResults = this.reviewsService.GetReviewsByProductId(productId).ToList();
            int expectedResults = 0;

            Assert.Equal(expectedResults, actualResults.Count());
        }
        public void Edit_WithCorrectData_ShouldPassSuccessfully()
        {
            string errorMessagePrefix = "SuppliersService Edit() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            SeedData(context);
            this.suppliersService = new SuppliersService(context);

            SupplierServiceModel expectedData = context.Suppliers.First().To <SupplierServiceModel>();

            bool actualData = this.suppliersService.Edit(expectedData);

            Assert.True(actualData, errorMessagePrefix);
        }
        public void GetSupplierById_WithNonExistentId_ShouldReturnNull()
        {
            string errorMessagePrefix = "SuppliersService GetSupplierById() method does not work properly.";

            var context = UniShopDbContextInMemoryFactory.InitializeContext();

            SeedData(context);
            this.suppliersService = new SuppliersService(context);

            int nonExistentId = 5;

            SupplierServiceModel actualResult = this.suppliersService.GetSupplierById(nonExistentId);

            Assert.True(actualResult == null, errorMessagePrefix);
        }