Ejemplo n.º 1
0
        public async System.Threading.Tasks.Task ShallReturnCalendarEventsFromProviderAsync()
        {
            calendarEventsProviderMock.Setup(p => p.GetEventsInMonthAsync(It.IsAny <int>(), It.IsAny <int>())).Returns(() => {
                var cal = new CalendarEvent()
                {
                    Subject   = "MySubject",
                    StartDate = new DateTime(2020, 6, 1),
                    EndDate   = new DateTime(2020, 6, 1)
                };

                var result = new ConcurrentBag <CalendarEvent>();
                result.Add(cal);
                return(Task.FromResult <ConcurrentBag <CalendarEvent> >(result));
            });
            var result = await calendarController.GetEventsInMonthAsync(2020, 6);

            calendarEventsProviderMock.Verify(p => p.GetEventsInMonthAsync(2020, 6), Times.Once);
            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result.First().EndDate, Is.EqualTo(new DateTime(2020, 6, 1)));
        }