Esempio n. 1
0
        public void CreateRootViewModel()
        {
            var project = UnconfiguredProjectFactory.Create();

            var dependencyModel = new TestDependencyModel
            {
                ProviderType = "MyProvider1",
                Id           = "ZzzDependencyRoot",
                Name         = "ZzzDependencyRoot",
                Caption      = "ZzzDependencyRoot",
                Icon         = KnownMonikers.AboutBox
            };

            var subTreeProvider1 = IProjectDependenciesSubTreeProviderFactory.Implement(
                providerType: "MyProvider1",
                createRootDependencyNode: dependencyModel);
            var subTreeProvider2 = IProjectDependenciesSubTreeProviderFactory.Implement(
                providerType: "MyProvider2");

            var factory = new TestableDependenciesViewModelFactory(project, new[] { subTreeProvider1, subTreeProvider2 });

            var result = factory.CreateRootViewModel("MyProvider1", hasUnresolvedDependency: false);

            Assert.NotNull(result);
            Assert.Equal("ZzzDependencyRoot", result.Caption);
            Assert.Equal(KnownMonikers.AboutBox, result.Icon);
        }
        public void DependenciesViewModelFactoryTests_CreateRootViewModel()
        {
            var project    = UnconfiguredProjectFactory.Create();
            var dependency = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""MyProvider1"",
    ""Id"": ""ZzzDependencyRoot"",
    ""Name"":""ZzzDependencyRoot"",
    ""Caption"":""ZzzDependencyRoot""
}", icon: KnownMonikers.AboutBox);

            var subTreeProvider1 = IProjectDependenciesSubTreeProviderFactory.Implement(
                providerType: "MyProvider1",
                createRootDependencyNode: dependency);
            var subTreeProvider2 = IProjectDependenciesSubTreeProviderFactory.Implement(
                providerType: "MyProvider2");

            var factory = new TestableDependenciesViewModelFactory(project, new[] { subTreeProvider1, subTreeProvider2 });

            var result = factory.CreateRootViewModel("MyProvider1", hasUnresolvedDependency: false);

            Assert.NotNull(result);
            Assert.Equal("ZzzDependencyRoot", result.Caption);
            Assert.Equal(KnownMonikers.AboutBox, result.Icon);
        }
        public void CreateGroupNodeViewModel()
        {
            var project = UnconfiguredProjectFactory.Create();

            var dependencyModel = new TestDependencyModel
            {
                ProviderType     = "MyProvider1",
                Id               = "ZzzDependencyRoot",
                OriginalItemSpec = "ZzzDependencyRoot",
                Caption          = "ZzzDependencyRoot",
                Icon             = KnownMonikers.AboutBox
            };

            var subTreeProvider1 = IProjectDependenciesSubTreeProviderFactory.Implement(
                providerType: "MyProvider1",
                createRootDependencyNode: dependencyModel);
            var subTreeProvider2 = IProjectDependenciesSubTreeProviderFactory.Implement(
                providerType: "MyProvider2");

            var factory = new TestableDependenciesViewModelFactory(project, new[] { subTreeProvider1, subTreeProvider2 });

            var result = factory.CreateGroupNodeViewModel("MyProvider1", maximumDiagnosticLevel: DiagnosticLevel.None);

            Assert.NotNull(result);
            Assert.Equal("ZzzDependencyRoot", result !.Caption);
            Assert.Equal(KnownMonikers.AboutBox, result.Icon);
        }
Esempio n. 4
0
        public void CreateRootViewModelReturnsNullForUnknownProviderType()
        {
            var project = UnconfiguredProjectFactory.Create();

            var subTreeProvider1 = IProjectDependenciesSubTreeProviderFactory.Implement(providerType: "MyProvider1");

            var factory = new TestableDependenciesViewModelFactory(project, new[] { subTreeProvider1 });

            var result = factory.CreateRootViewModel("UnknownProviderType", hasUnresolvedDependency: false);

            Assert.Null(result);
        }
        public void CreateGroupNodeViewModel_ReturnsNullForUnknownProviderType()
        {
            var project = UnconfiguredProjectFactory.Create();

            var subTreeProvider1 = IProjectDependenciesSubTreeProviderFactory.Implement(providerType: "MyProvider1");

            var factory = new TestableDependenciesViewModelFactory(project, new[] { subTreeProvider1 });

            var result = factory.CreateGroupNodeViewModel("UnknownProviderType", maximumDiagnosticLevel: DiagnosticLevel.None);

            Assert.Null(result);
        }