コード例 #1
0
        private void readAndVerifyOrderFeed(Serialized client)
        {
            Debug.WriteLine("Reading feed: " + orderType);

            var orderFeed      = client.FeedEventsByType(orderType);
            var feedEnumerator = orderFeed.Entries.GetEnumerator();

            Assert.AreEqual(3, orderFeed.Entries.Count);

            // First
            feedEnumerator.MoveNext();
            Assert.AreEqual(orderId1, feedEnumerator.Current.AggregateId);
            var eventEnumerator = feedEnumerator.Current.Events.GetEnumerator();

            eventEnumerator.MoveNext();

            var eventData = (JObject)eventEnumerator.Current.Data;

            Assert.AreEqual("OrderPlaced", eventEnumerator.Current.EventType);
            Assert.AreEqual("some-test-id-1", eventData["customerId"]);
            Assert.AreEqual(12345, eventData["orderAmount"]);
            Assert.IsNotNull(eventData["placedAt"]);

            // Second
            feedEnumerator.MoveNext();
            Assert.AreEqual(orderId1, feedEnumerator.Current.AggregateId);
            eventEnumerator = feedEnumerator.Current.Events.GetEnumerator();
            eventEnumerator.MoveNext();

            eventData = (JObject)eventEnumerator.Current.Data;
            Assert.AreEqual("OrderPaid", eventEnumerator.Current.EventType);
            Assert.AreEqual("some-test-id-1", eventData["customerId"]);
            Assert.IsNotNull(eventData["paidAt"]);

            // Third
            feedEnumerator.MoveNext();
            Assert.AreEqual(orderId2, feedEnumerator.Current.AggregateId);
            eventEnumerator = feedEnumerator.Current.Events.GetEnumerator();
            eventEnumerator.MoveNext();

            eventData = (JObject)eventEnumerator.Current.Data;
            Assert.AreEqual("OrderPlaced", eventEnumerator.Current.EventType);
            Assert.AreEqual("some-test-id-2", eventData["customerId"]);
            Assert.AreEqual(67890, eventData["orderAmount"]);
            Assert.IsNotNull(eventData["placedAt"]);
        }