示例#1
0
        public void ExecCommand_VerifyCorrectFrameworkSet(int cmdIndex, bool expected)
        {
            var frameworks = new List <string>()
            {
                "net461", "netcoreapp1.0"
            };
            var activeDebugFrameworkSvcs = new IActiveDebugFrameworkServicesMock()
                                           .ImplementGetActiveDebuggingFrameworkPropertyAsync(null)
                                           .ImplementGetProjectFrameworksAsync(frameworks);

            if (expected)
            {
                activeDebugFrameworkSvcs.ImplementSetActiveDebuggingFrameworkPropertyAsync(frameworks[cmdIndex]);
            }
            var startupHelper = new Mock <IStartupProjectHelper>();

            startupHelper.Setup(x => x.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles))
            .Returns(activeDebugFrameworkSvcs.Object);

            var command = new TestDebugFrameworksDynamicMenuCommand(startupHelper.Object);

            Assert.Equal(expected, command.ExecCommand(cmdIndex, EventArgs.Empty));

            startupHelper.Verify();
            activeDebugFrameworkSvcs.Verify();
        }
示例#2
0
        public void QueryStatus_TestValidFrameworkIndexes(int cmdIndex, string activeFramework)
        {
            var frameworks = new List <string>()
            {
                "netcoreapp1.0", "net461", "net462"
            };

            var activeDebugFrameworkSvcs = new IActiveDebugFrameworkServicesMock()
                                           .ImplementGetProjectFrameworksAsync(frameworks)
                                           .ImplementGetActiveDebuggingFrameworkPropertyAsync(activeFramework);

            var startupHelper = new Mock <IStartupProjectHelper>();

            startupHelper.Setup(x => x.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles))
            .Returns(activeDebugFrameworkSvcs.Object);

            var command = new TestDebugFrameworksDynamicMenuCommand(startupHelper.Object);

            Assert.True(command.QueryStatusCommand(cmdIndex, EventArgs.Empty));
            Assert.True(command.Visible);
            Assert.Equal(frameworks[cmdIndex], command.Text);
            Assert.Equal(frameworks[cmdIndex] == activeFramework, command.Checked);
            Assert.True(command.Enabled);

            startupHelper.Verify();
            activeDebugFrameworkSvcs.Verify();
        }
        public void QueryStatus_MultipleStartupProjects_DifferentFrameworks()
        {
            var activeDebugFrameworkSvcs1 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetActiveDebuggingFrameworkPropertyAsync("netcoreapp1.0")
                                            .ImplementGetProjectFrameworksAsync(new List <string>()
            {
                "net461", "netcoreapp1.0"
            });

            var activeDebugFrameworkSvcs2 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetActiveDebuggingFrameworkPropertyAsync("netcoreapp1.0")
                                            .ImplementGetProjectFrameworksAsync(new List <string>()
            {
                "net45", "netcoreapp1.0"
            });

            var startupHelper = new Mock <IStartupProjectHelper>();

            startupHelper.Setup(x => x.GetExportFromDotNetStartupProjects <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles))
            .Returns(ImmutableArray.Create(activeDebugFrameworkSvcs1.Object, activeDebugFrameworkSvcs2.Object));

            var command = CreateInstance(startupHelper.Object);

            Assert.True(command.QueryStatusCommand(0, EventArgs.Empty));
            Assert.False(command.Visible);
            Assert.Equal("", command.Text);
            Assert.False(command.Checked);
            Assert.False(command.Enabled);

            startupHelper.Verify();
            activeDebugFrameworkSvcs1.Verify();
            activeDebugFrameworkSvcs2.Verify();
        }
示例#4
0
        public void QueryStatus_MultipleStartupProjects_LessThan2Frameworks(bool createList)
        {
            var activeDebugFrameworkSvcs1 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetProjectFrameworksAsync(createList ? new List <string>()
            {
                "netcoreapp1.0"
            } : null);

            var activeDebugFrameworkSvcs2 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetProjectFrameworksAsync(createList ? new List <string>()
            {
                "netcoreapp1.0"
            } : null);

            var startupHelper = new Mock <IStartupProjectHelper>();

            startupHelper.Setup(x => x.GetExportFromDotNetStartupProjects <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles))
            .Returns(ImmutableArray.Create(activeDebugFrameworkSvcs1.Object, activeDebugFrameworkSvcs2.Object));

            var command = new TestDebugFrameworksDynamicMenuCommand(startupHelper.Object);

            Assert.True(command.QueryStatusCommand(0, EventArgs.Empty));
            Assert.False(command.Visible);
            Assert.Equal("", command.Text);
            Assert.False(command.Checked);
            Assert.False(command.Enabled);

            startupHelper.Verify();
            activeDebugFrameworkSvcs1.Verify();
            activeDebugFrameworkSvcs2.Verify();
        }
