Beispiel #1
0
        public void GivenThereIsAnEventSubscriberListeningOnPortCalled(HttpStatusCode response, int port, string name)
        {
            var subscriber = new StubWorkflowEventSubscriber(port, response);

            subscriber.Start();
            this.scenarioContext.Set(subscriber, name);
        }
Beispiel #2
0
        public void ThenACloudEventShouldHaveBeenPublishedToTheSubscriberCalled(string subscriberName, Table table)
        {
            StubWorkflowEventSubscriber subscriber = this.scenarioContext.Get <StubWorkflowEventSubscriber>(subscriberName);

            // Get the data from the requests as JObjects so we can check their values...
            JObject[] requestPayloads = subscriber.ReceivedRequests.Select(x => JObject.Parse(x.Content)).ToArray();

            foreach (TableRow row in table.Rows)
            {
                int    index         = int.Parse(row[0]);
                string path          = row[1];
                string expectedValue = row[2];

                // We might need to substitute the tenant Id in...
                expectedValue = expectedValue.Replace("{tenantId}", this.transientTenantManager.PrimaryTransientClient.Id);

                Assert.IsTrue(index < requestPayloads.Length, $"Expected an event at index {index} but was not present.");

                JToken targetToken = requestPayloads[index].SelectToken(path);
                Assert.IsNotNull(targetToken, $"Expected to find a data item at index '{index}' and path '{path}', but was not present.");

                Assert.AreEqual(expectedValue, targetToken.ToString(), $"Value did not match at index '{index}' and path '{path}'.");
            }
        }