public void HttpStub_ReturnsProxy_ReturnsHttpProxyStub() { var predicateInvokingProxyStub = new ContainsPredicate <HttpPredicateFields>(new HttpPredicateFields { Path = "/aTestPath" }); var proxyGeneratorPredicate = new MatchesPredicate <HttpPredicateFields>(new HttpPredicateFields { Path = "/aTestPath", Method = Method.Get, QueryParameters = new Dictionary <string, string> { { "q", "value" } } }); var proxyToUrl = new Uri("http://someTestDestination.com"); var proxyModeToUse = ProxyMode.ProxyTransparent; var stub = new HttpStub(); stub.On(predicateInvokingProxyStub) .ReturnsProxy(proxyToUrl, proxyModeToUse, new [] { proxyGeneratorPredicate }); var proxyResponse = stub.Responses.First() as ProxyResponse <ProxyResponseFields <HttpPredicateFields> >; Assert.AreEqual(proxyToUrl, proxyResponse.Fields.To); Assert.AreEqual(proxyModeToUse, proxyResponse.Fields.Mode); Assert.AreEqual(proxyGeneratorPredicate, proxyResponse.Fields.PredicateGenerators.First()); }
public void MatchesPredicate_Constructor_SetsFieldObject() { var expectedFields = new TestPredicateFields(); var predicate = new MatchesPredicate <TestPredicateFields>(expectedFields); Assert.AreSame(expectedFields, predicate.Fields); }
public void MatchesPredicate_Constructor_SetsCaseSensitivity() { var fields = new TestPredicateFields(); var predicate = new MatchesPredicate <TestPredicateFields>(fields, isCaseSensitive: true); Assert.IsTrue(predicate.IsCaseSensitive); }
public void TcpStub_ReturnsProxy_ReturnsTcpBooleanProxyStub() { var predicateInvokingProxyStub = new ContainsPredicate <TcpPredicateFields>(new TcpPredicateFields { Data = "123345" }); var proxyGeneratorPredicate = new MatchesPredicate <TcpBooleanPredicateFields>(new TcpBooleanPredicateFields { Data = true }); var proxyToUrl = new Uri("tcp://someTestDestination.com"); var proxyModeToUse = ProxyMode.ProxyTransparent; var stub = new TcpStub(); stub.On(predicateInvokingProxyStub) .ReturnsProxy(proxyToUrl, proxyModeToUse, new [] { proxyGeneratorPredicate }); var proxyResponse = stub.Responses.First() as ProxyResponse <ProxyResponseFields <TcpBooleanPredicateFields> >; Assert.AreEqual(proxyToUrl, proxyResponse.Fields.To); Assert.AreEqual(proxyModeToUse, proxyResponse.Fields.Mode); Assert.AreEqual(proxyGeneratorPredicate, proxyResponse.Fields.PredicateGenerators.First()); }
public void Constructor_SetsXpathSelector() { var expectedXPathSelector = new XPathSelector("!$"); var fields = new TestPredicateFields(); var predicate = new MatchesPredicate<TestPredicateFields>(fields, false, null, expectedXPathSelector); Assert.AreEqual(expectedXPathSelector, predicate.Selector); }
public void Constructor_SetsExceptExpression() { const string expectedExceptRegex = "!$"; var fields = new TestPredicateFields(); var predicate = new MatchesPredicate<TestPredicateFields>(fields, false, expectedExceptRegex, null); Assert.AreEqual(expectedExceptRegex, predicate.ExceptExpression); }
public void MatchesPredicate_Constructor_SetsJsonPathSelector() { var expectedJsonPathSelector = new JsonPathSelector("$..title"); var fields = new TestPredicateFields(); var predicate = new MatchesPredicate <TestPredicateFields>(fields, jsonpath: expectedJsonPathSelector); Assert.AreEqual(expectedJsonPathSelector, predicate.JsonPathSelector); }
public void MatchesPredicate_Constructor_SetsXpathSelector() { var expectedXPathSelector = new XPathSelector("!$"); var fields = new TestPredicateFields(); var predicate = new MatchesPredicate <TestPredicateFields>(fields, xpath: expectedXPathSelector); Assert.AreEqual(expectedXPathSelector, predicate.XPathSelector); }
public void MatchesPredicate_Constructor_SetsExceptExpression() { const string expectedExceptRegex = "!$"; var fields = new TestPredicateFields(); var predicate = new MatchesPredicate <TestPredicateFields>(fields, exceptExpression: expectedExceptRegex); Assert.AreEqual(expectedExceptRegex, predicate.ExceptExpression); }
public async Task JsonExample() { var imposter = _client.CreateHttpImposter(4545, "JsonExample"); var caseSensitiveFields = new HttpPredicateFields { RequestBody = new Book { Title = "Harry Potter" } }; var caseSensitivePredicate = new EqualsPredicate <HttpPredicateFields>(caseSensitiveFields, true, null, null); var exceptFields = new HttpPredicateFields { RequestBody = new Book { Title = "POTTER" } }; var exceptPredicate = new EqualsPredicate <HttpPredicateFields>(exceptFields, false, "HARRY ", null); var matchesFields = new HttpPredicateFields { RequestBody = new Book { Title = "^Harry" } }; var matchesPredicate = new MatchesPredicate <HttpPredicateFields>(matchesFields); // Exists examples not provided since MbDotNet does not yet support checking specific object keys imposter.AddStub() .On(caseSensitivePredicate) .On(exceptPredicate) .On(matchesPredicate) .ReturnsJson(HttpStatusCode.OK, new BookResponse { Code = "SUCCESS", Author = "J.K. Rowling" }); await _client.SubmitAsync(imposter); }
public void Constructor_SetsFieldObject() { var expectedFields = new TestPredicateFields(); var predicate = new MatchesPredicate<TestPredicateFields>(expectedFields); Assert.AreSame(expectedFields, predicate.Fields); }
public void Constructor_SetsCaseSensitivity() { var fields = new TestPredicateFields(); var predicate = new MatchesPredicate<TestPredicateFields>(fields, true, null, null); Assert.IsTrue(predicate.IsCaseSensitive); }