public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfiguration = new ProjectConfiguraiton(); defaultCodeProvider = new DefaultCodeProvider(); codeProvider = new CSharpCodeProvider(projectManager, projectConfiguration, defaultCodeProvider); }
public void Setup() { this.innovatorUser = new InnovatorUser(); this.serverConnection = Substitute.For <IServerConnection>(); this.innovatorInstance = new Innovator(this.serverConnection); this.iOMWrapper = Substitute.For <IIOMWrapper>(); this.authManager = new AuthenticationManagerProxy(serverConnection, innovatorInstance, innovatorUser, iOMWrapper); this.dialogFactory = Substitute.For <IDialogFactory>(); this.projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); this.projectConfiguration = Substitute.For <IProjectConfiguraiton>(); this.templateLoader = new TemplateLoader(dialogFactory); this.packageManager = new PackageManager(authManager); ConnectionInfo testConnectionInfo = new ConnectionInfo() { LastConnection = true }; this.projectConfiguration.Connections.Returns(new List <ConnectionInfo>() { testConnectionInfo }); this.openFromArasViewModel = new OpenFromArasViewModel(authManager, dialogFactory, projectConfigurationManager, projectConfiguration, templateLoader, packageManager, "tesPathToProjectConfigFile", "testProjectName", "testProjectFullName", "testProjectLanguage"); }
public CSharpCodeProvider(IProjectManager projectManager, IProjectConfiguraiton projectConfiguration, DefaultCodeProvider defaultCodeProvider, ICodeItemProvider codeItemProvider, IIOWrapper iOWrapper, IDialogFactory dialogFactory) { if (projectManager == null) { throw new ArgumentNullException(nameof(projectManager)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (defaultCodeProvider == null) { throw new ArgumentNullException(nameof(defaultCodeProvider)); } if (codeItemProvider == null) { throw new ArgumentNullException(nameof(codeItemProvider)); } if (iOWrapper == null) { throw new ArgumentNullException(nameof(iOWrapper)); } this.projectManager = projectManager; this.defaultCodeProvider = defaultCodeProvider; this.projectConfiguration = projectConfiguration; this.codeItemProvider = codeItemProvider; this.iOWrapper = iOWrapper; this.dialogFactory = dialogFactory; }
public void UpdateProjectConfiguration(IProjectConfiguraiton projectConfiguration, IProjectManager projectManager) { ProjectItems serverMethods = projectManager.ServerMethodFolderItems; if (serverMethods.Count == 0) { projectConfiguration.MethodInfos.Clear(); return; } var updatedMethodInfos = new List <MethodInfo>(); foreach (MethodInfo methodInfo in projectConfiguration.MethodInfos) { if (!projectManager.IsMethodExist(methodInfo.Package.MethodFolderPath, methodInfo.MethodName)) { continue; } MethodInfo updatedMethodInfo; if (methodInfo is PackageMethodInfo) { updatedMethodInfo = new PackageMethodInfo((PackageMethodInfo)methodInfo); } else { updatedMethodInfo = new MethodInfo(methodInfo); } updatedMethodInfos.Add(updatedMethodInfo); } projectConfiguration.MethodInfos = updatedMethodInfos; }
public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfigurationManager = new ProjectConfigurationManager(); dialogFactory = Substitute.For <IDialogFactory>(); authManager = new AuthManagerStub(); codeProviderFactory = Substitute.For <ICodeProviderFactory>(); globalConfiguration = Substitute.For <IGlobalConfiguration>();; CreateMethodCmd.Initialize(projectManager, authManager, dialogFactory, projectConfigurationManager, codeProviderFactory, globalConfiguration); createMethodCmd = CreateMethodCmd.Instance; iVsUIShell = Substitute.For <IVsUIShell>(); var currentPath = AppDomain.CurrentDomain.BaseDirectory; projectManager.ProjectConfigPath.Returns(Path.Combine(currentPath, "TestData\\projectConfig.xml")); projectManager.MethodConfigPath.Returns(Path.Combine(currentPath, "TestData\\method-config.xml")); template = new TemplateInfo { TemplateName = string.Empty }; eventSpecificDataType = new EventSpecificDataType { EventSpecificData = EventSpecificData.None }; templateLoader = new TemplateLoader(dialogFactory); packageManager = new PackageManager(authManager); codeProvider = Substitute.For <ICodeProvider>(); projectConfiguration = projectConfigurationManager.Load(projectManager.ProjectConfigPath); templateLoader.Load(projectManager.MethodConfigPath); codeProviderFactory.GetCodeProvider(null, null).ReturnsForAnyArgs(codeProvider); }
public OpenFromArasViewModel( IAuthenticationManager authenticationManager, IDialogFactory dialogFactory, IProjectConfigurationManager configurationManager, IProjectConfiguraiton projectConfiguration, TemplateLoader templateLoader, PackageManager packageManager, string pathToProjectConfigFile, string projectName, string projectFullName, string projectLanguage) { if (authenticationManager == null) { throw new ArgumentNullException(nameof(authenticationManager)); } if (dialogFactory == null) { throw new ArgumentNullException(nameof(dialogFactory)); } if (configurationManager == null) { throw new ArgumentNullException(nameof(configurationManager)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (templateLoader == null) { throw new ArgumentNullException(nameof(templateLoader)); } if (packageManager == null) { throw new ArgumentNullException(nameof(packageManager)); } this.authenticationManager = authenticationManager; this.dialogFactory = dialogFactory; this.configurationManager = configurationManager; this.projectConfiguration = projectConfiguration; this.templateLoader = templateLoader; this.packageManager = packageManager; this.pathToProjectConfigFile = pathToProjectConfigFile; this.projectName = projectName; this.projectFullName = projectFullName; this.projectLanguage = projectLanguage; this.isUseVSFormattingCode = projectConfiguration.UseVSFormatting; this.editConnectionInfoCommand = new RelayCommand <object>(EditConnectionInfoCommandClicked); this.searchMethodDialogCommand = new RelayCommand <object>(SearchMethodDialogCommandClicked); this.okCommand = new RelayCommand <object>(OkCommandCliked, IsEnabledOkButton); this.closeCommand = new RelayCommand <object>(OnCloseCliked); ConnectionInformation = projectConfiguration.Connections.First(c => c.LastConnection); SelectedEventSpecificData = EventSpecificData.First(); }
public UpdateFromArasViewModel( IAuthenticationManager authManager, IProjectConfigurationManager projectConfigurationManager, IProjectConfiguraiton projectConfiguration, TemplateLoader templateLoader, PackageManager packageManager, MethodInfo methodInfo, string projectConfigPath, string projectName, string projectFullName) { if (authManager == null) { throw new ArgumentNullException(nameof(authManager)); } if (projectConfigurationManager == null) { throw new ArgumentNullException(nameof(projectConfigurationManager)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (templateLoader == null) { throw new ArgumentNullException(nameof(templateLoader)); } if (packageManager == null) { throw new ArgumentNullException(nameof(packageManager)); } if (methodInfo == null) { throw new ArgumentNullException(nameof(methodInfo)); } this.authManager = authManager; this.projectConfigurationManager = projectConfigurationManager; this.projectConfiguration = projectConfiguration; this.templateLoader = templateLoader; this.packageManager = packageManager; this.projectConfigPath = projectConfigPath; this.projectName = projectName; this.projectFullName = projectFullName; this.isUseVSFormattingCode = projectConfiguration.UseVSFormatting; this.methodName = methodInfo.MethodName; this.eventData = methodInfo.EventData; this.editConnectionInfoCommand = new RelayCommand <object>(EditConnectionInfoCommandClick); this.okCommand = new RelayCommand <object>(OkCommandClick, IsEnabledOkButton); this.closeCommand = new RelayCommand <object>(OnCloseCliked); ConnectionInformation = projectConfiguration.Connections.First(c => c.LastConnection); UpdateMethodView(null); }
public void Setup() { this.innovatorUser = new InnovatorUser(); this.serverConnection = Substitute.For <IServerConnection>(); this.innovatorInstance = new Innovator(this.serverConnection); this.iOMWrapper = Substitute.For <IIOMWrapper>(); this.authManager = new AuthenticationManagerProxy(serverConnection, innovatorInstance, innovatorUser, iOMWrapper); this.dialogFactory = Substitute.For <IDialogFactory>(); this.projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); this.projectConfiguration = Substitute.For <IProjectConfiguraiton>(); this.messageManager = Substitute.For <MessageManager>(); this.packageManager = new PackageManager(authManager, messageManager); this.arasDataProvider = Substitute.For <IArasDataProvider>(); this.methodInformation = new MethodInfo(); this.templateLoader = new TemplateLoader(); this.projectManager = Substitute.For <IProjectManager>(); this.codeProvider = Substitute.For <ICodeProvider>(); this.globalConfiguration = Substitute.For <IGlobalConfiguration>(); this.globalConfiguration.GetUserCodeTemplatesPaths().Returns(new List <string>()); this.serverConnection.When(x => x.CallAction("ApplyItem", Arg.Is <XmlDocument>(doc => doc.DocumentElement.Attributes["type"].Value == "Value"), Arg.Any <XmlDocument>())) .Do(x => { (x[2] as XmlDocument).Load(Path.Combine(currentPath, @"Dialogs\ViewModels\TestData\ActionLocationsListValue.xml")); }); this.serverConnection.When(x => x.CallAction("ApplyItem", Arg.Is <XmlDocument>(doc => doc.DocumentElement.Attributes["type"].Value == "Filter Value"), Arg.Any <XmlDocument>())) .Do(x => { (x[2] as XmlDocument).Load(Path.Combine(currentPath, @"Dialogs\ViewModels\TestData\MethodTypesListFilterValue.xml")); }); this.projectConfiguration.LastSavedSearch.Returns(new Dictionary <string, List <PropertyInfo> >()); XmlDocument methodItemTypeAML = new XmlDocument(); methodItemTypeAML.Load(Path.Combine(currentPath, @"Dialogs\ViewModels\TestData\MethodItemType.xml")); Item methodItemType = this.innovatorInstance.newItem(); methodItemType.loadAML(methodItemTypeAML.OuterXml); this.arasDataProvider.GetMethodItemTypeInfo().Returns(new MethodItemTypeInfo(methodItemType, messageManager)); this.createMethodViewModel = new CreateMethodViewModel(authManager, dialogFactory, projectConfiguration, templateLoader, packageManager, projectManager, arasDataProvider, codeProvider, globalConfiguration, messageManager); }
public void SetUp() { this.dialogFactory = Substitute.For <IDialogFactory>(); templateLoader = new TemplateLoader(this.dialogFactory); this.projectConfiguration = Substitute.For <IProjectConfiguraiton>(); this.projectConfiguration.LastSelectedSearchTypeInOpenFromPackage.Returns("MethodContent"); openFromPackageViewModel = new OpenFromPackageViewModel(this.dialogFactory, templateLoader, "C#", this.projectConfiguration); }
public DebugMethodViewModel( IAuthenticationManager authManager, IProjectConfigurationManager projectConfigurationManager, IProjectConfiguraiton projectConfiguration, MethodInfo methodInformation, IDialogFactory dialogFactory, string methodCode, string projectConfigPath, string projectName, string projectFullName) { if (authManager == null) { throw new ArgumentNullException(nameof(authManager)); } if (projectConfigurationManager == null) { throw new ArgumentNullException(nameof(projectConfigurationManager)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (methodInformation == null) { throw new ArgumentNullException(nameof(methodInformation)); } if (dialogFactory == null) { throw new ArgumentNullException(nameof(dialogFactory)); } this.authManager = authManager; this.projectConfigurationManager = projectConfigurationManager; this.projectConfiguration = projectConfiguration; this.dialogFactory = dialogFactory; this.projectConfigPath = projectConfigPath; this.projectName = projectName; this.projectFullName = projectFullName; this.okCommand = new RelayCommand <object>(OkCommandClick); this.closeCommand = new RelayCommand <object>(OnCloseCliked); this.editConnectionInfoCommand = new RelayCommand <object>(EditConnectionInfoCommandClick); this.methodCode = methodCode; this.methodContext = $"<Item action=\"{methodInformation.MethodName}\" type=\"Method\" />"; this.methodType = methodInformation.MethodType; this.methodLanguage = methodInformation.MethodLanguage; this.templateName = methodInformation.TemplateName; this.eventData = methodInformation.EventData.ToString(); this.methodName = methodInformation.MethodName; //TODO: How to know current connection? ConnectionInformation = projectConfiguration.Connections.First(c => c.LastConnection); }
public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfiguration = new ProjectConfiguraiton(); iOWrapper = Substitute.For <IIOWrapper>(); defaultCodeProvider = new DefaultCodeProvider(iOWrapper); codeItemProvider = Substitute.For <ICodeItemProvider>(); dialogFactory = Substitute.For <IDialogFactory>(); codeProvider = new CSharpCodeProvider(projectManager, projectConfiguration, defaultCodeProvider, codeItemProvider, iOWrapper, dialogFactory); }
public IViewAdaper <LoginView, ViewResult> GetLoginView(IProjectConfiguraiton projectConfiguration, string projectName, string projectFullName) { var view = new LoginView(); var viewModel = new LoginViewModel(authManager, projectConfiguration, projectName, projectFullName); view.DataContext = viewModel; AttachToParentWindow(view); return(new LoginViewAdapter(view)); }
public IViewAdaper <CreateMethodView, CreateMethodViewResult> GetCreateView(IProjectConfiguraiton projectConfiguration, TemplateLoader templateLoader, PackageManager packageManager, IProjectManager projectManager, ICodeProvider codeProvider, IGlobalConfiguration globalConfiguration) { CreateMethodView view = new CreateMethodView(); CreateMethodViewModel viewModel = new CreateMethodViewModel(authManager, this, projectConfiguration, templateLoader, packageManager, projectManager, arasDataProvider, codeProvider, globalConfiguration); view.DataContext = viewModel; AttachToParentWindow(view); return(new CreateMethodViewAdapter(view)); }
public void ExecuteCommandImpl_Partial_ShouldSaveConfigfile() { //Arange string partialfileName = "testPartialfileName"; string methodName = "methodName"; Project selectedProject = Substitute.For <Project>(); selectedProject.CodeModel.Language.Returns("C#"); this.projectManager.MethodName.Returns(methodName); this.projectManager.ServerMethodFolderPath.Returns(@"C:\Users\Vladimir\source\repos\Aras11SP15MethodProject12\Aras11SP15MethodProject12\ServerMethods\"); this.projectManager.SelectedFolderPath.Returns(@"C:\Users\Vladimir\source\repos\Aras11SP15MethodProject12\Aras11SP15MethodProject12\ServerMethods\MSO_Standard\Import\Method\MSO_GetAllSettings\Partials"); this.projectManager.SelectedProject.Returns(selectedProject); this.projectManager.ProjectConfigPath.Returns("ProjectConfigPath"); MethodInfo testMethodInfo = new MethodInfo() { MethodName = methodName, Package = new PackageInfo("MSO_Standard") }; IProjectConfiguraiton projectConfiguraiton = Substitute.For <IProjectConfiguraiton>(); projectConfiguraiton.MethodInfos.Returns(new List <MethodInfo>() { testMethodInfo }); projectConfigurationManager.CurrentProjectConfiguraiton.Returns(projectConfiguraiton); CreateCodeItemViewAdaper createCodeItemViewAdaper = new CreateCodeItemViewAdaper(partialfileName, Aras.Method.Libs.Code.CodeType.Partial, true); this.dialogFactory.GetCreateCodeItemView(Arg.Any <ICodeItemProvider>(), Arg.Any <bool>()).Returns(createCodeItemViewAdaper); ICodeProvider codeProvider = Substitute.For <ICodeProvider>(); CodeInfo codeItemInfo = new CodeInfo() { Code = "code", Path = @"path\testPartialfileName.cs" }; codeProviderFactory.GetCodeProvider("C#").Returns(codeProvider); codeProvider.CreatePartialCodeItemInfo(testMethodInfo, partialfileName, Arg.Any <CodeElementType>(), Arg.Any <bool>(), projectManager.ServerMethodFolderPath, projectManager.SelectedFolderPath, projectManager.MethodName, this.templateLoader, projectManager.MethodPath) .Returns(codeItemInfo); //Act this.createCodeItemCmd.ExecuteCommandImpl(null, null); //Assert this.projectConfigurationManager.Received().Save("ProjectConfigPath"); }
public void Setup() { this.serverConnection = Substitute.For <IServerConnection>(); this.innovator = new Innovator(this.serverConnection); this.authManager = new AuthenticationManagerProxy(this.serverConnection, innovator, new InnovatorUser(), Substitute.For <IIOMWrapper>()); this.dialogFactory = Substitute.For <IDialogFactory>(); IProjectConfiguraiton projectConfiguration = Substitute.For <IProjectConfiguraiton>(); this.projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); projectConfigurationManager.CurrentProjectConfiguraiton.Returns(projectConfiguration); this.messageManager = Substitute.For <MessageManager>(); this.packageManager = new PackageManager(authManager, messageManager); this.arasDataProvider = Substitute.For <IArasDataProvider>(); this.methodInformation = new MethodInfo() { Package = new PackageInfo(string.Empty) }; XmlDocument methodItemTypeXmlDocument = new XmlDocument(); methodItemTypeXmlDocument.Load(Path.Combine(currentPath, @"Dialogs\ViewModels\TestData\MethodItemType.xml")); Item methodItem = this.innovator.newItem(); methodItem.loadAML(methodItemTypeXmlDocument.OuterXml); MethodItemTypeInfo methodItemTypeInfo = new MethodItemTypeInfo(methodItem, messageManager); arasDataProvider.GetMethodItemTypeInfo().Returns(methodItemTypeInfo); List <ConnectionInfo> connectionInfos = new List <ConnectionInfo>() { new ConnectionInfo() { Login = "******", Database = "testDataBase", ServerUrl = "testServerUrl", LastConnection = true } }; projectConfiguration.Connections.Returns(connectionInfos); saveMethodViewModel = new SaveMethodViewModel(this.authManager, this.dialogFactory, this.projectConfigurationManager, this.packageManager, this.arasDataProvider, this.methodInformation, this.messageManager, "methodCode", "projectConfPath", "projectName", "projectFullName"); }
public void ExecuteCommandImpl_External_ShouldSaveConfigfile() { //Arange string externalfileName = "testExternalFileName"; string methodName = "methodName"; Project selectedProject = Substitute.For <Project>(); selectedProject.CodeModel.Language.Returns("C#"); this.projectManager.MethodName.Returns(methodName); this.projectManager.SelectedProject.Returns(selectedProject); this.projectManager.ProjectConfigPath.Returns("ProjectConfigPath"); MethodInfo testMethodInfo = new MethodInfo() { MethodName = methodName }; IProjectConfiguraiton projectConfiguraiton = Substitute.For <IProjectConfiguraiton>(); projectConfiguraiton.MethodInfos.Returns(new List <MethodInfo>() { testMethodInfo }); projectConfigurationManager.CurrentProjectConfiguraiton.Returns(projectConfiguraiton); CreateCodeItemViewAdaper createCodeItemViewAdaper = new CreateCodeItemViewAdaper(externalfileName, Aras.Method.Libs.Code.CodeType.External, true); this.dialogFactory.GetCreateCodeItemView(Arg.Any <ICodeItemProvider>(), Arg.Any <bool>()).Returns(createCodeItemViewAdaper); ICodeProvider codeProvider = Substitute.For <ICodeProvider>(); CodeInfo codeItemInfo = new CodeInfo() { Code = "code", Path = @"path\testExternalFileName.cs" }; codeProviderFactory.GetCodeProvider("C#").Returns(codeProvider); codeProvider.CreateExternalCodeItemInfo(testMethodInfo, externalfileName, Arg.Any <CodeElementType>(), Arg.Any <bool>(), this.projectManager.ServerMethodFolderPath, this.projectManager.SelectedFolderPath, this.projectManager.MethodName, this.templateLoader, this.projectManager.MethodPath) .Returns(codeItemInfo); //Act this.createCodeItemCmd.ExecuteCommandImpl(null, null); //Assert this.projectConfigurationManager.Received().Save("ProjectConfigPath"); }
public VBCodeProvider(Project project, IProjectConfiguraiton projectConfiguration) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } this.project = project; this.projectConfiguration = projectConfiguration; }
public void Init() { serverConnection = Substitute.For <IServerConnection>(); Innovator innovatorIns = new Innovator(serverConnection); this.authManager = new AuthenticationManagerProxy(this.serverConnection, innovatorIns, new InnovatorUser(), Substitute.For <IIOMWrapper>()); this.dialogFactory = Substitute.For <IDialogFactory>(); this.projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); this.projectConfiguration = Substitute.For <IProjectConfiguraiton>(); this.messageManager = Substitute.For <MessageManager>(); this.packageManager = new PackageManager(this.authManager, this.messageManager); this.templateLoader = new TemplateLoader(); this.codeProvider = Substitute.For <ICodeProvider>(); this.projectManager = Substitute.For <IProjectManager>(); this.arasDataProvider = Substitute.For <IArasDataProvider>(); this.iOWrapper = Substitute.For <IIOWrapper>(); this.methodInformation = new MethodInfo() { MethodName = string.Empty, Package = new PackageInfo(string.Empty) }; this.projectConfiguration.LastSavedSearch.Returns(new Dictionary <string, List <PropertyInfo> >()); XmlDocument methodItemTypeDoc = new XmlDocument(); methodItemTypeDoc.Load(Path.Combine(currentPath, @"Dialogs\ViewModels\TestData\MethodItemType.xml")); Item methodItemType = innovatorIns.newItem(); methodItemType.loadAML(methodItemTypeDoc.OuterXml); MethodItemTypeInfo methodItemTypeInfo = new MethodItemTypeInfo(methodItemType, messageManager); this.arasDataProvider.GetMethodItemTypeInfo().Returns(methodItemTypeInfo); string pathToFileForSave = Path.Combine(currentPath, @"Dialogs\ViewModels\TestData\MethodAml\ReturnNullMethodAml.xml"); this.saveToPackageViewModel = new SaveToPackageViewModel(authManager, dialogFactory, projectConfiguration, templateLoader, packageManager, codeProvider, projectManager, arasDataProvider, iOWrapper, messageManager, methodInformation, pathToFileForSave); }
public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); dialogFactory = Substitute.For <IDialogFactory>(); messageManager = Substitute.For <MessageManager>(); cmdBaseTest = new CmdBaseTest(projectManager, dialogFactory, projectConfigurationManager, messageManager); IProjectConfiguraiton projectConfiguraiton = Substitute.For <IProjectConfiguraiton>(); projectConfiguraiton.Connections.Returns(Substitute.For <List <ConnectionInfo> >()); projectConfiguraiton.MethodInfos.Returns(Substitute.For <List <MethodInfo> >()); projectConfigurationManager.CurrentProjectConfiguraiton.Returns(projectConfiguraiton); }
public void ExecuteCommandImpl_ShouldAddPartialClassesAndSaveConfigfile() { //Arange string partialfileName = "testPartialfileName"; string methodName = "methodName"; Project selectedProject = Substitute.For <Project>(); selectedProject.CodeModel.Language.Returns("C#"); this.projectManager.MethodName.Returns(methodName); this.projectManager.SelectedProject.Returns(selectedProject); this.projectManager.ProjectConfigPath.Returns("ProjectConfigPath"); MethodInfo testMethodInfo = new MethodInfo() { MethodName = methodName, PartialClasses = new List <string>() }; IProjectConfiguraiton projectConfiguraiton = Substitute.For <IProjectConfiguraiton>(); projectConfiguraiton.MethodInfos.Returns(new List <MethodInfo>() { testMethodInfo }); this.projectConfigurationManager.Load(Arg.Any <string>()).Returns(projectConfiguraiton); CreateCodeItemViewAdaper createCodeItemViewAdaper = new CreateCodeItemViewAdaper(partialfileName, MethodPlugin.Code.CodeType.Partial, true); this.dialogFactory.GetCreateCodeItemView(Arg.Any <ICodeItemProvider>(), Arg.Any <bool>()).Returns(createCodeItemViewAdaper); ICodeProvider codeProvider = Substitute.For <ICodeProvider>(); CodeInfo codeItemInfo = new CodeInfo() { Code = "code", Path = @"path\testPartialfileName.cs" }; codeProviderFactory.GetCodeProvider("C#", projectConfiguraiton).Returns(codeProvider); codeProvider.CreateCodeItemInfo(testMethodInfo, partialfileName, Arg.Any <MethodPlugin.Code.CodeType>(), Arg.Any <CodeElementType>(), Arg.Any <bool>()).Returns(codeItemInfo); //Act this.createCodeItemCmd.ExecuteCommandImpl(null, null); //Assert Assert.IsTrue(testMethodInfo.PartialClasses.Contains(codeItemInfo.Path)); this.projectConfigurationManager.Received().Save("ProjectConfigPath", projectConfiguraiton); }
public void Save(string configFilePath, IProjectConfiguraiton configuration) { XmlDocument xmlDoc = MapProjectConfigToXmlDoc(configuration); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UTF8Encoding(true); settings.Indent = true; settings.IndentChars = "\t"; settings.NewLineOnAttributes = false; settings.OmitXmlDeclaration = true; using (XmlWriter xmlWriter = XmlWriter.Create(configFilePath, settings)) { xmlDoc.Save(xmlWriter); } //xmlDoc.Save(configFilePath); }
public void ExecuteCommandImpl_ShouldThrowException() { //Arange IProjectConfiguraiton projectConfiguraiton = Substitute.For <IProjectConfiguraiton>(); projectConfiguraiton.MethodInfos.Returns(new List <MethodInfo>()); this.projectConfigurationManager.Load(Arg.Any <string>()).Returns(projectConfiguraiton); //Assert Assert.Throws <Exception>(() => { //Act this.createCodeItemCmd.ExecuteCommandImpl(null, null); }); }
public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfigurationManager = Substitute.For <ProjectConfigurationManager>(); dialogFactory = Substitute.For <IDialogFactory>(); codeProviderFactory = Substitute.For <ICodeProviderFactory>(); CreatePartialElementCmd.Initialize(projectManager, dialogFactory, projectConfigurationManager, codeProviderFactory); createPartialElementCmd = CreatePartialElementCmd.Instance; iVsUIShell = Substitute.For <IVsUIShell>(); var currentPath = AppDomain.CurrentDomain.BaseDirectory; projectManager.ProjectConfigPath.Returns(Path.Combine(currentPath, "TestData\\projectConfig.xml")); projectManager.MethodName.Returns("TestMethod"); projectConfiguration = projectConfigurationManager.Load(projectManager.ProjectConfigPath); projectConfiguration.UseVSFormatting = false; codeProvider = Substitute.For <ICodeProvider>(); codeProviderFactory.GetCodeProvider(null, null).ReturnsForAnyArgs(codeProvider); }
public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfigurationManager = Substitute.For <ProjectConfigurationManager>(); dialogFactory = Substitute.For <IDialogFactory>(); authManager = new AuthManagerStub(); codeProviderFactory = Substitute.For <ICodeProviderFactory>(); codeProvider = Substitute.For <ICodeProvider>(); codeProviderFactory.GetCodeProvider(null, null).ReturnsForAnyArgs(codeProvider); iVsUIShell = Substitute.For <IVsUIShell>(); var currentPath = AppDomain.CurrentDomain.BaseDirectory; projectManager.ProjectConfigPath.Returns(Path.Combine(currentPath, "TestData\\projectConfig.xml")); projectConfiguration = projectConfigurationManager.Load(projectManager.ProjectConfigPath); projectManager.MethodName.Returns("TestMethod"); projectManager.MethodPath.Returns(Path.Combine(currentPath, "TestData\\TestMethod.txt")); DebugMethodCmd.Initialize(projectManager, authManager, dialogFactory, projectConfigurationManager, codeProviderFactory); debugMethodCmd = DebugMethodCmd.Instance; var project = Substitute.For <Project>(); var properties = Substitute.For <EnvDTE.Properties>(); var property = Substitute.For <Property>(); var propertiesForActiveConfigurations = Substitute.For <EnvDTE.Properties>(); var propertyForActiveConfiguration = Substitute.For <Property>(); var configurationManager = Substitute.For <ConfigurationManager>(); var activeConfigurator = Substitute.For <Configuration>(); projectManager.SelectedProject.Returns(project); project.FileName.Returns(currentPath); project.Properties.Returns(properties); properties.Item(Arg.Any <string>()).Returns(property); property.Value = ""; project.ConfigurationManager.Returns(configurationManager); configurationManager.ActiveConfiguration.Returns(activeConfigurator); activeConfigurator.Properties.Returns(propertiesForActiveConfigurations); propertiesForActiveConfigurations.Item(Arg.Any <string>()).Returns(propertyForActiveConfiguration); propertyForActiveConfiguration.Value = ""; projectManager.When(x => x.AttachToProcess(Arg.Any <System.Diagnostics.Process>())).Do(x => { }); var codeModel = Substitute.For <CodeModel>(); project.CodeModel.Returns(codeModel); codeModel.Language.Returns(""); }
public CSharpCodeProvider(IProjectManager projectManager, IProjectConfiguraiton projectConfiguration, DefaultCodeProvider defaultCodeProvider) { if (projectManager == null) { throw new ArgumentNullException(nameof(projectManager)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (defaultCodeProvider == null) { throw new ArgumentNullException(nameof(defaultCodeProvider)); } this.projectManager = projectManager; this.defaultCodeProvider = defaultCodeProvider; this.projectConfiguration = projectConfiguration; }
public void Setup() { this.innovatorUser = new InnovatorUser(); this.serverConnection = Substitute.For <IServerConnection>(); this.innovator = new Innovator(this.serverConnection); this.authenticationManager = new AuthenticationManagerProxy(this.serverConnection, this.innovator, this.innovatorUser, Substitute.For <IIOMWrapper>()); List <ConnectionInfo> connectionInfo = new List <ConnectionInfo>(); this.projectConfiguraiton = Substitute.For <IProjectConfiguraiton>(); this.projectConfiguraiton.Connections.Returns(connectionInfo); this.loginViewModel = new LoginViewModel(this.authenticationManager, this.projectConfiguraiton, "testProjectName", "testProjectFullName"); }
public ICodeProvider GetCodeProvider(string projectLanguageCode, IProjectConfiguraiton projectConfiguration) { string projectLanguage = string.Empty; ICodeProvider codeProvider = null; if (projectLanguageCode == CodeModelLanguageConstants.vsCMLanguageCSharp) { codeProvider = new CSharpCodeProvider(projectManager, projectConfiguration, defaultCodeProvider); } else if (projectLanguageCode == CodeModelLanguageConstants.vsCMLanguageVB) { codeProvider = new VBCodeProvider(projectManager.SelectedProject, projectConfiguration); } else { throw new NotSupportedException("Current project type is not supported"); } return(codeProvider); }
public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfigurationManager = Substitute.For <ProjectConfigurationManager>(); dialogFactory = Substitute.For <IDialogFactory>(); authManager = Substitute.For <IAuthenticationManager>(); codeProviderFactory = Substitute.For <ICodeProviderFactory>(); codeProvider = Substitute.For <ICodeProvider>(); codeProviderFactory.GetCodeProvider(null, null).ReturnsForAnyArgs(codeProvider); OpenFromPackageCmd.Initialize(projectManager, authManager, dialogFactory, projectConfigurationManager, codeProviderFactory); openFromPackageCmd = OpenFromPackageCmd.Instance; iVsUIShell = Substitute.For <IVsUIShell>(); var currentPath = AppDomain.CurrentDomain.BaseDirectory; projectManager.ProjectConfigPath.Returns(Path.Combine(currentPath, "TestData\\projectConfig.xml")); projectConfiguration = projectConfigurationManager.Load(projectManager.ProjectConfigPath); templateLoader = new TemplateLoader(); projectManager.MethodConfigPath.Returns(Path.Combine(currentPath, "TestData\\method-config.xml")); templateLoader.Load(projectManager.MethodConfigPath); }
public void Init() { authManager = Substitute.For <IAuthenticationManager>(); projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); dialogFactory = Substitute.For <IDialogFactory>(); projectManager = Substitute.For <IProjectManager>(); codeProviderFactory = Substitute.For <ICodeProviderFactory>(); messageManager = Substitute.For <MessageManager>(); authenticationCommandBaseTest = new AuthenticationCommandBaseTest(authManager, dialogFactory, projectManager, projectConfigurationManager, codeProviderFactory, messageManager); IProjectConfiguraiton projectConfiguraiton = Substitute.For <IProjectConfiguraiton>(); projectConfiguraiton.Connections.Returns(Substitute.For <List <ConnectionInfo> >()); projectConfiguraiton.MethodInfos.Returns(Substitute.For <List <MethodInfo> >()); projectConfigurationManager.When(x => x.Load(projectManager.ProjectConfigPath)) .Do(callback => { projectConfigurationManager.CurrentProjectConfiguraiton.Returns(projectConfiguraiton); }); }
public void Setup() { this.authenticationManager = Substitute.For <IAuthenticationManager>(); this.projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); this.projectConfiguration = Substitute.For <IProjectConfiguraiton>(); this.dialogFactory = Substitute.For <IDialogFactory>(); this.methodInformation = new MethodInfo(); this.connectionInfos = new List <ConnectionInfo>() { new ConnectionInfo() { Login = "******", Database = "testDataBase", ServerUrl = "testServerUrl", LastConnection = true } }; this.projectConfiguration.Connections.Returns(this.connectionInfos); }