Exemplo n.º 1
0
        public void i_can_compare_parameter_location_field(
            [Values(null, ParameterLocation.Cookie, ParameterLocation.Header, ParameterLocation.Path,
                    ParameterLocation.Query)]
            ParameterLocation?previous
            , [Values(null, ParameterLocation.Cookie, ParameterLocation.Header, ParameterLocation.Path,
                      ParameterLocation.Query)]
            ParameterLocation?actual)
        {
            const string parameterName = "parameter01";
            var          context       = ComparisonContext.FromPath("/path") with {
                Request = parameterName
            };
            var previousParameter = new OpenApiParameter()
            {
                In = previous
            };
            var actualParameter = new OpenApiParameter()
            {
                In = actual
            };
            var diffs = previousParameter.CompareTo(actualParameter, context).ToArray();

            Assert.AreEqual(previous == actual ? 0 : 1, diffs.Length, "unexpected differences count");
            foreach (DiffResult diff in diffs)
            {
                Assert.AreEqual(context, diff.Context, "unexpected context");
                TestContext.Progress.WriteLine($"[{diff.Context}] {diff.Kind}: '{diff.Message}'");
            }
        }
Exemplo n.º 2
0
        public void i_can_compare_parameter_boolean_fields(OpenApiParameter previous, OpenApiParameter actual,
                                                           int expectedDiff)
        {
            const string parameterName = "parameter01";
            var          context       = ComparisonContext.FromPath("/path") with {
                Request = parameterName
            };
            var diffs = previous.CompareTo(actual, context).ToArray();

            foreach (DiffResult diff in diffs)
            {
                TestContext.Progress.WriteLine($"[{diff.Context}] {diff.Kind}: '{diff.Message}'");
            }
            Assert.AreEqual(expectedDiff, diffs.Length, "unexpected differences count");
        }