Example #1
0
 public async Task ExpectGetToReturnNonExistantPropertyGivesErrorMessage()
 {
     const string ServiceUri   = "http://localhost:9222";
     var          fetcher      = new FilePactFetcher("TestPacts/Test6.json");
     var          pactVerifier = new PactVerifier((condition, message) => Assert.False(condition, message), fetcher);
     await pactVerifier
     .ProviderState($"{ServiceUri}/provider-states")
     .ServiceProvider("theProvider", ServiceUri)
     .HonoursPactWith("theConsumer")
     .Verify(0, () =>
             new HttpClient(new FakeHandler(HttpStatusCode.OK))
     {
         BaseAddress = new System.Uri(ServiceUri)
     }
             );
 }
Example #2
0
 public async Task CompareEmptyWithNull()
 {
     const string ServiceUri   = "http://localhost:9222";
     var          fetcher      = new FilePactFetcher("TestPacts/Test3.json");
     var          pactVerifier = new PactVerifier((condition, message) => Assert.True(condition, message), fetcher);
     await pactVerifier
     .ProviderState($"{ServiceUri}/provider-states")
     .ServiceProvider("theProvider", ServiceUri)
     .HonoursPactWith("theConsumer")
     .Verify(0, () =>
             new HttpClient(new FakeHandler())
     {
         BaseAddress = new System.Uri(ServiceUri)
     }
             );
 }
        public void GetPactParsesJsonFile()
        {
            const string filename = @"pactUri.json";
            const string json     = @"
                {
                    ""consumer"": {
                        ""name"": ""a consumer name""
                    },
                    ""provider"": {
                        ""name"": ""a provider name""
                    },
                    ""metadata"": {
                    ""pactSpecification"": {
                        ""version"": ""2.0.0""
                    }
                }
            ";

            File.WriteAllText(filename, json);

            var result = new FilePactFetcher(filename).GetPact("a consumer name", "a provider name", "a tag name");
        }