public void RecordMatcherRespectsVolatiledQueryParameters(string requestUri, string entryUri, bool includeVolatile, bool shouldMatch)
        {
            var matcher = new RecordMatcher();

            if (includeVolatile)
            {
                matcher.VolatileQueryParameters.Add("VolatileParam1");
                matcher.VolatileQueryParameters.Add("VolatileParam2");
            }

            var mockRequest = new RecordEntry()
            {
                RequestUri    = requestUri,
                RequestMethod = RequestMethod.Put,
            };

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri    = entryUri,
                    RequestMethod = RequestMethod.Put
                }
            };

            if (shouldMatch)
            {
                Assert.NotNull(matcher.FindMatch(mockRequest, entries));
            }
            else
            {
                Assert.Throws <TestRecordingMismatchException>(() => matcher.FindMatch(mockRequest, entries));
            }
        }
Beispiel #2
0
 /// <summary>
 /// Creates a new SearchTestBase instance.
 /// </summary>
 /// <param name="async">
 /// When false, we'll rewrite our tests methods to call the sync
 /// versions of async APIs.
 /// </param>
 /// <param name="serviceVersion">
 /// Version of the REST API to test against.
 /// </param>
 /// <param name="mode">
 /// Whether to run in Playback, Record, or Live mode.  The default
 /// value is pulled from the AZURE_TEST_MODE environment variable.
 /// </param>
 public SearchTestBase(bool async, SearchClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode = null)
     : base(async, mode ?? RecordedTestUtilities.GetModeFromEnvironment())
 {
     ServiceVersion = serviceVersion;
     Sanitizer      = new SearchRecordedTestSanitizer();
     Matcher        = new RecordMatcher(compareBodies: false);
 }
 public KeyResolverLiveTests(bool isAsync, KeyClientOptions.ServiceVersion serviceVersion)
     : base(isAsync, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
     _serviceVersion = serviceVersion;
     // TODO: https://github.com/Azure/azure-sdk-for-net/issues/11634
     Matcher = new RecordMatcher(compareBodies: false);
 }
Beispiel #4
0
        public void GenStringSanitizerQuietExitForAllHttpComponents()
        {
            var session          = TestHelpers.LoadRecordSession("Test.RecordEntries/post_delete_get_content.json");
            var untouchedSession = TestHelpers.LoadRecordSession("Test.RecordEntries/post_delete_get_content.json");

            var targetString         = ".*";
            var replacementString    = "<thistablehasbeenreplaced!>";
            var targetEntry          = session.Session.Entries[0];
            var targetUntouchedEntry = untouchedSession.Session.Entries[0];
            var matcher = new RecordMatcher();

            var sanitizer = new GeneralStringSanitizer(targetString, replacementString);

            session.Session.Sanitize(sanitizer);

            var resultRequestBody  = Encoding.UTF8.GetString(targetEntry.Request.Body);
            var resultResponseBody = Encoding.UTF8.GetString(targetEntry.Response.Body);
            var resultLocation     = targetEntry.Response.Headers["Location"].First().ToString();

            Assert.DoesNotContain(targetString, resultRequestBody);
            Assert.DoesNotContain(targetString, resultResponseBody);
            Assert.DoesNotContain(targetString, resultLocation);

            Assert.Equal(0, matcher.CompareHeaderDictionaries(targetUntouchedEntry.Request.Headers, targetEntry.Request.Headers, new HashSet <string>(), new HashSet <string>()));
            Assert.Equal(0, matcher.CompareHeaderDictionaries(targetUntouchedEntry.Response.Headers, targetEntry.Response.Headers, new HashSet <string>(), new HashSet <string>()));
            Assert.Equal(0, matcher.CompareBodies(targetUntouchedEntry.Request.Body, targetEntry.Request.Body));
            Assert.Equal(0, matcher.CompareBodies(targetUntouchedEntry.Response.Body, targetEntry.Response.Body));
            Assert.Equal(targetUntouchedEntry.RequestUri, targetEntry.RequestUri);
        }
Beispiel #5
0
 public BlobBatchClientTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
     // Batch delimiters are random so disable body comparison
     Matcher   = new RecordMatcher(compareBodies: false);
     Sanitizer = new BatchStorageRecordedTestSanitizer();
 }
