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 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 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 ExecuteCommandImpl_ShouldThrow_CodeItemAlreadyExistsException() { //Arange string partialfileName = "testPartialfileName"; string methodName = "methodName"; this.projectManager.MethodName.Returns(methodName); MethodInfo testMethodInfo = new MethodInfo() { MethodName = methodName, PartialClasses = new List <string>() { partialfileName } }; 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); //Assert Assert.Throws <Exception>(() => { //Act this.createCodeItemCmd.ExecuteCommandImpl(null, null); }, "Code item already exists."); }
public void ExecuteCommandImpl_ShouldThrow_CodeItemAlreadyExistsException() { //Arange string partialfileName = "testPartialfileName"; string methodName = "methodName"; this.projectManager.MethodName.Returns(methodName); this.projectManager.ServerMethodFolderPath.Returns(@"TEST:\Users\Vladimir\source\repos\Aras11SP15MethodProject12\Aras11SP15MethodProject12\ServerMethods\"); this.projectManager.SelectedFolderPath.Returns(@"TEST:\Users\Vladimir\source\repos\Aras11SP15MethodProject12\Aras11SP15MethodProject12\ServerMethods\MSO_Standard\Import\Method\MSO_GetAllSettings\Partials"); 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); //Assert Assert.Throws <Exception>(() => { //Act this.createCodeItemCmd.ExecuteCommandImpl(null, null); }, "Code item already exists."); }