Beispiel #1
0
        public void Visibility()
        {
            var settings = Substitute.For <IRSettings>();
            // NSub does not work with dynamic, see "https://github.com/nsubstitute/NSubstitute/issues/143"
            var dte = new DteMock();
            var cbs = Substitute.For <CommandBars.CommandBars>();

            dte.CommandBars = cbs;

            var cb = Substitute.For <CommandBar>();

            cbs["R Toolbar"].Returns(cb);
            var tb = new RToolbar(dte, settings);

            tb.Show();
            cb.Visible.Should().BeFalse();

            settings.ShowRToolbar.Returns(true);
            tb.Show();
            cb.Visible.Should().BeTrue();

            tb.SaveState();
            settings.ShowRToolbar.Should().BeTrue();

            cb.Visible = false;
            tb.SaveState();
            settings.ShowRToolbar.Should().BeFalse();
        }
        public async Task TestPackageValues()
        {
            const string mockedVersion = "MockVsVersion";
            const string mockedEdition = "MockedEdition";

            DteMock.Setup(dte => dte.Version).Returns(mockedVersion);
            DteMock.Setup(dte => dte.Edition).Returns(mockedEdition);

            await RunPackageInitializeAsync();

            string expectedAssemblyVersion = GetVsixManifestVersion();

            Assert.AreEqual(mockedVersion, GoogleCloudExtensionPackage.Instance.VsVersion);
            Assert.AreEqual(mockedEdition, GoogleCloudExtensionPackage.Instance.VsEdition);
            Assert.AreEqual(ExpectedAssemblyName, GoogleCloudExtensionPackage.Instance.ApplicationName);
            Assert.AreEqual(expectedAssemblyVersion, GoogleCloudExtensionPackage.Instance.ApplicationVersion);
            Assert.AreEqual(
                $"{ExpectedAssemblyName}/{expectedAssemblyVersion}",
                GoogleCloudExtensionPackage.Instance.VersionedApplicationName);
            Assert.AreEqual(
                GoogleCloudExtensionPackage.Instance.ApplicationVersion,
                GoogleCloudExtensionPackage.Instance.GeneralSettings.InstalledVersion);
            Assert.IsNull(GoogleCloudExtensionPackage.Instance.GeneralSettings.ClientId);
            Assert.IsFalse(GoogleCloudExtensionPackage.Instance.GeneralSettings.DialogShown);
            Assert.IsFalse(GoogleCloudExtensionPackage.Instance.GeneralSettings.OptIn);
        }
Beispiel #3
0
        public async Task TestWindowActiveWhenNormalState()
        {
            DteMock.Setup(d => d.MainWindow).Returns(Mock.Of <Window>(w => w.WindowState == vsWindowState.vsWindowStateNormal));

            await RunPackageInitalizeAsync();

            Assert.IsTrue(_objectUnderTest.IsWindowActive());
        }
        public async Task TestWindowActiveWhenMinimizedState()
        {
            DteMock.Setup(d => d.MainWindow).Returns(Mock.Of <Window>(w => w.WindowState == vsWindowState.vsWindowStateMinimize));

            await RunPackageInitializeAsync();

            Assert.IsFalse(_objectUnderTest.IsWindowActive());
        }
        public void TestWindowActiveWhenMaximizedState()
        {
            DteMock.Setup(d => d.MainWindow).Returns(Mock.Of <Window>(w => w.WindowState == vsWindowState.vsWindowStateMaximize));

            RunPackageInitalize();

            Assert.IsTrue(_objectUnderTest.IsWindowActive());
        }