Ejemplo n.º 1
0
        public void TestGetUnexistingProduct()
        {
            var       service = new Core.Services.Implementation.ProductService(new TestProdRepo());
            Exception ex      = Assert.Throws <InvalidDataException>(() =>
                                                                     service.GetProductById(1));

            Assert.Equal("Product does not exist.", ex.Message);
        }
Ejemplo n.º 2
0
        public void TestAddProductWithNoPrice()
        {
            var service = new Core.Services.Implementation.ProductService(new TestProdRepo());

            Assert.True(service.GetAllProducts(null).Count == 0);
            var prod1 = new Product()
            {
                Id          = 0,
                Console     = "PS4",
                Stock       = 5,
                Title       = "Spoodermoobs",
                ReleaseDate = DateTime.Now
            };

            service.CreateProduct(prod1);
            Assert.Equal(service.GetProductById(0).Price, 0);
        }
Ejemplo n.º 3
0
        public void AddProduct()
        {
            Filter filter  = null;
            var    service = new Core.Services.Implementation.ProductService(new TestProdRepo());

            Assert.True(service.GetAllProducts(filter).Count == 0);
            var prod1 = new Product()
            {
                Id          = 0,
                Console     = "PS4",
                Price       = 500,
                Stock       = 5,
                Title       = "Spoodermoobs",
                ReleaseDate = DateTime.Now
            };

            service.CreateProduct(prod1);
            Assert.True(service.GetProductById(0) == prod1);
        }