public void Delete_DeletesOrderById_CorrectListOfOrders()
        {
            Vendor.ClearAll();
            Order.Clear();
            string name        = "Suzie's cafe";
            string description = "Description";
            Vendor newVendor   = new Vendor(name, description);

            string   title01            = "Order 1";
            string   orderDescription01 = "Description of order 1";
            double   price01            = 23.50;
            DateTime date01             = new DateTime(2020, 01, 10);
            Order    order01            = new Order(title01, orderDescription01, price01, date01);

            newVendor.AddOrder(order01);
            string   title02            = "Order 2";
            string   orderDescription02 = "Description of order 2";
            double   price02            = 13.50;
            DateTime date02             = new DateTime(2020, 02, 20);
            Order    order02            = new Order(title02, orderDescription02, price02, date02);

            newVendor.AddOrder(order02);

            newVendor.DeleteOrder(1);
            List <Order> result = newVendor.GetOrderList();
            List <Order> orders = new List <Order> {
                order01
            };

            CollectionAssert.AreEqual(orders, result);
        }
        public void Find_FindsOrderById_Order()
        {
            Vendor.ClearAll();
            Order.Clear();
            string name        = "Suzie's cafe";
            string description = "Description";
            Vendor newVendor   = new Vendor(name, description);

            string   title01            = "Order 1";
            string   orderDescription01 = "Description of order 1";
            double   price01            = 23.50;
            DateTime date01             = new DateTime(2020, 01, 10);
            Order    order01            = new Order(title01, orderDescription01, price01, date01);

            newVendor.AddOrder(order01);
            string   title02            = "Order 2";
            string   orderDescription02 = "Description of order 2";
            double   price02            = 13.50;
            DateTime date02             = new DateTime(2020, 02, 20);
            Order    order02            = new Order(title02, orderDescription02, price02, date02);

            newVendor.AddOrder(order02);

            Order result        = newVendor.FindOrder(1);
            Order selectedOrder = order02;

            Assert.AreEqual(selectedOrder, result);
        }
        public void GetById_ReturnsVendorWithGivenId_Vendor()
        {
            Vendor.ClearAll();
            Vendor vendor1 = new("Vendor1");
            Vendor vendor2 = new("Vendor2");

            Assert.AreEqual(vendor2, Vendor.GetById(2));
        }
        public ActionResult DeleteAll(string searchId)
        {
            int    numId  = int.Parse(searchId);
            Vendor vendor = Vendor.Find(numId);

            vendor.ClearAll();
            return(RedirectToAction("Index"));
        }
示例#5
0
        public void ClearAll_ClearsVendors_Vendor()
        {
            string name01     = "French Bakery Vendor";
            string desc01     = "Delicious patisserie";
            Vendor newVendor1 = new Vendor(name01, desc01);

            Vendor.ClearAll();
            Assert.AreEqual(Vendor.GetVendors().Count, 0);
        }
        public void GetAll_ReturnsAllInstancesOfVendor_VendorList()
        {
            Vendor.ClearAll();
            Vendor        vendor1  = new("Vendor1");
            Vendor        vendor2  = new("Vendor2");
            List <Vendor> expected = new List <Vendor> {
                vendor1, vendor2
            };

            CollectionAssert.AreEqual(expected, Vendor.GetAll());
        }
