Beispiel #1
0
        //TEST:  WEBAPI_MARKORDERSHIPPED_TEST
        //Test the functionality of the WebAPI MarkOrderShipped method using test data.
        public void WebAPI_MarkOrderShipped_Test()
        {
            MyDataEntities          db = new MyDataEntities();
            OrderShippingController os = new OrderShippingController();

            //ARRANGE
            //Grab the test user that we created in SqlSecurityManager_RegisterUser and find their UserID
            var userArray  = db.Users.Where(x => x.UserName == "testRegisterUser").ToList();
            int testUserID = 0;

            foreach (var item in userArray)
            {
                testUserID = item.UserID;
            }

            //Use the UserID to find the list of Orders owned by this User (Should cotnain 1 order) and return the OrderID
            var list        = db.Orders.Where(x => x.UserID == testUserID).ToList();
            int testOrderID = 0;

            foreach (var item in list)
            {
                testOrderID = item.OrderID;
            }
            //ACT
            string result = os.MarkOrderShipped(testOrderID);

            //ASSERT
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Equals("Order Status set to: Order Shipped"));
        }
Beispiel #2
0
        //TEST:  WEBAPI_MARKORDERSHIPPED_FAILURETEST
        //Test the functionality of the WebAPI MarkOrderShipped method when using unintended test data.
        //When given an integer that does not match an order in the DB (this could be a negative number or simply a number not
        // associated with an order) The method will simply return a string that says: "Failure: No Order Found"
        public void WebAPI_MarkOrderShipped_FAILURETest()
        {
            MyDataEntities          db = new MyDataEntities();
            OrderShippingController os = new OrderShippingController();

            //ARRANGE

            //ACT
            string result = os.MarkOrderShipped(1);

            //ASSERT
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Equals("Failure: No Order Found"));
        }
Beispiel #3
0
        //TEST:  WEBAPI_GETORDERS_TEST
        //Test the functionality of the WebAPI GetOrders method using test data.
        public void WebAPI_GetOrders_Test()
        {
            MyDataEntities          db = new MyDataEntities();
            OrderShippingController os = new OrderShippingController();

            //ARRANGE
            db.SaveChanges();
            List <Order> list = new List <Order>();
            //This time value is equal to 1 minute and the purpose is to subtract the current time by 1 minutes and get all the orders created
            //within the last minute (we will only find our test order)
            TimeSpan time      = new TimeSpan(0, 1, 0);
            DateTime startDate = DateTime.Now.Subtract(time);
            DateTime endDate   = DateTime.Now;

            //ACT
            list = os.GetOrders(startDate, endDate);
            //ASSERT
            Assert.IsNotNull(list);
            Assert.IsInstanceOfType(list, typeof(List <Order>));
            Assert.IsTrue(list.Count() == 1);
        }