Beispiel #1
0
        public void UserLogin_InvalidLoginData_ShouldReturn400_BadRequest()
        {
            // Arrange
            TestingEngine.CleanDatabase();

            // Act -> empty username
            var responseEmptyUsername = TestingEngine.LoginUserHttpPost("", "#paSSw@rd12345");

            // Assert -> 400 (Bad Request)
            Assert.AreEqual(HttpStatusCode.BadRequest, responseEmptyUsername.StatusCode);

            // Act -> empty password
            var responseEmptyPassword = TestingEngine.LoginUserHttpPost("maria", "");

            // Assert -> 400 (Bad Request)
            Assert.AreEqual(HttpStatusCode.BadRequest, responseEmptyPassword.StatusCode);

            // Act -> null username
            var responseNullUsername = TestingEngine.LoginUserHttpPost(null, "#paSSw@rd12345");

            // Assert -> 400 (Bad Request)
            Assert.AreEqual(HttpStatusCode.BadRequest, responseNullUsername.StatusCode);

            // Act -> null password
            var responseNullPassword = TestingEngine.LoginUserHttpPost("maria", null);

            // Assert -> 400 (Bad Request)
            Assert.AreEqual(HttpStatusCode.BadRequest, responseNullPassword.StatusCode);

            // Act -> no data (empty HTTP body)
            var httpResponse = TestingEngine.HttpClient.PostAsync("/api/user/login", null).Result;

            // Assert -> 400 (Bad Request)
            Assert.AreEqual(HttpStatusCode.BadRequest, httpResponse.StatusCode);
        }
Beispiel #2
0
        public void UserLogin_InvalidUser_ShouldReturn400_BadRequest()
        {
            // Arrange
            TestingEngine.CleanDatabase();
            var username = "******";
            var password = "******";

            // Act
            var loginResponse = TestingEngine.LoginUserHttpPost(username, password);

            // Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, loginResponse.StatusCode);
        }