public void Constructor_WhenTreeServiceCurrentTreeTreeIsNull_SetsCurrentTreeToNull()
        {
            var projectTreeServiceState = IProjectTreeServiceStateFactory.ImplementTree(() => null);
            var projectTreeService      = new Lazy <IProjectTreeService>(() => IProjectTreeServiceFactory.ImplementCurrentTree(() => projectTreeServiceState));
            var projectTreeProvider     = new Lazy <IProjectTreeProvider>(() => IProjectTreeProviderFactory.Create());

            var projectTree = new PhysicalProjectTree(projectTreeService, projectTreeProvider);

            Assert.Null(projectTree.CurrentTree);
        }
        public static IProjectTreeService Create(IProjectTree tree)
        {
            var mock = new Mock <IProjectTreeService>();

            var treeState = IProjectTreeServiceStateFactory.ImplementTree(() => tree, () => IProjectTreeProviderFactory.Create());

            mock.SetupGet(s => s.CurrentTree)
            .Returns(treeState);

            return(mock.Object);
        }
        public void Constructor_ValueAsTreeService_SetsCurrentTreeToTreeServiceCurrentTreeTree()
        {
            var tree = ProjectTreeParser.Parse(@"
Root (flags: {ProjectRoot})
");

            var projectTreeServiceState = IProjectTreeServiceStateFactory.ImplementTree(() => tree);
            var projectTreeService      = new Lazy <IProjectTreeService>(() => IProjectTreeServiceFactory.ImplementCurrentTree(() => projectTreeServiceState));
            var projectTreeProvider     = new Lazy <IProjectTreeProvider>(() => IProjectTreeProviderFactory.Create());

            var projectTree = new PhysicalProjectTree(projectTreeService, projectTreeProvider);

            Assert.Same(tree, projectTree.CurrentTree);
        }
        public static IProjectTreeService Create(IProjectTree tree, IProjectTreeProvider?treeProvider = null)
        {
            var mock = new Mock <IProjectTreeService>();

            var treeState = IProjectTreeServiceStateFactory.ImplementTree(() => tree, () => treeProvider ?? IProjectTreeProviderFactory.Create());

            mock.Setup(s => s.PublishAnyNonLoadingTreeAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(treeState);

            mock.Setup(s => s.PublishAnyNonNullTreeAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync(treeState);

            mock.SetupGet(s => s.CurrentTree)
            .Returns(treeState);

            return(mock.Object);
        }