Exemplo n.º 1
0
        public async Task Consumer_Should_Create_A_Pack()
        {
            var options = new PactDefinitionOptions
            {
                IgnoreContractValues = true,
                IgnoreCasing         = true
            };


            await PactMaker
            .Create(options)
            .Between("frontend", "bicycles")
            .WithHttpInteraction(bc =>
                                 bc.Given("There is a request for some id")
                                 .UponReceiving("A GET request to get bicycle")
                                 .With(request => request
                                       .WithMethod(HttpMethod.Get)
                                       .WithPath("bicycles/1"))
                                 .WillRespondWith(response => response
                                                  .WithHeader("Content-Type", "application/json")
                                                  .WithStatusCode(HttpStatusCode.OK)
                                                  .WithBody <BicycleResponseModel>()))
            .PublishedViaHttp("http://localhost/pacts/provider/bicycles/consumer/frontend/version/1.0.0", HttpMethod.Put)
            .MakeAsync();
        }
 public async Task Given_Valid_Product_Id_Product_Should_Be_Returned()
 {
     await PactMaker
     .Create(new PactDefinitionOptions
     {
         IgnoreCasing         = true,
         IgnoreContractValues = true,
     })
     .Between("orders", "products")
     .WithHttpInteraction(b => b
                          .Given("Existing product")
                          .UponReceiving("A GET request to retrieve product details")
                          .With(request => request
                                .WithMethod(HttpMethod.Get)
                                .WithPath($"/products/{ProductId}"))
                          .WillRespondWith(response => response
                                           .WithHeader("Content-Type", "application/json")
                                           .WithStatusCode(HttpStatusCode.OK)
                                           .WithBody <ProductDto>()))
     .PublishedAsFile("../../../../../../../pacts")     // TODO: docker based pact broker
     .MakeAsync().ConfigureAwait(false);
 }
Exemplo n.º 3
0
        public async Task Consumer_Should_Create_APact()
        {
            var options = new PactDefinitionOptions
            {
                IgnoreContractValues = true,
                IgnoreCasing = true
            };

            await PactMaker
                .Create(options)
                .Between("orders", "parcels")
                .WithHttpInteraction(cb => cb
                    .Given("There is a parcel with some id")
                    .UponReceiving("A GET Request to retrieve the parcel")
                    .With( request => request
                        .WithMethod(HttpMethod.Get)
                        .WithPath("api/parcels/{Id}"))
                    .WillRespondWith(response => response
                        .WithStatusCode(HttpStatusCode.OK)
                        .WithBody<ParcelReadModel>()))
                .PublishedViaHttp("http://localhost:9292/pacts/provider/parcels/consumer/orders/version/1.2.104", HttpMethod.Put)
                .MakeAsync();
        }
Exemplo n.º 4
0
        public async Task Given_Valid_Parcel_Id_Parcel_Should_Be_Returned()
        {
            var options = new PactDefinitionOptions
            {
                IgnoreCasing         = true,
                IgnoreContractValues = true
            };

            await PactMaker
            .Create(options)
            .Between("orders", "parcels")
            .WithHttpInteraction(b => b
                                 .Given("Existing parcel")
                                 .UponReceiving("A GET request to retrieve parcel details")
                                 .With(request => request
                                       .WithMethod(HttpMethod.Get)
                                       .WithPath($"/parcels/{ParcelId}"))
                                 .WillRespondWith(response => response
                                                  .WithHeader("Content-Type", "application/json")
                                                  .WithStatusCode(HttpStatusCode.OK)
                                                  .WithBody <ParcelDto>()))
            .PublishedAsFile("../../../../../../pacts")
            .MakeAsync();
        }