예제 #1
0
        public void AddInitialData()
        {
            Supplier supplier1 = new Supplier1("Supplier 1");
            var      article1  = new Article(458);

            supplier1.AddArticle(article1);
            _context.Suppliers.Add(supplier1);

            Supplier supplier2 = new Supplier2("Supplier 2");
            var      article2  = new Article(459);

            supplier2.AddArticle(article2);
            _context.Suppliers.Add(supplier2);

            var      article3  = new Article(460);
            Supplier supplier3 = new Supplier3("Supplier 3");

            supplier3.AddArticle(article3);

            SupplierOrganisation organisation = new SupplierOrganisation()
            {
                ID = 1
            };

            organisation.AddSupplier(supplier1);
            organisation.AddSupplier(supplier2);
            organisation.AddSupplier(supplier3);
            _context.Organisations.Add(organisation);
        }
        public void AddNullArticleTest()
        {
            var supplier = new Supplier1();

            Action testCode = () => { supplier.AddArticle(null); };

            Assert.NotNull(Record.Exception(testCode));
        }
        public void ArticleInInventoryTest()
        {
            var article = new Article
            {
                ID = 2
            };
            var supplier = new Supplier1();

            supplier.AddArticle(article);

            Assert.True(supplier.ArticleInInventory(article.ID));
        }
        public void NoArticleInInventoryTest()
        {
            var article = new Article
            {
                ID = 2
            };
            var supplier = new Supplier1();

            supplier.AddArticle(article);

            Assert.False(supplier.ArticleInInventory(23));
        }
        public void SuccessfulAddArticleSupplierSetTest()
        {
            var article = new Article
            {
                ID = 2
            };
            var supplier = new Supplier1();

            supplier.AddArticle(article);

            Assert.Equal(supplier.Articles.Find(a => a == article).Supplier, supplier);
        }
        public void SuccessfulAddArticleTest()
        {
            var article = new Article
            {
                ID = 2
            };
            var supplier = new Supplier1();

            supplier.AddArticle(article);

            Assert.NotNull(supplier.Articles.Find(a => a == article));
        }
        public void GetArticleWithNoExestingIdTest()
        {
            var article = new Article
            {
                ID = 2
            };
            var supplier = new Supplier1();

            supplier.AddArticle(article);

            var articleFromInventory = supplier.GetArticle(23);

            Assert.Null(articleFromInventory);
        }
        public void GetArticleTest()
        {
            var article = new Article
            {
                ID = 2
            };
            var supplier = new Supplier1();

            supplier.AddArticle(article);

            var articleFromInventory = supplier.GetArticle(article.ID);

            Assert.Equal(articleFromInventory, article);
        }
        public void SoldArticleInInventoryTest()
        {
            var article = new Article
            {
                ID = 2
            };

            article.Sell(12);
            var supplier = new Supplier1();

            supplier.AddArticle(article);

            Assert.False(supplier.ArticleInInventory(article.ID));
        }
        public void HasViableleArticleWithIncorrectArticleId()
        {
            int price        = 10;
            int idArticle    = 2;
            var validArticle = new Article(price)
            {
                ID = idArticle
            };
            var supplier = new Supplier1("Supplier 1");

            supplier.AddArticle(validArticle);

            Assert.False(supplier.HasViableleArticle(idArticle + 1, price + 1));
        }
        public void SuccessfulHasViableleArticle()
        {
            int price        = 10;
            int idArticle    = 2;
            var validArticle = new Article(price)
            {
                ID = idArticle
            };
            var supplier = new Supplier1("Supplier 1");

            supplier.AddArticle(validArticle);

            Assert.True(supplier.HasViableleArticle(idArticle, price + 1));
        }
        public void SuccessfulOrderArticle()
        {
            int price        = 10;
            int idArticle    = 2;
            var validArticle = new Article(price)
            {
                ID = idArticle
            };
            var supplier = new Supplier1("Supplier 1");

            supplier.AddArticle(validArticle);
            var organisation = new SupplierOrganisation();

            organisation.AddSupplier(supplier);

            var orderedArticle = organisation.OrderArticle(idArticle, price + 1);

            Assert.Equal(orderedArticle, validArticle);
        }