コード例 #1
0
        public void GetOrderDetailsByOrderID_InvalidID()
        {
            #region ASSIGN

            OrderDetailsRepo          testRepo       = new OrderDetailsRepo();
            OrderDetailsApiController testController = new OrderDetailsApiController(testRepo);

            #endregion

            #region ACT

            var taskReturn = testController.GetDetailsOfAnOrder(2);
            taskReturn.Wait();
            var result = taskReturn.Result.Value;

            List <OrderDetail> testResult = result;

            #endregion

            #region ASSERT

            Assert.AreNotEqual(testResult.Count, 2);

            Assert.AreNotEqual(testResult[0].Id, 1);
            Assert.AreNotEqual(testResult[0].OrdersId, 1);
            Assert.AreNotEqual(testResult[0].Price, 7.99M);
            Assert.AreNotEqual(testResult[0].SizeId, 1);
            Assert.AreNotEqual(testResult[0].SpecialRequest, "Special A");
            Assert.AreNotEqual(testResult[0].ToppingsCount, 2);
            Assert.AreNotEqual(testResult[0].ToppingsSelected, "TopA,TopB");

            #endregion
        }
コード例 #2
0
        public void GetOrderDetailsByOrderID_NonExistingID()
        {
            #region ASSIGN

            OrderDetailsRepo          testRepo       = new OrderDetailsRepo();
            OrderDetailsApiController testController = new OrderDetailsApiController(testRepo);

            #endregion

            #region ACT

            var taskReturn = testController.GetDetailsOfAnOrder(0);
            taskReturn.Wait();
            var result = taskReturn.Result.Result;

            #endregion

            #region ASSERT

            Assert.IsTrue(result is NotFoundResult);
            Assert.AreEqual((result as NotFoundResult).StatusCode, 404);

            #endregion
        }