コード例 #1
0
        public async Task GetMethodologyThemes()
        {
            var fileStorageService = new Mock <IFileStorageService>();

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

            var controller = new ThemeController(fileStorageService.Object);

            var result = await controller.GetMethodologyThemes();

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

            var theme = result.Value.First();

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

            var topic = theme.Topics.First();

            Assert.Single(topic.Publications);
        }