Beispiel #6
0
 public CryptographyClientLiveTests(bool isAsync, KeyClientOptions.ServiceVersion serviceVersion)
     : base(isAsync, serviceVersion)
 {
     _serviceVersion = serviceVersion;
     // TODO: https://github.com/Azure/azure-sdk-for-net/issues/11634
     Matcher = new RecordMatcher(compareBodies: false);
 }
        public void RecordMatcherIgnoresIgnoredHeaders()
        {
            var matcher = new RecordMatcher(new RecordedTestSanitizer());

            MockRequest mockRequest = new MockRequest
            {
                Method = RequestMethod.Put
            };

            mockRequest.UriBuilder.Uri = new Uri("http://localhost");

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri     = "http://localhost",
                    RequestMethod  = RequestMethod.Put,
                    RequestHeaders =
                    {
                        { "Request-Id", new[] { "Non-Random value" } },
                    }
                }
            };

            Assert.NotNull(matcher.FindMatch(mockRequest, entries));
        }
        public void RecordMatcherIgnoresIgnoredHeaders()
        {
            var matcher = new RecordMatcher();

            var mockRequest = new RecordEntry()
            {
                RequestUri    = "http://localhost",
                RequestMethod = RequestMethod.Put,
            };

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri    = "http://localhost",
                    RequestMethod = RequestMethod.Put,
                    Request       =
                    {
                        Headers =
                        {
                            { "Request-Id", new[] { "Non-Random value" } },
                        }
                    }
                }
            };

            Assert.NotNull(matcher.FindMatch(mockRequest, entries));
        }
        protected KeyClientLiveTests(bool isAsync, KeyClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode)
            : base(isAsync, serviceVersion, mode)
        {
            _serviceVersion = serviceVersion;

            // TODO: https://github.com/Azure/azure-sdk-for-net/issues/11634
            Matcher = new RecordMatcher(compareBodies: false);
        }
Beispiel #10
0
        protected ConversationAnalysisTestBase(bool isAsync, ConversationAnalysisClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode)
            : base(isAsync, mode)
        {
            // TODO: Compare bodies again when https://github.com/Azure/azure-sdk-for-net/issues/22219 is resolved.
            Matcher = new RecordMatcher(compareBodies: false);

            Sanitizer      = new ConversationAnalysisRecordedTestSanitizer();
            ServiceVersion = serviceVersion;
        }
        public void SetMatcherForRecording(string recordingId, RecordMatcher matcher)
        {
            if (!PlaybackSessions.TryGetValue(recordingId, out var session))
            {
                throw new HttpException(HttpStatusCode.BadRequest, $"{recordingId} is not an active playback session. Check the value being passed and try again.");
            }

            session.CustomMatcher = matcher;
        }
        public void RecordMatcherThrowsExceptionsWithDetails()
        {
            var matcher = new RecordMatcher();

            var requestEntry = new RecordEntry()
            {
                RequestUri    = "http://localhost/",
                RequestMethod = RequestMethod.Head,
                Request       =
                {
                    Headers =
                    {
                        { "Content-Length",    new[] { "41"           } },
                        { "Some-Header",       new[] { "Random value" } },
                        { "Some-Other-Header", new[] { "V"            } }
                    },
                    Body    = Encoding.UTF8.GetBytes("This is request body, it's nice and long.")
                }
            };

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri    = "http://remote-host",
                    RequestMethod = RequestMethod.Put,
                    Request       =
                    {
                        Headers =
                        {
                            { "Content-Length", new[] { "41"               } },
                            { "Some-Header",    new[] { "Non-Random value" } },
                            { "Extra-Header",   new[] { "Extra-Value"      } }
                        },
                        Body    = Encoding.UTF8.GetBytes("This is request body, it's nice and long but it also doesn't match.")
                    }
                }
            };

            InvalidOperationException exception = Assert.Throws <InvalidOperationException>(() => matcher.FindMatch(requestEntry, entries));

            Assert.AreEqual(
                "Unable to find a record for the request HEAD http://localhost/" + Environment.NewLine +
                "Method doesn't match, request <HEAD> record <PUT>" + Environment.NewLine +
                "Uri doesn't match:" + Environment.NewLine +
                "    request <http://localhost/>" + Environment.NewLine +
                "    record  <http://remote-host>" + Environment.NewLine +
                "Header differences:" + Environment.NewLine +
                "    <Some-Header> values differ, request <Random value>, record <Non-Random value>" + Environment.NewLine +
                "    <Some-Other-Header> is absent in record, value <V>" + Environment.NewLine +
                "    <Extra-Header> is absent in request, value <Extra-Value>" + Environment.NewLine +
                "Body differences:" + Environment.NewLine +
                "Request and response bodies do not match at index 40:" + Environment.NewLine +
                "     request: \"e and long.\"" + Environment.NewLine +
                "     record:  \"e and long but it also doesn't\"" + Environment.NewLine,
                exception.Message);
        }
