Exemple #1
0
        internal JObject ToPactInteraction(ITransportFormat format)
        {
            var pactInteraction = new JObject
            {
                ["description"] = interactionDescription
            };

            if (!string.IsNullOrEmpty(providerState))
            {
                pactInteraction["providerState"] = providerState;
            }

            pactInteraction["request"]  = format.SerializeRequest(request);
            pactInteraction["response"] = format.SerializeResponse(responseFactory(request));

            if (responseMatchers.Any())
            {
                var rules = new JObject();
                foreach (var responseMatcher in responseMatchers.GroupBy(m => m.PropertyPath))
                {
                    rules["$." + responseMatcher.Key] = new JArray(responseMatcher.Select(r => r.ToPactMatcher()).ToArray());
                }
                pactInteraction["matchingRules"] = rules;
            }

            return(pactInteraction);
        }
Exemple #2
0
 public string ToPactFile(string consumer, string provider, ITransportFormat format)
 {
     return(new JObject
     {
         ["consumer"] = new JObject {
             ["name"] = consumer
         },
         ["provider"] = new JObject {
             ["name"] = provider
         },
         ["interactions"] = new JArray(interactions.Select(i => i.ToPactInteraction(format)).ToArray())
     }.ToString());
 }
Exemple #3
0
 public CallbackTransport(ITransportFormat transportFormat, Func <object, Task <object> > callback, ITransportMatchers matchers = null)
 {
     Format        = transportFormat;
     Matchers      = matchers ?? new NoTransportMatchers();
     this.callback = callback;
 }