public async Task InvalidFormReturnsBadRequest()
        {
            var formByteArray = ToByteArray(new ContactFormRequestModel());

            _req.Setup(x => x.Body).Returns(new MemoryStream(formByteArray));

            var expected = new BadRequestObjectResult("");
            var actual   = await _sut.Run(_req.Object, _log.Object, _context.Object);

            Assert.Equal(expected.GetType(), actual.GetType());
        }
        public void TestLoginIsFailed()
        {
            User        user   = new User();
            Task <bool> result = Task.FromResult(false);

            _userManager.CheckPasswordAsync(user, "password").Returns(result);

            var expected = new BadRequestObjectResult(new BadRequestResult());
            var actual   = _loginController.Login(_login).Result;

            Assert.AreEqual(expected.GetType(), actual.GetType());
        }
        public async Task BadRequestObjectResultReturnsWhenGuidInvalid()
        {
            var req         = new Mock <HttpRequest>();
            var queryString = new Dictionary <string, StringValues>()
            {
                { "id", "invalidGuid" }
            };

            req.Setup(x => x.Query).Returns(new QueryCollection(queryString));

            var expected = new BadRequestObjectResult("");
            var actual   = await _sut.Run(req.Object, _loggerMock.Object);

            Assert.True(expected.GetType() == actual.GetType());
        }
Ejemplo n.º 4
0
        public async Task LoginUser()
        {
            var u = new LoginModel
            {
                Email    = "*****@*****.**",
                Password = "******"
            };
            var ok       = new OkObjectResult(null);
            var resultOk = await _userController.Login(u);

            Assert.Equal(ok.GetType(), resultOk.GetType());

            u.Password = "******";
            var bad = new BadRequestObjectResult(new { message = "Emails or password is incorrect!" });

            var resultBad = await _userController.Login(u);

            Assert.Equal(bad.GetType(), resultBad.GetType());
            Assert.NotEqual(resultOk.GetType(), resultBad.GetType());
        }
        public async Task InvalidRequestReturnsBadRequest()
        {
            var locationDetailsRequestModel = new LocationDetailsRequestModel
            {
                Address           = new Shared.Models.AddressModel {
                },
                AssignedGamesList = new List <AssignedGamesRequestModel>(),
                BusinessHoursList = new List <BusinessHoursRequestModel>(),
                ImageUrlList      = new List <string>(),
                PhoneNumberList   = new List <string>(),
            };

            var formByteArray = ToByteArray(locationDetailsRequestModel);

            _httpRequest.Setup(x => x.Body).Returns(new MemoryStream(formByteArray));

            var expected = new BadRequestObjectResult("");
            var actual   = await _sut.Run(_httpRequest.Object, _log.Object);

            Assert.Equal(expected.GetType(), actual.GetType());
        }