Exemplo n.º 1
0
        public async Task GetDownloadThemes()
        {
            var fileStorageService = new Mock <IFileStorageService>();

            fileStorageService
            .Setup(
                s => s.GetDeserialized <IEnumerable <ThemeTree <PublicationDownloadTreeNode> > >(
                    "download/tree.json"
                    )
                )
            .ReturnsAsync(
                new List <ThemeTree <PublicationDownloadTreeNode> >
            {
                new ThemeTree <PublicationDownloadTreeNode>
                {
                    Topics = new List <TopicTree <PublicationDownloadTreeNode> >
                    {
                        new TopicTree <PublicationDownloadTreeNode>
                        {
                            Publications = new List <PublicationDownloadTreeNode>
                            {
                                new PublicationDownloadTreeNode
                                {
                                    DownloadFiles = new List <FileInfo>
                                    {
                                        new FileInfo()
                                    }
                                }
                            }
                        }
                    }
                }
            }
                );

            var controller = new ThemeController(fileStorageService.Object);
            var result     = await controller.GetDownloadThemes();

            Assert.IsAssignableFrom <IEnumerable <ThemeTree <PublicationDownloadTreeNode> > >(result.Value);
            Assert.Single(result.Value);

            var theme = result.Value.First();

            Assert.IsType <ThemeTree <PublicationDownloadTreeNode> >(theme);
            Assert.Single(theme.Topics);

            var topic = theme.Topics.First();

            Assert.Single(topic.Publications);

            var publication = topic.Publications.First();

            Assert.Single(publication.DownloadFiles);
        }