public void TestOnBrowseStackdriverLogCommand() { string filter = null; var logsToolWindowMock = new Mock <LogsViewerToolWindow> { CallBase = true }; logsToolWindowMock.Setup(w => w.ViewModel.FilterLog(It.IsAny <string>())).Callback((string s) => filter = s); logsToolWindowMock.Object.Frame = VsWindowFrameMocks.GetMockedWindowFrame(); PackageMock.Setup( p => p.FindToolWindow <LogsViewerToolWindow>(false, It.IsAny <int>())) .Returns(() => null); PackageMock.Setup(p => p.FindToolWindow <LogsViewerToolWindow>(true, It.IsAny <int>())) .Returns(logsToolWindowMock.Object); var objectUnderTest = new VersionViewModel( new GaeSourceRootViewModel(), Mock.Of <Service>(s => s.Id == "ServiceId" && s.Split.Allocations == new Dictionary <string, double?>()), new Version { Id = "VersionId" }, true); MenuItem logsMenuItem = objectUnderTest.ContextMenu.ItemsSource.OfType <MenuItem>().Single( mi => mi.Header.Equals(Resources.CloudExplorerLaunchLogsViewerMenuHeader)); logsMenuItem.Command.Execute(null); StringAssert.Contains(filter, "resource.type=\"gae_app\""); StringAssert.Contains(filter, "resource.labels.module_id=\"ServiceId\""); StringAssert.Contains(filter, "resource.labels.version_id=\"VersionId\""); }
protected override void BeforeEach() { _analyticsOptions = new AnalyticsOptions(); PackageMock.Setup(p => p.AnalyticsSettings).Returns(_analyticsOptions); _promptAnalyticsMock = new Mock <Func <bool> >(); EventsReporterWrapper.PromptAnalyticsOptIn = _promptAnalyticsMock.Object; }
public void BeforeEach() { _propertyServiceMock = new Mock <IVsProjectPropertyService>(); PackageMock.Setup(p => p.GetMefService <IVsProjectPropertyService>()).Returns(_propertyServiceMock.Object); var mockedApiManager = Mock.Of <IApiManager>(m => m.AreServicesEnabledAsync(It.IsAny <IList <string> >()) == Task.FromResult(true) && m.EnableServicesAsync(It.IsAny <IEnumerable <string> >()) == Task.FromResult(true)); PackageMock.Setup(p => p.GetMefService <IApiManager>()).Returns(mockedApiManager); _getInstanceListTaskSource = new TaskCompletionSource <IList <Instance> >(); var mockedDataSource = Mock.Of <IGceDataSource>(ds => ds.GetInstanceListAsync() == _getInstanceListTaskSource.Task); _windowsCredentialStoreMock = new Mock <IWindowsCredentialsStore>(); _manageCredentialsPromptMock = new Mock <Action <Instance> >(); _mockedProject = Mock.Of <DteProject>(p => p.ConfigurationManager.ConfigurationRowNames == new string[0]); _objectUnderTest = new GceStepViewModel( mockedDataSource, _windowsCredentialStoreMock.Object, _manageCredentialsPromptMock.Object, Mock.Of <IPublishDialog>( pd => pd.Project.Name == VisualStudioProjectName && pd.Project.Project == _mockedProject)); _changedProperties = new List <string>(); _objectUnderTest.PropertyChanged += (sender, args) => _changedProperties.Add(args.PropertyName); }
protected override void BeforeEach() { _propertyServiceMock = new Mock <IVsProjectPropertyService>(); PackageMock.Setup(p => p.GetMefService <IVsProjectPropertyService>()).Returns(_propertyServiceMock.Object); _parsedProject = new FakeParsedProject { Name = VisualStudioProjectName }; _parsedProject.ProjectMock.Setup(p => p.ConfigurationManager.ConfigurationRowNames).Returns(new string[0]); _pickProjectPromptMock = new Mock <Func <Project> >(); _changedProperties = new List <string>(); var mockedApiManager = Mock.Of <IApiManager>( x => x.AreServicesEnabledAsync(It.IsAny <IList <string> >()) == Task.FromResult(true) && x.EnableServicesAsync(It.IsAny <IEnumerable <string> >()) == Task.FromResult(true)); _getClusterListTaskSource = new TaskCompletionSource <IList <Cluster> >(); var mockedDataSource = Mock.Of <IGkeDataSource>(ds => ds.GetClusterListAsync() == _getClusterListTaskSource.Task); _objectUnderTest = new GkeStepViewModel( mockedDataSource, mockedApiManager, _pickProjectPromptMock.Object, Mock.Of <IPublishDialog>(pd => pd.Project == _parsedProject)); _objectUnderTest.PropertyChanged += (sender, args) => _changedProperties.Add(args.PropertyName); _objectUnderTest.PublishCommand.CanExecuteChanged += (sender, args) => _canPublishChangedCount++; _startProcessMock = new Mock <Func <string, Process> >(); _objectUnderTest._startProcessOverride = _startProcessMock.Object; }
public void TestOnBrowseStackdriverLogCommand() { var logsToolWindowMock = new Mock <LogsViewerToolWindow> { CallBase = true }; logsToolWindowMock.Object.Frame = VsWindowFrameMocks.GetMockedWindowFrame(); PackageMock.Setup( p => p.FindToolWindow <LogsViewerToolWindow>(false, It.IsAny <int>())) .Returns(() => null); PackageMock.Setup( p => p.FindToolWindow <LogsViewerToolWindow>(true, It.IsAny <int>())) .Returns(logsToolWindowMock.Object); string filter = null; logsToolWindowMock.Setup(w => w.ViewModel.FilterLog(It.IsAny <string>())).Callback((string s) => filter = s); var objectUnderTest = new GceInstanceViewModel( new GceSourceRootViewModel(Mock.Of <IGceDataSource>()), new Instance { Id = 1 }); MenuItem logsMenuItem = objectUnderTest.ContextMenu.ItemsSource.OfType <MenuItem>().Single( mi => mi.Header as string == Resources.CloudExplorerLaunchLogsViewerMenuHeader); logsMenuItem.Command.Execute(null); StringAssert.Contains(filter, "resource.type=\"gce_instance\""); StringAssert.Contains(filter, "resource.labels.instance_id=\"1\""); }
public void TestGetRemoteDebuggerPort_Success(string version, int expectedPort) { PackageMock.Setup(p => p.VsVersion).Returns(version); int result = VsVersionUtils.GetRemoteDebuggerPort(); Assert.AreEqual(expectedPort, result); }
public void TestRefreshCommand_RefreshesResourceManagerDataSource() { _testObject = new PickProjectIdViewModel(DefaultHelpText, false); _testObject.RefreshCommand.Execute(null); PackageMock.Verify(p => p.DataSourceFactory.ResourceManagerDataSource.RefreshProjects()); }
public void BeforeEach() { _getProfileTaskSource = new TaskCompletionSource <Person>(); _dataSourceFactoryMock = new Mock <IDataSourceFactory>(); _dataSourceFactoryMock.Setup(dsf => dsf.CreatePlusDataSource(It.IsAny <GoogleCredential>()).GetProfileAsync()) .Returns(_getProfileTaskSource.Task); PackageMock.Setup(p => p.DataSourceFactory).Returns(_dataSourceFactoryMock.Object); }
protected override void BeforeEach() { _processServiceMock = new Mock <IProcessService>(); SetupRunCommandResult(true); PackageMock.Setup(p => p.ProcessService).Returns(_processServiceMock.Object); _objectUnderTest = new GCloudContext(); _mockedOutputAction = Mock.Of <Action <string> >(); }
public void TestSignIn_PromptsForNoUser() { CredentialStoreMock.Setup(cs => cs.CurrentAccount).Returns(() => null); _objectUnderTest.SignIn(); PackageMock.Verify(p => p.UserPromptService.PromptUser(It.IsAny <ManageAccountsWindowContent>())); }
public void TestGetToolsPathProvider_GetsVs15Provider() { PackageMock.Setup(p => p.VsVersion).Returns(VsVersionUtils.VisualStudio2017Version); IToolsPathProvider result = VsVersionUtils.GetToolsPathProvider(); Assert.IsInstanceOfType(result, typeof(GoogleCloudExtension.VsVersion.VS15.ToolsPathProvider)); }
public void TestDefault_DefersToPackage() { var expectedFactory = Mock.Of <IDataSourceFactory>(); PackageMock.Setup(p => p.DataSourceFactory).Returns(expectedFactory); Assert.AreEqual(expectedFactory, DataSourceFactory.Default); }
protected override void BeforeEach() { _propertyServiceMock = new Mock <IVsProjectPropertyService>(); PackageMock.Setup(p => p.GetMefService <IVsProjectPropertyService>()).Returns(_propertyServiceMock.Object); _mockedProject = Mock.Of <Project>(); _mockedParsedProject = Mock.Of <IParsedDteProject>(p => p.Project == _mockedProject); }
public void BeforeEach() { _browserServiceMock = new Mock <IBrowserService>(); PackageMock.Setup(p => p.GetMefServiceLazy <IBrowserService>()) .Returns(_browserServiceMock.ToLazy()); _objectUnderTest = new AnalyticsOptInWindowViewModel(); }
public void TestNoLoadWhenMinimized() { _listLogEntriesSource.SetException(new DataSourceException("")); PackageMock.Setup(p => p.IsWindowActive()).Returns(false); _objectUnderTest.OnAutoReloadCommand.Execute(null); Assert.IsFalse(_objectUnderTest.AsyncAction.IsError); }
protected override void BeforeEach() { _dteMock = new Mock <DTE>(); _dteMock.Setup(dte => dte.FullName).Returns(DefaultDevenvPath); PackageMock.Setup(p => p.GetService <SDTE, DTE>()).Returns(_dteMock.Object); _objectUnderTest = new ToolsPathProvider(); }
public void BeforeEach() { _processServiceMock = new Mock <IProcessService>(); _versionResultSource = new TaskCompletionSource <CloudSdkVersions>(); SetupGetJsonOutput("version", _versionResultSource.Task); PackageMock.Setup(p => p.ProcessService).Returns(_processServiceMock.Object); _objectUnderTest = new GCloudContext(); _mockedOutputAction = Mock.Of <Func <string, Task> >(); }
public void TestGetAvailableAspNetCoreVersions_ForVS2017NetCore20() { PackageMock.Setup(p => p.VsVersion).Returns(VsVersionUtils.VisualStudio2017Version); _toolsPathProviderMock.Setup(p => p.GetNetCoreSdkVersions()).Returns(new[] { "2.0.35" }); IList <AspNetVersion> results = AspNetVersion.GetAvailableAspNetCoreVersions(FrameworkType.NetCore); CollectionAssert.AreEqual(new[] { AspNetVersion.AspNetCore20 }, results.ToList()); }
public void TestShowToolWindowNoWindowFrame() { PackageMock.Setup(p => p.FindToolWindow <ToolWindowPane>(true, 0)) .Returns(() => new ToolWindowPane { Frame = null }); ToolWindowCommandUtils.ShowToolWindow <ToolWindowPane>(); }
public async Task TestShowToolWindowNoWindowFrame() { PackageMock.Setup(p => p.FindToolWindow <ToolWindowPane>(true, 0)) .Returns(new ToolWindowPane { Frame = null }); await ToolWindowCommandUtils.ShowToolWindowAsync <ToolWindowPane>(); }
public void BeforeEach() { _targetSdkVersions = new List <string>(); // ReSharper disable once PossibleUnintendedReferenceComparison VsVersionUtils.s_toolsPathProviderOverride = Mock.Of <IToolsPathProvider>(tpp => tpp.GetNetCoreSdkVersions() == _targetSdkVersions); _closeWindowMock = new Mock <Action>(); PackageMock.Setup(p => p.VsVersion).Returns(VsVersionUtils.VisualStudio2017Version); }
public void TestInitialConditionsVs2015MissingNetCoreSdk() { PackageMock.Setup(p => p.VsVersion).Returns(VsVersionUtils.VisualStudio2015Version); var objectUnderTest = new AspNetCoreTemplateChooserViewModel(_closeWindowMock.Object); Assert.IsTrue(objectUnderTest.NetCoreMissingError); Assert.IsFalse(objectUnderTest.OkCommand.CanExecuteCommand); }
public void BeforeEach() { _dteMock = new Mock <DTE2>(); _dteMock.Setup(dte => dte.FullName).Returns(DefaultDevenvPath); PackageMock.Setup(p => p.Dte).Returns(_dteMock.Object); _objectUnderTest = new ToolsPathProvider(); }
public async Task TestDispose_NonReentrant() { _objectUnderTest = await KubectlContext.GetForClusterAsync(DefaultCluster, DefaultZone); _objectUnderTest.Dispose(); _objectUnderTest.Dispose(); PackageMock.Verify(p => p.GetMefService <IFileSystem>().File.Delete(It.IsAny <string>()), Times.Once); }
public void TestAutoReloadCommandWithWindowMinimized() { CreateErrorScenario(); PackageMock.Setup(p => p.IsWindowActive()).Returns(false); _objectUnderTest.OnAutoReloadCommand.Execute(null); Assert.IsFalse(_objectUnderTest.ShowError); }
public void TestConstructor_SetsProjectId() { const string expectedProjectId = "expected-project-id"; PackageMock.SetupGet(p => p.CredentialsStore.CurrentProjectId).Returns(expectedProjectId); var objectUnderTest = new GCloudContext(); Assert.AreEqual(expectedProjectId, objectUnderTest.ProjectId); }
public void TestChangeUserCommandNoUser() { CredentialStoreMock.SetupGet(cs => cs.CurrentAccount).Returns(() => null); _testObject = new PickProjectIdViewModel(DefaultHelpText, false); _testObject.ChangeUserCommand.Execute(null); PackageMock.Verify(p => p.UserPromptService.PromptUser(It.IsAny <ManageAccountsWindowContent>())); Assert.IsNull(_testObject.LoadTask); }
protected override void BeforeEach() { _environmentMock = new Mock <IEnvironment>(); _environmentMock.Setup(e => e.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)) .Returns(DefaultX86ProgramFilesPath); PackageMock.Setup(p => p.GetMefServiceLazy <IEnvironment>()).Returns(_environmentMock.ToLazy()); _objectUnderTest = new ToolsPathProvider(); }
public void BeforeEach() { _testObject = null; _projectTaskSource = new TaskCompletionSource <IList <Project> >(); PackageMock.Setup(p => p.DataSourceFactory.ResourceManagerDataSource.ProjectsListTask) .Returns(() => _projectTaskSource.Task); _properiesChanged = new List <string>(); _testObject = new PickProjectIdViewModel(DefaultHelpText, false); _testObject.PropertyChanged += (sender, args) => _properiesChanged.Add(args.PropertyName); }
public void TestGetToolsPathProvider_ThrowsNotSupportedException() { const string expectedUnknownVersion = "ExpectedUnknownVersion"; PackageMock.Setup(p => p.VsVersion).Returns(expectedUnknownVersion); var e = Assert.ThrowsException <NotSupportedException>(VsVersionUtils.GetToolsPathProvider); StringAssert.Contains(e.Message, expectedUnknownVersion); }
public void TestAddPackageToDependencyMap() { // Arrange string packageName = "KittenService", dependencyName = "CamelCaser"; var expectedPackage = new PackageMock() { Name = packageName, Dependency = new PackageMock() { Name = dependencyName } }; // Act var actualPackage = dependencyMap.AddPackage(packageName, dependencyName); // Assert Assert.AreEqual(expectedPackage, actualPackage); }