Example #1
0
        public void EnsureEventApiHonoursPactWithConsumer()
        {
            //Arrange
            var outputter = new CustomOutputter();
            var config = new PactVerifierConfig();
            config.ReportOutputters.Add(outputter);
            IPactVerifier pactVerifier = new PactVerifier(() => {}, () => {}, config);

            pactVerifier
                .ProviderState(
                    "there are events with ids '45D80D13-D5A2-48D7-8353-CBB4C0EAABF5', '83F9262F-28F1-4703-AB1A-8CFD9E8249C9' and '3E83A96B-2A0C-49B1-9959-26DF23F83AEB'",
                    setUp: InsertEventsIntoDatabase)
                .ProviderState("there is an event with id '83f9262f-28f1-4703-ab1a-8cfd9e8249c9'",
                    setUp: InsertEventIntoDatabase)
                .ProviderState("there is one event with type 'DetailsView'",
                    setUp: EnsureOneDetailsViewEventExists);

            //Act / Assert
            using (var testServer = TestServer.Create<Startup>())
            {
                pactVerifier
                   .ServiceProvider("Event API", testServer.HttpClient)
                   .HonoursPactWith("Consumer")
                   .PactUri("../../../Consumer.Tests/pacts/consumer-event_api.json")
                   .Verify();
            }

            // Verify that verifaction log is also sent to additional reporters defined in the config
            Assert.Contains("Verifying a Pact between Consumer and Event API", outputter.Output);
        }
Example #2
0
 /// <summary>
 /// Define any set up and tear down state that is required when running the interaction verify.
 /// We strongly recommend that any set up state is cleared using the tear down. This includes any state and IoC container overrides you may be doing.
 /// </summary>
 /// <param name="setUp">A set up action that will be run before each interaction verify. If no action is required please use an empty lambda () => {}.</param>
 /// <param name="tearDown">A tear down action that will be run after each interaction verify. If no action is required please use an empty lambda () => {}.</param>
 /// <param name="config"></param>
 public PactVerifier(Action setUp, Action tearDown, PactVerifierConfig config = null)
     : this(setUp, 
     tearDown,
     new FileSystem(),
     (httpRequestSender, reporter, verifierConfig) => new ProviderServiceValidator(httpRequestSender, reporter, verifierConfig),
     new HttpClient(),
     config)
 {
 }
Example #3
0
 /// <summary>
 /// Define any set up and tear down state that is required when running the interaction verify.
 /// We strongly recommend that any set up state is cleared using the tear down. This includes any state and IoC container overrides you may be doing.
 /// </summary>
 /// <param name="setUp">A set up action that will be run before each interaction verify. If no action is required please use an empty lambda () => {}.</param>
 /// <param name="tearDown">A tear down action that will be run after each interaction verify. If no action is required please use an empty lambda () => {}.</param>
 /// <param name="config"></param>
 public PactVerifier(Action setUp, Action tearDown, PactVerifierConfig config = null)
     : this(
         setUp,
         tearDown,
         new FileSystem(),
         (httpRequestSender, reporter, verifierConfig) => new ProviderServiceValidator(httpRequestSender, reporter, verifierConfig),
         new HttpClient(),
         config)
 {
 }
Example #4
0
        internal PactVerifier(Func <PactVerifierHostConfig, IPactCoreHost> pactVerifierHostFactory, PactVerifierConfig config)
        {
            _pactVerifierHostFactory = pactVerifierHostFactory;
            _config = config;

            if (config.PublishVerificationResults && IsNullOrEmpty(config.ProviderVersion))
            {
                throw new ArgumentException($"config.{nameof(config.ProviderVersion)} is required when config.{nameof(config.PublishVerificationResults)} is true.");
            }
        }
Example #5
0
 public PactVerifier(PactVerifierConfig config) :
     this(
         hostConfig => new PactCoreHost <PactVerifierHostConfig>(hostConfig),
         config ?? new PactVerifierConfig())
 {
     if (config.PublishVerificationResults && string.IsNullOrEmpty(config.ProviderVersion))
     {
         throw new ArgumentException($"{nameof(config.ProviderVersion)} is required when {nameof(config.PublishVerificationResults)} is true.");
     }
 }
Example #6
0
        internal PactVerifier(
            Action setUp,
            Action tearDown,
            IFileSystem fileSystem,
            Func <IHttpRequestSender, IReporter, PactVerifierConfig, IProviderServiceValidator> providerServiceValidatorFactory,
            HttpClient httpClient,
            PactVerifierConfig config)
        {
            _fileSystem = fileSystem;
            _providerServiceValidatorFactory = providerServiceValidatorFactory;
            _httpClient = httpClient;
            _config     = config ?? new PactVerifierConfig();

            ProviderStates = new ProviderStates(setUp, tearDown);
        }
Example #7
0
        internal PactVerifier(
            Action setUp,
            Action tearDown,
            IFileSystem fileSystem,
            Func<IHttpRequestSender, IReporter, PactVerifierConfig, IProviderServiceValidator> providerServiceValidatorFactory,
            HttpClient httpClient,
            PactVerifierConfig config)
        {
            _fileSystem = fileSystem;
            _providerServiceValidatorFactory = providerServiceValidatorFactory;
            _httpClient = httpClient;
            _config = config ?? new PactVerifierConfig();

            ProviderStates = new ProviderStates(setUp, tearDown);
        }
Example #8
0
 public PactVerifier(PactVerifierConfig config) :
     this(
         hostConfig => new PactCoreHost <PactVerifierHostConfig>(hostConfig),
         config ?? new PactVerifierConfig())
 {
 }
Example #9
0
 internal PactVerifier(Func <PactVerifierHostConfig, IPactCoreHost> pactVerifierHostFactory, PactVerifierConfig config)
 {
     _pactVerifierHostFactory = pactVerifierHostFactory;
     _config = config;
 }