示例#1
0
        public async Task TestGet()
        {
            using (var context = new SocialBackendContext(options))
            {
                // Given
                i = 0; //
                string username = usernames[i];
                string password = passwords[i];

                //When
                ICookieService   fakeCookie     = new FakeCookieService();
                TodoesController todoController = new TodoesController(context, fakeCookie);
                var result = await todoController.GetTodo() as IActionResult;

                // Then
                Assert.IsNotNull(result);
                Assert.IsInstanceOfType(result, typeof(OkObjectResult));

                var okObject = result as OkObjectResult;
                var todo     = okObject.Value as List <Todo>;

                Assert.IsNotNull(todo);
                Assert.IsTrue(todo.Count == 1);
                Assert.AreEqual(2, context.Todo.Count());
            }
        }
示例#2
0
        public async Task TestNoCookieGet()
        {
            using (var context = new SocialBackendContext(options))
            {
                // Given
                i = 3; //
                string username = usernames[i];
                string password = passwords[i];

                //When
                ICookieService   fakeCookie     = new FakeCookieService();
                TodoesController todoController = new TodoesController(context, fakeCookie);
                var result = await todoController.GetTodo();

                // Then
                Assert.IsNotNull(result);
                Assert.IsInstanceOfType(result, typeof(UnauthorizedResult));
                Assert.AreEqual(2, context.Todo.Count());
            }
        }