Esempio n. 1
0
        public async Task WhenSwitchingToInstanceNode_ThenGridIsPopulated()
        {
            var broker = new Mock <IGlobalSessionBroker>();

            broker.Setup(b => b.IsConnected(
                             It.IsAny <InstanceLocator>()))
            .Returns(false);
            var viewModel = new ConnectionSettingsViewModel(
                this.service,
                broker.Object);

            var node = new Mock <IProjectModelInstanceNode>();

            node.SetupGet(n => n.Instance).Returns(
                new InstanceLocator(SampleProjectId, "zone-1", "instance-1"));
            node.SetupGet(n => n.DisplayName).Returns("display");
            node.SetupGet(n => n.OperatingSystem).Returns(OperatingSystems.Windows);

            await viewModel.SwitchToModelAsync(node.Object);

            // Switch again.
            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsNotNull(viewModel.InspectedObject);
            StringAssert.Contains(ConnectionSettingsViewModel.DefaultWindowTitle, viewModel.WindowTitle);
            StringAssert.Contains("display", viewModel.WindowTitle);
        }
        public async Task WhenSwitchingToProjectNode_ThenGridIsPopulated()
        {
            var viewModel = new ConnectionSettingsViewModel(this.service);

            var node = new Mock <IProjectExplorerProjectNode>();

            node.SetupGet(n => n.ProjectId).Returns(SampleProjectId);
            node.SetupGet(n => n.DisplayName).Returns("display");

            await viewModel.SwitchToModelAsync(node.Object);

            // Switch again.
            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsNotNull(viewModel.InspectedObject);
            StringAssert.Contains(ConnectionSettingsViewModel.DefaultWindowTitle, viewModel.WindowTitle);
            StringAssert.Contains("display", viewModel.WindowTitle);
        }
        public async Task WhenSwitchingToCloudNode_ThenGridIsDisabled()
        {
            var viewModel = new ConnectionSettingsViewModel(this.service);

            var node = new Mock <IProjectExplorerCloudNode>();
            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsFalse(viewModel.IsInformationBarVisible);
            Assert.IsNull(viewModel.InspectedObject);
            Assert.AreEqual(ConnectionSettingsViewModel.DefaultWindowTitle, viewModel.WindowTitle);
        }
Esempio n. 4
0
        public async Task WhenSwitchingToZoneNode_ThenGridIsPopulated()
        {
            var viewModel = new ConnectionSettingsViewModel();
            var model     = CreateModel();

            var node = new Mock <IProjectExplorerZoneNode>();

            node.SetupGet(n => n.ProjectId).Returns("project-1");
            node.SetupGet(n => n.ZoneId).Returns("zone-1");
            node.SetupGet(n => n.DisplayName).Returns("display");
            node.SetupGet(n => n.SettingsEditor).Returns(model);

            await viewModel.SwitchToModelAsync(node.Object);

            // Switch again.
            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsNotNull(viewModel.InspectedObject);
            StringAssert.Contains(ConnectionSettingsViewModel.DefaultWindowTitle, viewModel.WindowTitle);
            StringAssert.Contains("display", viewModel.WindowTitle);
        }
        public async Task WhenInstanceIsNotRunning_ThenInformationBarIsNotShown()
        {
            var viewModel = new ConnectionSettingsViewModel(this.service);

            var node = new Mock <IProjectExplorerVmInstanceNode>();

            node.SetupGet(n => n.ProjectId).Returns(SampleProjectId);
            node.SetupGet(n => n.ZoneId).Returns("zone-1");
            node.SetupGet(n => n.InstanceName).Returns("instance-1");
            node.SetupGet(n => n.IsConnected).Returns(false);

            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsFalse(viewModel.IsInformationBarVisible);
        }
        public async Task WhenInstanceIsRunning_ThenInformationBarIsShown()
        {
            var viewModel = new ConnectionSettingsViewModel(this.service);

            var node = new Mock <IProjectExplorerInstanceNode>();

            node.SetupGet(n => n.Instance).Returns(
                new InstanceLocator(SampleProjectId, "zone-1", "instance-1"));
            node.SetupGet(n => n.IsConnected).Returns(true);
            node.SetupGet(n => n.IsWindowsInstance).Returns(true);

            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsTrue(viewModel.IsInformationBarVisible);
        }
Esempio n. 7
0
        public async Task WhenInstanceIsRunning_ThenInformationBarIsShown()
        {
            var viewModel = new ConnectionSettingsViewModel();
            var model     = CreateModel();

            var node = new Mock <IProjectExplorerVmInstanceNode>();

            node.SetupGet(n => n.ProjectId).Returns("project-1");
            node.SetupGet(n => n.ZoneId).Returns("zone-1");
            node.SetupGet(n => n.InstanceName).Returns("instance-1");
            node.SetupGet(n => n.SettingsEditor).Returns(model);
            node.SetupGet(n => n.IsConnected).Returns(true);

            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsTrue(viewModel.IsInformationBarVisible);
        }
Esempio n. 8
0
        public async Task WhenSwitchingToCloudNode_ThenGridIsDisabled()
        {
            var broker = new Mock <IGlobalSessionBroker>();

            broker.Setup(b => b.IsConnected(
                             It.IsAny <InstanceLocator>()))
            .Returns(false);
            var viewModel = new ConnectionSettingsViewModel(
                this.service,
                broker.Object);

            var node = new Mock <IProjectModelCloudNode>();
            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsFalse(viewModel.IsInformationBarVisible);
            Assert.IsNull(viewModel.InspectedObject);
            Assert.AreEqual(ConnectionSettingsViewModel.DefaultWindowTitle, viewModel.WindowTitle);
        }
Esempio n. 9
0
        public async Task WhenInstanceIsNotRunning_ThenInformationBarIsNotShown()
        {
            var broker = new Mock <IGlobalSessionBroker>();

            broker.Setup(b => b.IsConnected(
                             It.IsAny <InstanceLocator>()))
            .Returns(false);
            var viewModel = new ConnectionSettingsViewModel(
                this.service,
                broker.Object);

            var node = new Mock <IProjectModelInstanceNode>();

            node.SetupGet(n => n.Instance).Returns(
                new InstanceLocator(SampleProjectId, "zone-1", "instance-1"));
            node.SetupGet(n => n.OperatingSystem).Returns(OperatingSystems.Windows);

            await viewModel.SwitchToModelAsync(node.Object);

            Assert.IsFalse(viewModel.IsInformationBarVisible);
        }