Example #1
0
        public async Task EditEvent()
        {
            var now = DateTime.Now;

            var mock = new Mock <ITimelineService>();

            mock.Setup(m => m.PutJsonAsync(It.IsAny <string>(), It.IsAny <object>())).Returns(TestUtils.GetCompletedTask(TimelineEventJson));

            TimelineEvent timelineEvent = new TimelineEvent();

            timelineEvent.Id            = "ID1";
            timelineEvent.Title         = "Edited Title";
            timelineEvent.Description   = "Edited description";
            timelineEvent.EventDateTime = now;
            timelineEvent.Location      = "-1.1234,1.1234";
            await timelineEvent.EditAsync(mock.Object);

            // We reuse Event/Create to do a full on edit of all attributes at once.
            mock.Verify(m => m.PutJsonAsync("TimelineEvent/Create", It.Is <object>(o => o.VerifyObject("TimelineEventId", "ID1"))));
            mock.Verify(m => m.PutJsonAsync("TimelineEvent/Create", It.Is <object>(o => o.VerifyObject("Title", "Edited Title"))));
            mock.Verify(m => m.PutJsonAsync("TimelineEvent/Create", It.Is <object>(o => o.VerifyObject("Description", "Edited description"))));
            mock.Verify(m => m.PutJsonAsync("TimelineEvent/Create", It.Is <object>(o => o.VerifyObject("EventDateTime", now.Ticks.ToString()))));
            mock.Verify(m => m.PutJsonAsync("TimelineEvent/Create", It.Is <object>(o => o.VerifyObject("Location", "-1.1234,1.1234"))));
        }