コード例 #1
0
        public async Task GetPresentations_ShouldReturnListOfPresentations()
        {
            // Arrange
            var queuePresentationAddedMock = new Mock <PresentationAddedQueue>();
            var queueScheduleAddedMock     = new Mock <PresentationScheduleAddedQueue>();
            var presentationRepositoryMock = new Mock <IPresentationRepository>();

            presentationRepositoryMock.Setup(presentationRepository => presentationRepository.GetPresentationsAsync())
            .ReturnsAsync(new List <Presentation>
            {
                new Presentation
                {
                    PresentationId = 1, Abstract = "Abstract", Title = "Title", PowerpointUri = "PowerpointUri"
                },
                new Presentation
                {
                    PresentationId = 2, Abstract = "Abstract", Title = "Title", PowerpointUri = "PowerpointUri"
                },
            });

            var presentationManager = new PresentationManager(presentationRepositoryMock.Object,
                                                              queuePresentationAddedMock.Object, queueScheduleAddedMock.Object);

            // Act
            var presentations = await presentationManager.GetPresentationsAsync();

            // Assert
            Assert.NotNull(presentations);
            var listOfPresentations = presentations.ToList();

            Assert.True(listOfPresentations.Count == 2);

            for (var i = 0; i < listOfPresentations.Count; i++)
            {
                var presentation = listOfPresentations[i];
                Assert.Equal(i + 1, presentation.PresentationId);
                Assert.Equal("Abstract", presentation.Abstract);
                Assert.Equal("Title", presentation.Title);
                Assert.Equal("PowerpointUri", presentation.PowerpointUri);
            }
        }