IsMatch() публичный Метод

Determines whether the context of the HTTP request is match for the current instance.
public IsMatch ( IStumpsHttpContext context ) : bool
context IStumpsHttpContext The HTTP request.
Результат bool
Пример #1
0
        public void IsMatch_WithFailingRule_TriesAllRulesReturnsFalse()
        {
            var stump = new Stump("ABC");

            var context = Substitute.For <IStumpsHttpContext>();
            var request = Substitute.For <IStumpsHttpRequest>();

            context.Request.Returns(request);

            var rule1 = Substitute.For <IStumpRule>();

            rule1.IsMatch(request).Returns(true);

            var rule2 = Substitute.For <IStumpRule>();

            rule2.IsMatch(request).Returns(false);

            stump.AddRule(rule1);
            stump.AddRule(rule2);

            stump.Responds();

            var matches = stump.IsMatch(context);

            rule1.Received(1).IsMatch(request);
            rule2.Received(1).IsMatch(request);
            Assert.IsFalse(matches);
        }
Пример #2
0
        public void IsMatch_WithoutRules_ReturnsFalse()
        {
            var stump = new Stump("ABC");

            stump.Responds();

            Assert.IsFalse(stump.IsMatch(Substitute.For <IStumpsHttpContext>()));
        }
Пример #3
0
        public void IsMatch_WithNullResponse_ReturnsFalse()
        {
            var stump = new Stump("ABC");

            var rule1 = Substitute.For <IStumpRule>();

            rule1.IsMatch(null).Returns(true);

            stump.AddRule(rule1);

            Assert.IsFalse(stump.IsMatch(Substitute.For <IStumpsHttpContext>()));
        }
Пример #4
0
        public void IsMatch_WithResponseFactoryNoResponse_ReturnsFalse()
        {
            var stump = new Stump("ABC");

            var context = Substitute.For <IStumpsHttpContext>();
            var request = Substitute.For <IStumpsHttpRequest>();

            context.Request.Returns(request);

            var rule1 = Substitute.For <IStumpRule>();

            rule1.IsMatch(request).Returns(true);

            var matches = stump.IsMatch(context);

            rule1.DidNotReceive().IsMatch(request);
            Assert.IsFalse(matches);
        }
Пример #5
0
        public void IsMatch_WithFailingRule_TriesAllRulesReturnsFalse()
        {
            var stump = new Stump("ABC");

            var context = Substitute.For<IStumpsHttpContext>();
            var request = Substitute.For<IStumpsHttpRequest>();
            context.Request.Returns(request);

            var rule1 = Substitute.For<IStumpRule>();
            rule1.IsMatch(request).Returns(true);

            var rule2 = Substitute.For<IStumpRule>();
            rule2.IsMatch(request).Returns(false);

            stump.AddRule(rule1);
            stump.AddRule(rule2);

            stump.Response = new BasicHttpResponse();

            var matches = stump.IsMatch(context);
            rule1.Received(1).IsMatch(request);
            rule2.Received(1).IsMatch(request);
            Assert.IsFalse(matches);
        }
Пример #6
0
        public void IsMatch_WithoutRules_ReturnsFalse()
        {
            var stump = new Stump("ABC");
            stump.Response = new BasicHttpResponse();

            Assert.IsFalse(stump.IsMatch(Substitute.For<IStumpsHttpContext>()));
        }
Пример #7
0
        public void IsMatch_WithNullResponse_ReturnsFalse()
        {
            var stump = new Stump("ABC");

            var rule1 = Substitute.For<IStumpRule>();
            rule1.IsMatch(null).Returns(true);

            stump.AddRule(rule1);

            Assert.IsFalse(stump.IsMatch(Substitute.For<IStumpsHttpContext>()));
        }