Exemple #1
0
        public void ProcessUser_HappyPathTest()
        {
            var tgimbaApi = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object);

            var request       = GetLoginRequest();
            var tokenToReturn = "token";

            tgimbaService.Setup(x => x.ProcessUser
                                    (It.Is <string>(s => s == request.EncodedUserName),
                                    It.Is <string>(s => s == request.EncodedPassword)
                                    )).Returns(tokenToReturn);

            IActionResult  result        = tgimbaApi.ProcessUser(request);
            OkObjectResult requestResult = (OkObjectResult)result;

            Assert.IsNotNull(requestResult);
            Assert.AreEqual(200, requestResult.StatusCode);
            tgimbaService.Verify(x => x.ProcessUser
                                     (It.Is <string>(s => s == request.EncodedUserName),
                                     It.Is <string>(s => s == request.EncodedPassword)
                                     ), Times.Once);
            var token = (string)requestResult.Value;

            Assert.AreEqual(tokenToReturn, token);
        }
Exemple #2
0
        public void ProcessUser_GeneralErrorTest()
        {
            var tgimbaApi = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object);

            var request = GetLoginRequest();

            tgimbaService.Setup(x => x.ProcessUser
                                    (It.IsAny <string>(), It.IsAny <string>()))
            .Throws(new Exception("I am an exception"));

            IActionResult result = tgimbaApi.ProcessUser(request);

            BadResultVerify(result, 500);
        }
Exemple #3
0
        public void ProcessUser_ValidationErrorTest()
        {
            var tgimbaApi = new SharedTgimbaApiController(this.tgimbaService.Object, this.validationHelper.Object);

            var request = GetLoginRequest();

            validationHelper.Setup(x => x.IsValidRequest
                                       (It.IsAny <LoginRequest>()))
            .Throws(new ArgumentNullException(""));

            IActionResult result = tgimbaApi.ProcessUser(request);

            BadResultVerify(result);
            tgimbaService.Verify(x => x.ProcessUser(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }