Beispiel #1
0
        public async Task TimelineGetLinkedEvents()
        {
            string json = "[{\"TimelineEventId\":\"ID1\",\"TimelineId\":\"ID2\",\"IsDeleted\":true,\"Id\":\"ID3\",\"TenantId\":\"123\"}," +
                          "{\"TimelineEventId\":\"ID4\",\"TimelineId\":\"ID5\",\"IsDeleted\":true,\"Id\":\"ID6\",\"TenantId\":\"123\"}]";
            var mock = new Mock <ITimelineService>();

            mock.Setup(m => m.GetJsonAsync(It.IsAny <string>(), It.IsAny <NameValueCollection>())).Returns(TestUtils.GetCompletedTask(json));

            var linkedEvents = await TimelineEvent.GetEventsAsync(mock.Object, "ID1");

            mock.Verify(m => m.GetJsonAsync("Timeline/GetEvents", It.Is <NameValueCollection>(c => c.VerifyContains("TimelineId", "ID1"))));
            Assert.AreEqual(2, linkedEvents.Count);
            Assert.AreEqual(linkedEvents[0].TimelineEventId, "ID1");
            Assert.AreEqual(linkedEvents[0].TimelineId, "ID2");
            Assert.IsTrue(linkedEvents[0].IsDeleted);
            Assert.AreEqual(linkedEvents[0].Id, "ID3");
            Assert.AreEqual(linkedEvents[0].TenantId, "123");
            Assert.AreEqual(linkedEvents[1].TimelineEventId, "ID4");
        }