示例#5
0
        public void QueryStatus_NullFrameworks()
        {
            var activeDebugFrameworkSvcs = new IActiveDebugFrameworkServicesMock()
                                           .ImplementGetProjectFrameworksAsync(null);
            var startupHelper = new Mock <IStartupProjectHelper>();

            startupHelper.Setup(x => x.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles))
            .Returns(activeDebugFrameworkSvcs.Object);

            var command = new TestDebugFrameworksDynamicMenuCommand(startupHelper.Object);

            Assert.True(command.QueryStatusCommand(0, EventArgs.Empty));
            Assert.False(command.Visible);
            Assert.Equal("", command.Text);
            Assert.False(command.Checked);
            Assert.False(command.Enabled);

            startupHelper.Verify();
            activeDebugFrameworkSvcs.Verify();
        }
        public void QueryStatus_MultipleStartupProjects_TestValidFrameworkIndexes(int cmdIndex, string activeFramework)
        {
            var frameworks1 = new List <string>()
            {
                "netcoreapp1.0", "net461", "net462"
            };

            var activeDebugFrameworkSvcs1 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetProjectFrameworksAsync(frameworks1)
                                            .ImplementGetActiveDebuggingFrameworkPropertyAsync(activeFramework);

            var frameworks2 = new List <string>()
            {
                "netcoreapp1.0", "net461", "net462"
            };

            var activeDebugFrameworkSvcs2 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetProjectFrameworksAsync(frameworks2)
                                            .ImplementGetActiveDebuggingFrameworkPropertyAsync(activeFramework);

            var startupHelper = new Mock <IStartupProjectHelper>();

            startupHelper.Setup(x => x.GetExportFromDotNetStartupProjects <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles))
            .Returns(ImmutableArray.Create(activeDebugFrameworkSvcs1.Object, activeDebugFrameworkSvcs2.Object));

            var command = CreateInstance(startupHelper.Object);

            Assert.True(command.QueryStatusCommand(cmdIndex, EventArgs.Empty));
            Assert.True(command.Visible);
            Assert.Equal(frameworks1[cmdIndex], command.Text);
            Assert.Equal(frameworks1[cmdIndex] == activeFramework, command.Checked);
            Assert.Equal(frameworks2[cmdIndex], command.Text);
            Assert.Equal(frameworks2[cmdIndex] == activeFramework, command.Checked);
            Assert.True(command.Enabled);

            startupHelper.Verify();
            activeDebugFrameworkSvcs1.Verify();
            activeDebugFrameworkSvcs2.Verify();
        }
        public void ExecCommand_MultipleStartupProjects_VerifyCorrectFrameworkSet(int cmdIndex, bool expected)
        {
            var frameworks1 = new List <string>()
            {
                "net461", "netcoreapp1.0"
            };
            var activeDebugFrameworkSvcs1 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetActiveDebuggingFrameworkPropertyAsync(null)
                                            .ImplementGetProjectFrameworksAsync(frameworks1);

            var frameworks2 = new List <string>()
            {
                "net461", "netcoreapp1.0"
            };
            var activeDebugFrameworkSvcs2 = new IActiveDebugFrameworkServicesMock()
                                            .ImplementGetActiveDebuggingFrameworkPropertyAsync(null)
                                            .ImplementGetProjectFrameworksAsync(frameworks2);

            if (expected)
            {
                activeDebugFrameworkSvcs1.ImplementSetActiveDebuggingFrameworkPropertyAsync(frameworks1[cmdIndex]);
                activeDebugFrameworkSvcs2.ImplementSetActiveDebuggingFrameworkPropertyAsync(frameworks2[cmdIndex]);
            }
            var startupHelper = new Mock <IStartupProjectHelper>();

            startupHelper.Setup(x => x.GetExportFromDotNetStartupProjects <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles))
            .Returns(ImmutableArray.Create(activeDebugFrameworkSvcs1.Object, activeDebugFrameworkSvcs2.Object));

            var command = CreateInstance(startupHelper.Object);

            Assert.Equal(expected, command.ExecCommand(cmdIndex, EventArgs.Empty));

            startupHelper.Verify();
            activeDebugFrameworkSvcs1.Verify();
            activeDebugFrameworkSvcs2.Verify();
        }