Beispiel #13
0
 public AzureClientAttributeFunctionalTests(bool isAsync) : base(isAsync)
 {
     Matcher = new RecordMatcher()
     {
         IgnoredQueryParameters =
         {
             // Ignore KeyVault client API Version when matching
             "api-version"
         }
     };
 }
Beispiel #14
0
        public void RecordMatcheRequiresPresenceOfIgnoredHeaders()
        {
            var matcher = new RecordMatcher();

            var mockRequest = new RecordEntry()
            {
                RequestUri    = "http://localhost",
                RequestMethod = RequestMethod.Put,
                Request       =
                {
                    // Request-Id and TraceParent are ignored until we can
                    // re-record all old tests.
                    Headers =
                    {
                        { "Request-Id", new[] { "Some Random value"             } },
                        { "Date",       new[] { "Fri, 06 Nov 2020 02:42:26 GMT" } },
                        { "x-ms-date",  new[] { "Fri, 06 Nov 2020 02:42:26 GMT" } },
                    }
                }
            };

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri    = "http://localhost",
                    RequestMethod = RequestMethod.Put,
                    Request       =
                    {
                        Headers =
                        {
                            { "x-ms-client-request-id", new[] { "some random request id"  } },
                            { "User-Agent",             new[] { "some random sdk"         } },
                            { "traceparent",            new[] { "some random traceparent" } }
                        }
                    }
                }
            };

            TestRecordingMismatchException exception = Assert.Throws <TestRecordingMismatchException>(() => matcher.FindMatch(mockRequest, entries));

            Assert.Equal(
                "Unable to find a record for the request PUT http://localhost" + Environment.NewLine +
                "Header differences:" + Environment.NewLine +
                "    <Date> is absent in record, value <Fri, 06 Nov 2020 02:42:26 GMT>" + Environment.NewLine +
                "    <x-ms-date> is absent in record, value <Fri, 06 Nov 2020 02:42:26 GMT>" + Environment.NewLine +
                "    <User-Agent> is absent in request, value <some random sdk>" + Environment.NewLine +
                "    <x-ms-client-request-id> is absent in request, value <some random request id>" + Environment.NewLine +
                "Body differences:" + Environment.NewLine,
                exception.Message);
        }
Beispiel #15
0
        public void UriStringSanitizerQuietlyExits(string targetValue, string replacementValue, string targetFile)
        {
            var session          = TestHelpers.LoadRecordSession(targetFile);
            var untouchedSession = TestHelpers.LoadRecordSession(targetFile);

            var targetEntry          = session.Session.Entries[0];
            var targetUntouchedEntry = untouchedSession.Session.Entries[0];
            var matcher = new RecordMatcher();

            var sanitizer = new UriStringSanitizer(targetValue, replacementValue);

            session.Session.Sanitize(sanitizer);

            Assert.Equal(targetUntouchedEntry.RequestUri, targetEntry.RequestUri);
        }
Beispiel #16
0
        public void HeaderStringSanitizerQuietlyExits(string targetKey, string targetValue, string replacementValue, string recordingFile)
        {
            var session              = TestHelpers.LoadRecordSession(recordingFile);
            var untouchedSession     = TestHelpers.LoadRecordSession(recordingFile);
            var targetUntouchedEntry = untouchedSession.Session.Entries[0];
            var targetEntry          = session.Session.Entries[0];
            var matcher              = new RecordMatcher();

            var sanitizer = new HeaderStringSanitizer(targetKey, targetValue, value: replacementValue);

            session.Session.Sanitize(sanitizer);

            Assert.Equal(0, matcher.CompareHeaderDictionaries(targetUntouchedEntry.Request.Headers, targetEntry.Request.Headers, new HashSet <string>(), new HashSet <string>()));
            Assert.Equal(0, matcher.CompareHeaderDictionaries(targetUntouchedEntry.Response.Headers, targetEntry.Response.Headers, new HashSet <string>(), new HashSet <string>()));
        }
