コード例 #1
0
ファイル: UrlTests.cs プロジェクト: aidancasey/Moksy
        public void OneConditionMatchesCaseInsensitivePartialValue()
        {
            SimulationCondition c = new SimulationCondition();
            c.Parameter("A", "bcD", ComparisonType.PartialValue | ComparisonType.CaseInsensitive, ParameterType.UrlParameter);

            Assert.IsTrue(Evaluator.MatchesUrlParameters(c, "A=bcD"));
        }
コード例 #2
0
ファイル: Simulation.cs プロジェクト: aidancasey/Moksy
        /// <summary>
        /// Constructor. 
        /// </summary>
        public Simulation()
        {
            Name = "Simulation" + System.Guid.NewGuid().ToString();

            Condition = new SimulationCondition();
            Response = new SimulationResponse();
        }
コード例 #3
0
ファイル: BodyTests.cs プロジェクト: aidancasey/Moksy
        public void NoBodyParametersMatches()
        {
            List<Parameter> ps = new List<Parameter>();

            SimulationCondition c = new SimulationCondition();

            Assert.IsTrue(Evaluator.Matches(c, ps));
        }
コード例 #4
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void HeaderAndValueConditionNotExistsButNotExists()
        {
            List<Header> headers = new List<Header>();

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader", "TheValue", ComparisonType.NotExists);

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #5
0
ファイル: BodyTests.cs プロジェクト: aidancasey/Moksy
        public void OneParameterButNoCondition()
        {
            List<Parameter> ps = new List<Parameter>();
            ps.Add(new Parameter("thename2", "thevalue2"));

            SimulationCondition c = new SimulationCondition();

            Assert.IsTrue(Evaluator.Matches(c, ps));
        }
コード例 #6
0
ファイル: BodyTests.cs プロジェクト: aidancasey/Moksy
        public void OneConditionButNoParameters()
        {
            List<Parameter> ps = new List<Parameter>();

            SimulationCondition c = new SimulationCondition();
            c.Parameter("thename", "thevalue");

            Assert.IsFalse(Evaluator.Matches(c, ps));
        }
コード例 #7
0
        public void ContentWithPairMatchesBecauseNoParameters()
        {
            // Will always match
            SimulationConditionEvaluator e = new SimulationConditionEvaluator();
            SimulationCondition c = new SimulationCondition();

            System.Net.Http.HttpContent content = new System.Net.Http.StringContent("a=b", Encoding.UTF8, "application/json");

            Assert.IsTrue(e.MatchesBodyParameters(c, content));
        }
コード例 #8
0
ファイル: BodyTests.cs プロジェクト: aidancasey/Moksy
        public void ExactlyOneParameterMatch()
        {
            List<Parameter> ps = new List<Parameter>();
             ps.Add(new Parameter("thename", "thevalue"));

            SimulationCondition c = new SimulationCondition();
            c.Parameter("thename", "thevalue");

            Assert.IsTrue(Evaluator.Matches(c, ps));
        }
コード例 #9
0
        public void ContentWithOneOfTwoMatchingPairMatches()
        {
            // Will always match
            SimulationConditionEvaluator e = new SimulationConditionEvaluator();
            SimulationCondition c = new SimulationCondition();
            c.Parameter("c", "d");
            c.Parameter("a", "b");

            System.Net.Http.HttpContent content = new System.Net.Http.StringContent("a=b", Encoding.UTF8, "application/json");

            Assert.IsFalse(e.MatchesBodyParameters(c, content));
        }
コード例 #10
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void OneConditionMatchesAgainstTwoSecond()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));
            headers.Add(new Header("TheHeader2", "TheValue2"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader2", "TheValue2");

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #11
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void TwoConditionsSameHeaderNameDifferentValuesMatchesLast()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue1"));
            headers.Add(new Header("TheHeader", "TheValue2"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader", "TheValue2");

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #12
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
 public void EmptyHeadersAndConditionAlwaysMatches()
 {
     List<Header> headers = new List<Header>();
     SimulationCondition c = new SimulationCondition();
     Assert.IsTrue(Evaluator.Matches(c, headers));
 }
コード例 #13
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void OneHeaderOnlyUrlEncodedNotMatch()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheH%2feader", "TheValue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheH/eader", ComparisonType.Exists);

            Assert.IsFalse(Evaluator.Matches(c, headers));
        }
コード例 #14
0
ファイル: UrlTests.cs プロジェクト: aidancasey/Moksy
        public void NoConditionParametersOneInQuery()
        {
            SimulationCondition c = new SimulationCondition();

            Assert.IsTrue(Evaluator.MatchesUrlParameters(c, "a=b"));
        }
コード例 #15
0
ファイル: UrlTests.cs プロジェクト: aidancasey/Moksy
        public void OneConditionWithEncoding()
        {
            SimulationCondition c = new SimulationCondition();
            c.Parameter("d/e", "f/g", ComparisonType.UrlEncode, ParameterType.UrlParameter);

            Assert.IsTrue(Evaluator.MatchesUrlParameters(c, "d%2fe=f%2fg"));
        }
コード例 #16
0
ファイル: Proxy.cs プロジェクト: aidancasey/Moksy
 public HttpStatusCode Add(SimulationCondition condition)
 {
     if (null == condition) throw new System.ArgumentNullException("condition");
     if (null == condition.Simulation) throw new System.ArgumentOutOfRangeException("ERROR: The .Simulation property on condition must reference the owner Simulation. ");
     return Add(condition.Simulation);
 }
コード例 #17
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void HeaderAndValueImplicitExists()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader", "TheValue");

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #18
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void NullHeadersAlwaysMatches()
        {
            SimulationCondition c = new SimulationCondition();
            Assert.IsTrue(Evaluator.Matches(c, (IEnumerable<Header>) null));

            c.Header("TheHeader", "Woo");
            Assert.IsTrue(Evaluator.Matches(c, (IEnumerable<Header>)null));
        }
コード例 #19
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void HeaderPartialValueMatchCaseSensitive()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader", "eVal", ComparisonType.PartialValue);

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #20
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void HeaderOnlyNotExistsImplicitNoHeaders()
        {
            List<Header> headers = new List<Header>();

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader");

            Assert.IsFalse(Evaluator.Matches(c, headers));
        }
コード例 #21
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void HeaderAndValueImplicitNoneIsSkipped()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader", "TheValue", Persistence.None);

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #22
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void OneHeaderAndValueOnlyUrlEncodedMatch()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheH%2feader", "TheV%2falue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheH/eader", "TheV/alue", ComparisonType.Exists | ComparisonType.UrlEncode);

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #23
0
ファイル: UrlTests.cs プロジェクト: aidancasey/Moksy
        public void OneConditionWithBodyParameterDoesNotMatch()
        {
            SimulationCondition c = new SimulationCondition();
            c.Parameter("d", "e", ParameterType.BodyParameter);
            c.Parameter("g", "h", ParameterType.UrlParameter);

            Assert.IsFalse(Evaluator.MatchesUrlParameters(c, "d=e"));
        }
コード例 #24
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void OneHeaderDoesMatchIfThereAreNoHeadersInTheCondition()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));

            SimulationCondition c = new SimulationCondition();

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #25
0
ファイル: UrlTests.cs プロジェクト: aidancasey/Moksy
        public void OneConditionWithoutEncoding()
        {
            SimulationCondition c = new SimulationCondition();
            c.Parameter("d/e", "f/g", ParameterType.UrlParameter);

            Assert.IsFalse(Evaluator.MatchesUrlParameters(c, "d%2fe=f%2fg"));
        }
コード例 #26
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void OneHeaderExistsComparison()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader", "TheValue", ComparisonType.Exists);

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #27
0
ファイル: UrlTests.cs プロジェクト: aidancasey/Moksy
        public void NoUrlParametersNullQuery()
        {
            SimulationCondition c = new SimulationCondition();

            Assert.IsTrue(Evaluator.MatchesUrlParameters(c, null));
        }
コード例 #28
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void OneHeaderMatchesCaseSensitive()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHeader", "TheValue");

            Assert.IsTrue(Evaluator.Matches(c, headers));
        }
コード例 #29
0
ファイル: UrlTests.cs プロジェクト: aidancasey/Moksy
        public void OneConditionMatchesCaseSensitiveFails()
        {
            SimulationCondition c = new SimulationCondition();
            c.Parameter("A", "b", ParameterType.UrlParameter);

            Assert.IsFalse(Evaluator.MatchesUrlParameters(c, "a=b"));
        }
コード例 #30
0
ファイル: HeaderTests.cs プロジェクト: aidancasey/Moksy
        public void OneHeaderOnlyExistsComparisonCaseSensitive2()
        {
            List<Header> headers = new List<Header>();
            headers.Add(new Header("TheHeader", "TheValue"));

            SimulationCondition c = new SimulationCondition();
            c.Header("TheHEader", ComparisonType.Exists | ComparisonType.CaseSensitive);

            Assert.IsFalse(Evaluator.Matches(c, headers));
        }