Пример #1
0
        public async Task Returns404OnNoUser()
        {
            UserRepoMock   repo       = new UserRepoMock();
            UserController controller = new UserController {
                UserRepo = repo
            };

            Assert.AreEqual(404, ((await controller.Get(4)).Result as StatusCodeResult).StatusCode);
        }
Пример #2
0
        public async Task Update500sOnUnauthorized()
        {
            UserRepoMock   repo       = new UserRepoMock();
            UserController controller = new UserController {
                UserRepo = repo
            };
            ActionResult result = await controller.Update(new UserController.NewUser());

            Assert.AreEqual(401, (result as StatusCodeResult).StatusCode);
        }
Пример #3
0
        public async Task CanUpdateUser()
        {
            UserRepoMock   repo       = new UserRepoMock();
            UserController controller = new UserController {
                UserRepo = repo,
            };

            User lucca = new User("lucca", "lucca_is_lucca", "*****@*****.**");

            controller.Request.HttpContext.Items.Add("user", lucca);
            await controller.Update(new UserController.NewUser()
            {
                Description = "i am lucca"
            });

            Assert.AreEqual("i am lucca", lucca.Description);
        }
Пример #4
0
        public async Task ReturnsAUser()
        {
            UserRepoMock   repo       = new UserRepoMock();
            UserController controller = new UserController {
                UserRepo = repo
            };
            User lucca = new User("lucca", "lucca_is_lucca", "*****@*****.**");
            int  id    = 3;

            lucca.Id = id;
            repo.Users.Add(lucca);
            User expected = lucca;
            User actual   = (await controller.Get(id)).Value;

            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Username, actual.Username);
            Assert.AreEqual(expected.Email, actual.Email);
        }