Exemplo n.º 1
0
        public async Task GetStoryOverview_GetsStorySections()
        {
            var storySection = new StorySection {
                Id = 10, Description = "Chapter One", Order = 1, HierarchyLevel = 1
            };
            var storySections = new OrderedHierarchicalTree <StorySection> (new [] { storySection });

            Mock.Arrange(() => storySectionRepository.GetTreeForStory(testStory.Id))
            .Returns(() => Task.FromResult(storySections));

            var result = await target.GetStoryOverview(testStory.Id);

            Assert.Equal(1, result.Sections.Count);
            Assert.Equal(10, result.Sections[0].Id);
        }
Exemplo n.º 2
0
 public StoryReadServiceTests()
 {
     storyRepos             = Mock.Create <IStoryRepository>();
     nodeService            = Mock.Create <IAsyncNodeService>();
     storySectionRepository = Mock.Create <IStorySectionRepository>();
     target    = new StoryReadService(storyRepos, nodeService, storySectionRepository);
     testStory = new Story {
         Id = 1, Title = "A Story", Synopsis = "A Summary"
     };
     Mock.Arrange(() => storyRepos.GetAsync(testStory.Id))
     .Returns(() => Task.FromResult(testStory));
     Mock.Arrange(() => nodeService.Get(Arg.IsAny <INode>(), Arg.IsAny <NodeType <Actor> >()))
     .Returns(() => Task.FromResult(new List <Actor>()));
     Mock.Arrange(() => storySectionRepository.GetTreeForStory(Arg.AnyInt))
     .Returns(() => Task.FromResult(new OrderedHierarchicalTree <StorySection>()));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets requested story overview
        /// </summary>
        /// <param name="id">Story Id</param>
        /// <returns>Requested StoryOverview</returns>
        public async Task <StoryOverview> GetStoryOverview(int id)
        {
            var result = new StoryOverview();

            result.Summary = await GetStorySummary(id);

            var tree = await storySectionRepository.GetTreeForStory(id);

            result.Actors = await nodeService.Get(new Node(id, StoryboardNodeTypes.Story), StoryboardNodeTypes.Actor);

            if (tree != null && tree.Hierarchies.Count != 0)
            {
                if (tree.Hierarchies.Count != 1)
                {
                    throw new InvalidOperationException("Multiple Hierarchical levels not supported");
                }
                result.Sections = tree.GetHierarchicalLevel(tree.Hierarchies[0]).ToList();
            }
            else
            {
                result.Sections = new List <StorySection>();
            }
            return(result);
        }