Beispiel #17
0
        public void RecordMatcherIgnoresValuesOfIgnoredHeaders()
        {
            var matcher = new RecordMatcher();

            var mockRequest = new RecordEntry()
            {
                RequestUri    = "http://localhost",
                RequestMethod = RequestMethod.Put,
                Request       =
                {
                    Headers =
                    {
                        { "Request-Id",             new[] { "Non-Random value"              } },
                        { "Date",                   new[] { "Fri, 05 Nov 2020 02:42:26 GMT" } },
                        { "x-ms-date",              new[] { "Fri, 05 Nov 2020 02:42:26 GMT" } },
                        { "x-ms-client-request-id", new[] { "non random request id"         } },
                        { "x-ms-client-id",         new[] { "non random client id"          } },
                        { "User-Agent",             new[] { "non random sdk"                } },
                        { "traceparent",            new[] { "non random traceparent"        } }
                    }
                }
            };

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri    = "http://localhost",
                    RequestMethod = RequestMethod.Put,
                    Request       =
                    {
                        Headers =
                        {
                            { "Request-Id",             new[] { "Some Random value"             } },
                            { "Date",                   new[] { "Fri, 06 Nov 2020 02:42:26 GMT" } },
                            { "x-ms-date",              new[] { "Fri, 06 Nov 2020 02:42:26 GMT" } },
                            { "x-ms-client-request-id", new[] { "some random request id"        } },
                            { "x-ms-client-id",         new[] { "some random client id"         } },
                            { "User-Agent",             new[] { "some random sdk"               } },
                            { "traceparent",            new[] { "some random traceparent"       } }
                        }
                    }
                }
            };

            Assert.NotNull(matcher.FindMatch(mockRequest, entries));
        }
Beispiel #18
0
        public void BodyStringSanitizerQuietlyExits(string targetValue, string replacementValue, string recordingFile)
        {
            var session              = TestHelpers.LoadRecordSession(recordingFile);
            var untouchedSession     = TestHelpers.LoadRecordSession(recordingFile);
            var targetEntry          = session.Session.Entries[0];
            var originalBodyValue    = Encoding.UTF8.GetString(targetEntry.Request.Body);
            var targetUntouchedEntry = untouchedSession.Session.Entries[0];
            var matcher              = new RecordMatcher();

            var sanitizer = new BodyStringSanitizer(targetValue, value: replacementValue);

            session.Session.Sanitize(sanitizer);

            var resultBodyValue = Encoding.UTF8.GetString(targetEntry.Request.Body);

            Assert.Equal(0, matcher.CompareBodies(targetUntouchedEntry.Request.Body, targetEntry.Request.Body));
            Assert.Equal(0, matcher.CompareBodies(targetUntouchedEntry.Response.Body, targetEntry.Response.Body));
        }
