Пример #1
0
        public void KhachHangNhanPhong_TestStatusResponse()
        {
            var khachHang     = "{\"IDPhong\":\"231\",\"HoVaTen\":\"Nguyễn Đức Tuấn Anh\",\"CMND\":\"231654465\"}";
            var action_result = controller.KhachHangNhanPhong(khachHang);
            //act
            var actual_result1   = action_result as OkNegotiatedContentResult <string>;
            var actual_result2   = action_result as BadRequestErrorMessageResult;
            var expected_result1 = "Nhận phòng thành công!";
            var expected_result2 = "Lỗi nhận phòng!";
            var expected_result3 = "Lỗi lưu CSDL!";

            //assert
            try
            {
                Assert.AreEqual(expected_result1, actual_result1.Content);
            }
            catch (Exception)
            {
                try
                {
                    Assert.AreEqual(expected_result2, actual_result2.Message);
                }
                catch (Exception)
                {
                    Assert.AreEqual(expected_result3, actual_result2.Message);
                }
            }
        }