Exemplo n.º 1
0
        public void NotFoundExceptionContainUrlAndMethodName()
        {
            HttpMockServer.RecordsDirectory = currentDir;
            HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Record);
            FakeHttpClient client1     = CreateClient();
            var            resultCOrig = client1.DoStuffC("test", "123", "abc").Result;

            HttpMockServer.Flush(currentDir);

            HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Playback);
            FakeHttpClient client3 = CreateClient();

            try
            {
                var r = client1.DoStuffC("test", "123", "xyz").Result;
                Assert.False(true);
            }
            catch (AggregateException aggregateException)
            {
                var exception = aggregateException.InnerExceptions[0];

                //TODO: figure out whether exception message ever mentioned 'DoStuffC'
                Assert.Equal("Unable to find a matching HTTP request for URL 'POST /path/to/resourceB?api-version=xyz (x-ms-version=123)'. Calling method Item().",
                             exception.Message);
            }
        }
Exemplo n.º 2
0
        public void PlaybackWithDifferentVersionInHeaderDoesNotMatch()
        {
            HttpMockServer.RecordsDirectory = currentDir;
            HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Record);
            FakeHttpClient client1     = CreateClient();
            var            resultCOrig = client1.DoStuffC("test", "123", "abc").Result;

            HttpMockServer.Flush(currentDir);

            HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Playback);
            FakeHttpClient client3 = CreateClient();

            Assert.Throws <AggregateException>(() => client1.DoStuffC("test", "456", "abc").Result);
        }
Exemplo n.º 3
0
        public void PlaybackWithDifferentBodyIsMatched()
        {
            HttpMockServer.RecordsDirectory = currentDir;
            HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Record);
            FakeHttpClient client1     = CreateClient();
            var            resultCOrig = client1.DoStuffC("test", "123", "abc").Result;

            HttpMockServer.Flush(currentDir);

            HttpMockServer.Initialize(this.GetType(), TestUtilities.GetCurrentMethodName(), HttpRecorderMode.Playback);
            FakeHttpClient client3         = CreateClient();
            var            resultCPlayback = client1.DoStuffC("different", "123", "abc").Result;

            HttpMockServer.Flush(currentDir);

            Assert.Equal(resultCOrig.RequestMessage.RequestUri, resultCPlayback.RequestMessage.RequestUri);
        }