Ejemplo n.º 1
0
        public async Task AndPredicateExample()
        {
            var imposter = _client.CreateTcpImposter(4554, "AndPredicateExample");

            var startsWithFields = new TcpPredicateFields {
                Data = "start"
            };
            var startsWith = new StartsWithPredicate <TcpPredicateFields>(startsWithFields);

            var endsWithFields = new TcpPredicateFields {
                Data = "end\n"
            };
            var endsWith = new EndsWithPredicate <TcpPredicateFields>(endsWithFields);

            var containsFields = new TcpPredicateFields {
                Data = "middle"
            };
            var contains = new ContainsPredicate <TcpPredicateFields>(containsFields);

            var predicate = new AndPredicate(new List <PredicateBase> {
                startsWith, endsWith, contains
            });

            imposter.AddStub().On(predicate)
            .ReturnsData("matches");

            await _client.SubmitAsync(imposter);
        }
Ejemplo n.º 2
0
        public void Constructor_SetsFieldObject()
        {
            var expectedFields = new TestPredicateFields();
            var predicate      = new StartsWithPredicate <TestPredicateFields>(expectedFields);

            Assert.AreSame(expectedFields, predicate.Fields);
        }
Ejemplo n.º 3
0
        public void Constructor_SetsCaseSensitivity()
        {
            var fields    = new TestPredicateFields();
            var predicate = new StartsWithPredicate <TestPredicateFields>(fields, true, null, null);

            Assert.IsTrue(predicate.IsCaseSensitive);
        }
        public void Constructor_SetsXpathSelector()
        {
            var expectedXPathSelector = new XPathSelector("!$");

            var fields = new TestPredicateFields();
            var predicate = new StartsWithPredicate<TestPredicateFields>(fields, false, null, expectedXPathSelector);
            Assert.AreEqual(expectedXPathSelector, predicate.Selector);
        }
        public void Constructor_SetsExceptExpression()
        {
            const string expectedExceptRegex = "!$";

            var fields = new TestPredicateFields();
            var predicate = new StartsWithPredicate<TestPredicateFields>(fields, false, expectedExceptRegex, null);
            Assert.AreEqual(expectedExceptRegex, predicate.ExceptExpression);
        }
Ejemplo n.º 6
0
        public void Constructor_SetsXpathSelector()
        {
            var expectedXPathSelector = new XPathSelector("!$");

            var fields    = new TestPredicateFields();
            var predicate = new StartsWithPredicate <TestPredicateFields>(fields, false, null, expectedXPathSelector);

            Assert.AreEqual(expectedXPathSelector, predicate.Selector);
        }
Ejemplo n.º 7
0
        public void Constructor_SetsExceptExpression()
        {
            const string expectedExceptRegex = "!$";

            var fields    = new TestPredicateFields();
            var predicate = new StartsWithPredicate <TestPredicateFields>(fields, false, expectedExceptRegex, null);

            Assert.AreEqual(expectedExceptRegex, predicate.ExceptExpression);
        }
Ejemplo n.º 8
0
        public void StartsWithPredicate_Constructor_SetsJsonPathSelector()
        {
            var expectedJsonPathSelector = new JsonPathSelector("$..title");

            var fields    = new TestPredicateFields();
            var predicate = new StartsWithPredicate <TestPredicateFields>(fields, jsonpath: expectedJsonPathSelector);

            Assert.AreEqual(expectedJsonPathSelector, predicate.JsonPathSelector);
        }
 public void Constructor_SetsFieldObject()
 {
     var expectedFields = new TestPredicateFields();
     var predicate = new StartsWithPredicate<TestPredicateFields>(expectedFields);
     Assert.AreSame(expectedFields, predicate.Fields);
 }
Ejemplo n.º 10
0
 public void Constructor_SetsCaseSensitivity()
 {
     var fields = new TestPredicateFields();
     var predicate = new StartsWithPredicate<TestPredicateFields>(fields, true, null, null);
     Assert.IsTrue(predicate.IsCaseSensitive);
 }