Beispiel #19
0
        public async Task SetMatcher()
        {
            await DebugLogger.LogRequestDetailsAsync(_logger, Request);

            var mName       = RecordingHandler.GetHeader(Request, "x-abstraction-identifier");
            var recordingId = RecordingHandler.GetHeader(Request, "x-recording-id", allowNulls: true);

            RecordMatcher m = (RecordMatcher)GetMatcher(mName, await HttpRequestInteractions.GetBody(Request));

            if (recordingId != null)
            {
                _recordingHandler.SetMatcherForRecording(recordingId, m);
            }
            else
            {
                _recordingHandler.Matcher = m;
            }
        }
        public void RecordMatcherThrowsExceptionsWithDetails()
        {
            var matcher = new RecordMatcher(new RecordedTestSanitizer());

            MockRequest mockRequest = new MockRequest
            {
                Method = RequestMethod.Head
            };

            mockRequest.Uri.Reset(new Uri("http://localhost"));
            mockRequest.Headers.Add("Some-Header", "Random value");
            mockRequest.Headers.Add("Some-Other-Header", "V");

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri    = "http://remote-host",
                    RequestMethod = RequestMethod.Put,
                    Request       =
                    {
                        Headers =
                        {
                            { "Some-Header",  new[] { "Non-Random value" } },
                            { "Extra-Header", new[] { "Extra-Value"      } }
                        }
                    }
                }
            };

            InvalidOperationException exception = Assert.Throws <InvalidOperationException>(() => matcher.FindMatch(mockRequest, entries));

            Assert.AreEqual(
                "Unable to find a record for the request HEAD http://localhost/" + Environment.NewLine +
                "Method doesn't match, request <HEAD> record <PUT>" + Environment.NewLine +
                "Uri doesn't match:" + Environment.NewLine +
                "    request <http://localhost/>" + Environment.NewLine +
                "    record  <http://remote-host>" + Environment.NewLine +
                "Header differences:" + Environment.NewLine +
                "    <Some-Header> values differ, request <Random value>, record <Non-Random value>" + Environment.NewLine +
                "    <Some-Other-Header> is absent in record, value <V>" + Environment.NewLine +
                "    <Extra-Header> is absent in request, value <Extra-Value>" + Environment.NewLine,
                exception.Message);
        }
        public void RecordMatcherThrowsExceptionsWhenNoRecordsLeft()
        {
            var matcher = new RecordMatcher();

            var mockRequest = new RecordEntry()
            {
                RequestUri    = "http://localhost/",
                RequestMethod = RequestMethod.Head
            };

            RecordEntry[] entries = { };

            InvalidOperationException exception = Assert.Throws <InvalidOperationException>(() => matcher.FindMatch(mockRequest, entries));

            Assert.AreEqual(
                "Unable to find a record for the request HEAD http://localhost/" + Environment.NewLine +
                "No records to match." + Environment.NewLine,
                exception.Message);
        }
Beispiel #22
0
        public void UriStringSanitizerApplies(string targetValue, string replacementValue, string recordingFile)
        {
            var session          = TestHelpers.LoadRecordSession(recordingFile);
            var untouchedSession = TestHelpers.LoadRecordSession(recordingFile);

            var targetEntry          = session.Session.Entries[0];
            var targetUntouchedEntry = untouchedSession.Session.Entries[0];
            var matcher = new RecordMatcher();

            var sanitizer = new UriStringSanitizer(targetValue, replacementValue);

            session.Session.Sanitize(sanitizer);

            var originalUriValue = targetUntouchedEntry.RequestUri.ToString();
            var resultUriValue   = targetEntry.RequestUri.ToString();

            Assert.NotEqual(originalUriValue, resultUriValue);
            Assert.Contains(replacementValue, resultUriValue);
            Assert.DoesNotContain(targetValue, resultUriValue);
        }
Beispiel #23
0
        public void RecordMatcherThrowsExceptionsWhenNoRecordsLeft()
        {
            var matcher = new RecordMatcher(new RecordedTestSanitizer());

            MockRequest mockRequest = new MockRequest();

            mockRequest.Method         = RequestMethod.Head;
            mockRequest.UriBuilder.Uri = new Uri("http://localhost");
            mockRequest.Headers.Add("Some-Header", "Random value");
            mockRequest.Headers.Add("Some-Other-Header", "V");

            RecordEntry[] entries = {};

            InvalidOperationException exception = Assert.Throws <InvalidOperationException>(() => matcher.FindMatch(mockRequest, entries));

            Assert.AreEqual(
                "Unable to find a record for the request HEAD http://localhost/" + Environment.NewLine +
                "No records to match." + Environment.NewLine,
                exception.Message);
        }
Beispiel #24
0
        public void BodyNormalizationWorksWhenMatching(string body, string contentType)
        {
            byte[] bodyBytes = Encoding.UTF8.GetBytes(body);

            var session = new RecordSession();

            session.Variables["a"] = "value a";
            session.Variables["b"] = "value b";

            RecordEntry recordEntry = new RecordEntry();

            recordEntry.Request.Headers.Add("Content-Type", new[] { contentType });
            recordEntry.Request.Headers.Add("Other-Header", new[] { "multi", "value" });
            recordEntry.Request.Body  = bodyBytes;
            recordEntry.RequestUri    = "http://localhost/";
            recordEntry.RequestMethod = RequestMethod.Delete;

            recordEntry.Response.Headers.Add("Content-Type", new[] { contentType });
            recordEntry.Response.Headers.Add("Other-Response-Header", new[] { "multi", "value" });

            recordEntry.Response.Body = bodyBytes;
            recordEntry.StatusCode    = 202;

            session.Entries.Add(recordEntry);

            var arrayBufferWriter = new ArrayBufferWriter <byte>();

            using var jsonWriter = new Utf8JsonWriter(arrayBufferWriter, new JsonWriterOptions()
            {
                Indented = true
            });
            session.Serialize(jsonWriter);
            jsonWriter.Flush();
            var document            = JsonDocument.Parse(arrayBufferWriter.WrittenMemory);
            var deserializedSession = RecordSession.Deserialize(document.RootElement);

            var matcher = new RecordMatcher();

            Assert.NotNull(deserializedSession.Lookup(recordEntry, matcher, new[] { new RecordedTestSanitizer() }));
        }
