Exemplo n.º 1
0
        public void AddTwoNormalProducts()
        {
            ConcreteProduct product = new ConcreteProduct()
            {
                Name        = "My Super Product",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100
            };

            ConcreteProduct product2 = new ConcreteProduct()
            {
                Name        = "My Super Product 2",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100
            };

            SellService sellService = new SellService(this._repository);

            sellService.AddProduct(product);
            sellService.AddProduct(product2);

            Assert.AreEqual(product, this._repository.Get(0));
            Assert.AreEqual(product2, this._repository.Get(1));
        }
Exemplo n.º 2
0
        public void AddNormalProductEventsAddCheck()
        {
            ConcreteProduct product = new ConcreteProduct()
            {
                Name        = "My Super Product",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100,
            };

            SellService sellService = new SellService(this._repository);

            bool isAddCalled   = false;
            bool isAddedCalled = false;

            sellService.OnAddProduct   += (sender, args) => { isAddCalled = true; };
            sellService.OnAddedProduct += (sender, args) => { isAddedCalled = true; };

            sellService.AddProduct(product);

            Assert.IsTrue(isAddCalled);
            Assert.IsTrue(isAddedCalled);

            Assert.AreEqual(product, this._repository.Get(0));
        }
Exemplo n.º 3
0
        public void SellNormalProductEventCheck()
        {
            ConcreteProduct product = new ConcreteProduct()
            {
                Name        = "My Super Product",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100
            };

            SellService sellService = new SellService(this._repository);

            bool isSellChecked = false;
            bool isSoldChecked = false;

            sellService.OnSellProduct += (sender, args) => { isSellChecked = true; };
            sellService.OnSoldProduct += (sender, args) => { isSoldChecked = true; };

            sellService.AddProduct(product);
            sellService.SellProduct(product);

            Assert.IsTrue(isSellChecked);
            Assert.IsTrue(isSoldChecked);
            Assert.AreEqual((uint)49, this._repository.Get(0).Count);
        }
Exemplo n.º 4
0
        public void AddInvalidProductNull()
        {
            ConcreteProduct product = null;

            SellService sellService = new SellService(this._repository);

            sellService.AddProduct(product);
        }
Exemplo n.º 5
0
        public void DeleteUnExcitedProduct()
        {
            ConcreteProduct product = new ConcreteProduct()
            {
                Name        = "My Super Product",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100
            };

            SellService sellService = new SellService(this._repository);

            sellService.AddProduct(product);
            sellService.DeleteProduct(510);
        }
Exemplo n.º 6
0
        public void UpdateNullProduct()
        {
            ConcreteProduct product = new ConcreteProduct()
            {
                Name        = "My Super Product",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100
            };

            ConcreteProduct product2 = null;

            SellService sellService = new SellService(this._repository);

            sellService.AddProduct(product);
            sellService.UpdateProduct(product2);
        }
Exemplo n.º 7
0
        public void DeleteNormalProduct()
        {
            ConcreteProduct product = new ConcreteProduct()
            {
                Name        = "My Super Product",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100
            };

            SellService sellService = new SellService(this._repository);

            sellService.AddProduct(product);
            sellService.DeleteProduct(0);

            Assert.IsNull(this._repository.Get(0));
        }
Exemplo n.º 8
0
        public void SellNormalProduct()
        {
            ConcreteProduct product = new ConcreteProduct()
            {
                Name        = "My Super Product",
                Description = "Description of my super product",
                Weight      = 100,
                Price       = 100,
                Count       = 50,
                Height      = 100,
                Width       = 100
            };

            SellService sellService = new SellService(this._repository);

            sellService.AddProduct(product);
            sellService.SellProduct(product);

            Assert.AreEqual((uint)49, this._repository.Get(0).Count);
        }