Example #1
0
        public async Task StatusNull()
        {
            var userClaim = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.Name, "*****@*****.**"),
                new Claim(ClaimTypes.Email, "*****@*****.**")
            }, "mock"));

            var user = new ProProfsUser();

            user.Email = "*****@*****.**";
            this._mockAdapter.Setup(x => x.AddUserToQuiz(user)).ReturnsAsync(true);
            this._mockAdapter.Setup(x => x.QuizStatus(user.Email)).ReturnsAsync(user);
            this._mockUserRepository.Setup(x => x.AddUser(user)).ReturnsAsync(user);
            this._mockUserRepository.Setup(x => x.GetUser(string.Empty)).ReturnsAsync(user);
            var controller = new ProProfsController(this._mockAdapter.Object, this._mockUserRepository.Object);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = userClaim
                }
            };
            var result = await controller.Get();

            Assert.NotNull(result);
            Assert.Equal(user, result);
        }
Example #2
0
        public async Task Register()
        {
            var user = new ProProfsUser();

            user.Email = "*****@*****.**";
            this._mockAdapter.Setup(x => x.AddUserToQuiz(user)).ReturnsAsync(true);
            this._mockAdapter.Setup(x => x.QuizStatus(user.Email)).ReturnsAsync(user);
            this._mockUserRepository.Setup(x => x.AddUser(user)).ReturnsAsync(user);
            var controller = new ProProfsController(this._mockAdapter.Object, this._mockUserRepository.Object);
            var result     = await controller.PostQuiz(user);

            Assert.NotNull(result);
            Assert.Equal(user, result);
        }