Exemplo n.º 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 AddNullSupplierTest()
        {
            var organisation = new SupplierOrganisation();

            Action testCode = () => { organisation.AddSupplier(null); };

            Assert.NotNull(Record.Exception(testCode));
        }
        public void SuccessfulAddSupplierTest()
        {
            var supplier = new Supplier1("Supplier 1");

            var organisation = new SupplierOrganisation();

            organisation.AddSupplier(supplier);

            Assert.NotNull(organisation.Suppliers.Find(s => s == supplier));
        }
        public void SuccessfulAddSupplierSetOrganisationTest()
        {
            var supplier = new Supplier1("Supplier 1");

            var organisation = new SupplierOrganisation();

            organisation.AddSupplier(supplier);

            Assert.Equal(organisation, supplier.Organisation);
        }
        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);
        }