Ejemplo n.º 1
0
        public void TryExtractUser_returns_false_if_method_is_not_post(FormUserExtractor sut, HttpContext httpContext)
        {
            Assume.That(httpContext.Request.Method, Is.Not.EqualTo("post").IgnoreCase);

            var result = sut.TryExtractUser(httpContext, out _);

            Assert.That(result, Is.False);
        }
Ejemplo n.º 2
0
        public void TryExtractUser_returns_false_if_body_does_not_contain_data(FormUserExtractor sut, HttpContext httpContext)
        {
            Mock.Get(httpContext.Request).SetupGet(p => p.Method).Returns(HttpMethods.Post);
            Mock.Get(httpContext.Request).SetupGet(p => p.HasFormContentType).Returns(false);

            var result = sut.TryExtractUser(httpContext, out _);

            Assert.That(result, Is.False);
        }
Ejemplo n.º 3
0
        public void TryExtractUser_returns_true_if_body_contain_data([Frozen] IFormCollection form, [Frozen] HttpRequest request, FormUserExtractor sut, HttpContext httpContext, User user)
        {
            Mock.Get(form).SetupGet(p => p["username"]).Returns(user.UserName);
            Mock.Get(form).SetupGet(p => p["password"]).Returns(user.Password);

            Mock.Get(request).SetupGet(p => p.Method).Returns(HttpMethods.Post);
            Mock.Get(request).SetupGet(p => p.HasFormContentType).Returns(true);
            Mock.Get(request).SetupGet(p => p.Form).Returns(form);

            var result = sut.TryExtractUser(httpContext, out _);

            Assert.That(result, Is.True);
        }