Beispiel #25
0
        public void RecordMatcherIgnoresLegacyExcludedHeaders()
        {
            var matcher = new RecordMatcher
            {
                ExcludeHeaders = { "some header", "another" }
            };

            var mockRequest = new RecordEntry()
            {
                RequestUri    = "http://localhost",
                RequestMethod = RequestMethod.Put,
                Request       =
                {
                    Headers =
                    {
                        { "some header", new[] { "Non-Random value" } },
                    }
                }
            };

            RecordEntry[] entries = new[]
            {
                new RecordEntry()
                {
                    RequestUri    = "http://localhost",
                    RequestMethod = RequestMethod.Put,
                    Request       =
                    {
                        Headers =
                        {
                            { "another", new[] { "Some Random value" } },
                        }
                    }
                }
            };

            Assert.NotNull(matcher.FindMatch(mockRequest, entries));
        }
        public void SpecialHeadersNormalizedForMatching(string name)
        {
            // Use HttpClientTransport as it does header normalization
            var originalRequest = new HttpClientTransport().CreateRequest();

            originalRequest.Method = RequestMethod.Get;
            originalRequest.Uri.Reset(new Uri("http://localhost"));
            originalRequest.Headers.Add(name, "application/json;odata=nometadata");
            originalRequest.Headers.Add("Date", "This should be ignored");

            var playbackRequest = new MockTransport().CreateRequest();

            playbackRequest.Method = RequestMethod.Get;
            playbackRequest.Uri.Reset(new Uri("http://localhost"));
            playbackRequest.Headers.Add(name, "application/json;odata=nometadata");
            playbackRequest.Headers.Add("Date", "It doesn't match");

            var matcher      = new RecordMatcher();
            var requestEntry = RecordTransport.CreateEntry(originalRequest, null);
            var entry        = RecordTransport.CreateEntry(originalRequest, new MockResponse(200));

            Assert.NotNull(matcher.FindMatch(requestEntry, new[] { entry }));
        }
Beispiel #27
0
        /// <summary>
        /// Checks if a table is sorted
        /// </summary>
        /// <param name="T">The table to check</param>
        /// <param name="Columns">The desied sort order</param>
        /// <returns>the first instance that a record is out of order; if the table is sorted, returns a record not found key </returns>
        public static RecordKey CheckSort(Table T, Key Columns)
        {
            if (T.RecordCount < 2)
            {
                return(RecordKey.RecordNotFound);
            }

            RecordReader  rs      = T.OpenReader();
            RecordMatcher matcher = new RecordMatcher(Columns);
            Record        First   = rs.ReadNext();

            while (rs.CanAdvance)
            {
                // We want First <= Second
                Record Second = rs.ReadNext();
                int    check  = matcher.Compare(First, Second);
                if (check > 0)
                {
                    return(rs.PositionKey);
                }
            }

            return(RecordKey.RecordNotFound);
        }
 public TextAnalyticsClientLiveTests(bool isAsync) : base(isAsync)
 {
     Sanitizer = new TextAnalyticsRecordedTestSanitizer();
     Matcher   = new RecordMatcher(Sanitizer);
 }
Beispiel #29
0
 public PersonalizerTestBase(bool isAsync) : base(isAsync)
 {
     // TODO: Compare bodies again when https://github.com/Azure/azure-sdk-for-net/issues/22219 is resolved.
     Matcher   = new RecordMatcher(compareBodies: false);
     Sanitizer = new PersonalizerRecordedTestSanitizer();
 }
Beispiel #30
0
 public ConfigurationLiveTests(bool isAsync) : base(isAsync)
 {
     Sanitizer = new ConfigurationRecordedTestSanitizer();
     Matcher   = new RecordMatcher(Sanitizer);
 }