Example #1
0
        public async Task GetScheduledPresentation_ShouldReturnAListScheduledPresentations()
        {
            // Arrange
            var queuePresentationAddedMock = new Mock <PresentationAddedQueue>();
            var queueScheduleAddedMock     = new Mock <PresentationScheduleAddedQueue>();
            var presentationRepositoryMock = new Mock <IPresentationRepository>();

            presentationRepositoryMock
            .Setup(presentationRepository =>
                   presentationRepository.GetScheduledPresentationsForPresentationAsync(It.IsAny <int>()))
            .ReturnsAsync((int presentationIdInput) => new List <ScheduledPresentation>
            {
                new ScheduledPresentation
                {
                    ScheduledPresentationId = 1, AttendeeCount = 1,
                    Presentation            = new Presentation {
                        PresentationId = presentationIdInput
                    }
                },
                new ScheduledPresentation
                {
                    ScheduledPresentationId = 2, AttendeeCount = 1,
                    Presentation            = new Presentation {
                        PresentationId = presentationIdInput
                    }
                }
            });
            var presentationManager = new PresentationManager(presentationRepositoryMock.Object,
                                                              queuePresentationAddedMock.Object, queueScheduleAddedMock.Object);
            var presentationId = 15; // Can be any int

            // Act
            var scheduledPresentations =
                await presentationManager.GetScheduledPresentationsForPresentationAsync(presentationId);

            // Assert
            Assert.NotNull(scheduledPresentations);
            var scheduledPresentationsAsList = scheduledPresentations.ToList();

            Assert.Equal(2, scheduledPresentationsAsList.Count);
            for (var i = 0; i < scheduledPresentationsAsList.Count; i++)
            {
                var scheduledPresentation = scheduledPresentationsAsList[i];
                Assert.NotNull(scheduledPresentation.Presentation);
                Assert.Equal(presentationId, scheduledPresentation.Presentation.PresentationId);
                Assert.Equal(i + 1, scheduledPresentation.ScheduledPresentationId);
                Assert.Equal(1, scheduledPresentation.AttendeeCount);
            }
        }