Ejemplo n.º 1
0
        public void TestScenario()
        {
            try
            {
                Debug.WriteLine("Running scenario test... " + DateTime.Now);

                var credentials = new SerializedClientCredentials(accessKey, secretAccessKey);
                var client      = new Serialized(credentials);

                cleanUpPreviousExecutionResult(client);
                setUpDefinitions(client);

                // Verify no feeds exists as no aggregates exists.
                Assert.AreEqual(0, client.ListFeeds().Feeds.Count);

                // Store events and verify loading of aggregates.
                storeAndLoadEvents(client);

                // Verify one feed exists as one aggregate type (order) now exists.
                Assert.AreEqual(1, client.ListFeeds().Feeds.Count);

                readAndVerifyAllFeed(client);

                readAndVerifyOrderFeed(client);

                // Projections are created async so we have to wait a while.
                Thread.Sleep(2000);

                getAndVerifyOrderProjections(client);

                getAndVerifyOrderTotalsProjection(client);

                filterOrderProjectionsByReference(client, "PAID");

                // Verify no scheduled reactions exists.
                Assert.AreEqual(0, client.ListScheduledReactions().ReactionsProperty.Count);

                // Verify the two OrderPlaced events on orderId1 and orderId2 resulted in successfully triggered reactions (new order notifications).
                Assert.AreEqual(2, client.ListTriggeredReactions().ReactionsProperty.Count);

                Debug.WriteLine("Scenario test completed!");
            }
            catch (HttpOperationException hex)
            {
                Debug.WriteLine(hex);
                Debug.WriteLine("Error, code: " + hex.Response.StatusCode);
                Debug.WriteLine("Request: " + hex.Request.Content);
                Debug.WriteLine("Response: " + hex.Response.Content);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Assert.Fail();
            }
        }