示例#7
0
        public void ClearAll_ClearsListOfAllVendors_EmptyListOfVendors()
        {
            Vendor        newVendor1   = new Vendor("name", "description");
            Vendor        newVendor2   = new Vendor("name", "description");
            Vendor        newVendor3   = new Vendor("name", "description");
            List <Vendor> expectedList = new List <Vendor> {
            };

            Vendor.ClearAll();
            CollectionAssert.AreEquivalent(expectedList, Vendor.GetAll());
        }
        public ActionResult Create(string vendorName, string vendorDescription, bool deleteVendors)
        {
            if (deleteVendors)
            {
                Vendor.ClearAll();
            }
            else if (vendorName != null)
            {
                Vendor newVendor = new Vendor(vendorName, vendorDescription);
            }

            return(RedirectToAction("Index"));
        }
        public void AddOrder_CreatesOrderAndAddsToOrderList_VendorList()
        {
            Vendor.ClearAll();
            Vendor testVendor = new("Test Vendor");
            Order  testOrder  = new("Test Order", "Test order description", 50, 1, 1);

            testVendor.AddOrder("Test Order", "Test order description", 50, 1, 1);
            List <Order> expected = new List <Order> {
                testOrder
            };

            Assert.AreEqual(expected[0].GetType(), testVendor.Orders[0].GetType());
            Assert.AreEqual(expected[0].Title, testVendor.Orders[0].Title);
        }
        public void Delete_DeletesVendorById_CorrectListOfVendors()
        {
            Vendor.ClearAll();
            string name01        = "Susie's Cafe";
            string description01 = "Description";
            string name02        = "Pete's bakery";
            string description02 = "Another description";
            Vendor newVendor1    = new Vendor(name01, description01);
            Vendor newVendor2    = new Vendor(name02, description02);

            Vendor.Delete(1);
            List <Vendor> vendors = Vendor.GetAll();

            Assert.AreEqual(1, vendors.Count);
        }
        public void GetId_VendorsInstantiateWithAnIdAndGetterReturns_Int()
        {
            //Arrange

            string name        = "Suzie's Cafe";
            string description = "Some description";
            Vendor newVendor   = new Vendor(name, description);

            Vendor.ClearAll();

            //Act
            int result = newVendor.Id;

            //Assert
            Assert.AreEqual(0, result);
        }
        public void Find_ReturnsCorrectVendor_Vendor()
        {
            //Arrange
            Vendor.ClearAll();
            string name01        = "Susie's Cafe";
            string description01 = "Description";
            string name02        = "Pete's bakery";
            string description02 = "Another description";
            Vendor newVendor1    = new Vendor(name01, description01);
            Vendor newVendor2    = new Vendor(name02, description02);

            //Act
            Vendor result = Vendor.Find(1);

            //Assert
            Assert.AreEqual(newVendor2, result);
        }
示例#13
0
        public void ClearAll_ClearsAllVendors_Int()
        {
            string name1        = "Howl Jenkins Pendragon";
            string address1     = "111 Howl's Moving Castle, Ingary";
            string description1 = "A castle that moves, good luck with the delivery!";
            string name2        = "Haku";
            string address2     = "Yubaba's Bathhouse";
            string description2 = "A nice vacation spot, but don't sign any contracts!";
            Vendor newVendor1   = new Vendor(name1, address1, description1);
            Vendor newVendor2   = new Vendor(name2, address2, description2);
            int    beforeClear  = Vendor.GetAll().Count;

            Assert.AreEqual(2, beforeClear);
            Vendor.ClearAll();
            int result = Vendor.GetAll().Count;

            Assert.AreEqual(0, result);
        }
示例#14
0
 public void Dispose()
 {
     Vendor.ClearAll();
     Vendor.ClearCurrentId();
 }
 public void Dispose()
 {
     Vendor.ClearAll();
 }
示例#16
0
 public ActionResult DeleteAll()
 {
     Vendor.ClearAll();
     return(View());
 }
 public ActionResult DeleteAllVendors()
 {
     Vendor.ClearAll();
     return(RedirectToAction("Index"));
 }
示例#18
0
 public void TearDown()
 {
     Vendor.ClearAll();
 }
 public void Dispose()
 {
     Vendor.ClearAll();
     Vendor.ClearIdCount();
 }
 public void Dispose()
 {
     Order.ClearAll();
     Vendor.ClearAll();
 }
示例#21
0
 public void Cleanup()
 {
     Vendor.ClearAll();
 }