private void migrateButton_Click(object sender, EventArgs e) { var sourceDirectory = fromDirectoryTextBox.Text; var targetDirectory = toDirectoryTextBox.Text; if (sourceDirectory == string.Empty || !Directory.Exists(sourceDirectory)) { MessageBox.Show("Must provide a valid Source Directory", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (targetDirectory == string.Empty || !Directory.Exists(targetDirectory)) { MessageBox.Show("Must provide a valid Target Directory", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var migrator = new ProjectMigrator( fromDirectoryTextBox.Text, toDirectoryTextBox.Text, checkboxSourceCode.Checked, checkboxAPI.Checked, checkboxContent.Checked, checkboxRebinding.Checked, checkboxInputs.Checked ); migrator.AttachProgressBar(progressBar, actionLabel); migrator.Migrate(); }
public void GivenRiskeerGuiWithStorageSql_WhenRunWithMigratedFile_MigratedProjectSet(string sourceFilePath) { string targetFilePath = Path.Combine(workingDirectory, nameof(GivenRiskeerGuiWithStorageSql_WhenRunWithMigratedFile_MigratedProjectSet)); MigrateFile(sourceFilePath, targetFilePath); // Given var projectStore = new StorageSqLite(); var mocks = new MockRepository(); var inquiryHelper = mocks.StrictMock <IInquiryHelper>(); mocks.ReplayAll(); var projectMigrator = new ProjectMigrator(inquiryHelper); var guiCoreSettings = new GuiCoreSettings { ApplicationIcon = SystemIcons.Application }; using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), guiCoreSettings)) { // When gui.Run(targetFilePath); // Then Assert.AreEqual(targetFilePath, gui.ProjectFilePath); Assert.NotNull(gui.Project); string expectedProjectName = Path.GetFileNameWithoutExtension(targetFilePath); Assert.AreEqual(expectedProjectName, gui.Project.Name); Assert.AreEqual("description", gui.Project.Description); Assert.IsInstanceOf <RiskeerProject>(gui.Project); } mocks.VerifyAll(); }
public void ItHasWarningWhenMigratingADeprecatedProjectJson() { var testProjectDirectory = TestAssets .GetProjectJson(TestAssetKinds.NonRestoredTestProjects, "PJDeprecatedCompile") .CreateInstance() .WithSourceFiles() .Root .GetDirectory("project") .FullName; var mockProj = ProjectRootElement.Create(); var testSettings = MigrationSettings.CreateMigrationSettingsTestHook( testProjectDirectory, testProjectDirectory, mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); var report = projectMigrator.Migrate(testSettings); var projectReport = report.ProjectMigrationReports.First(); var warningMessage = projectReport.Warnings.First(); warningMessage.Should().Contain("MIGRATE1011::Deprecated Project:"); warningMessage.Should().Contain("The 'compile' option is deprecated. Use 'compile' in 'buildOptions' instead. (line: 3, file:"); }
public void ItHasErrorWhenMigratingAProjectJsonWithoutAFrameworks() { var testInstance = TestAssets.Get( "NonRestoredTestProjects", "TestLibraryWithProjectFileWithoutFrameworks") .CreateInstance() .WithSourceFiles(); var testProjectDirectory = testInstance.Root.FullName; var mockProj = ProjectRootElement.Create(); var testSettings = MigrationSettings.CreateMigrationSettingsTestHook( testProjectDirectory, testProjectDirectory, mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); var report = projectMigrator.Migrate(testSettings); var projectReport = report.ProjectMigrationReports.First(); projectReport.Errors.First().GetFormattedErrorMessage() .Should().Contain("MIGRATE1013::No Project:") .And.Contain($"The project.json specifies no target frameworks in {testProjectDirectory}"); }
public void DetermineMigrationLocation_ValidPath_AsksUserForTargetPathAndReturnsIt() { // Setup const string originalFileName = "Im_a_valid_file_path"; const string expectedFileExtension = "risk"; string validFilePath = TestHelper.GetScratchPadPath($"{originalFileName}.{expectedFileExtension}"); string versionWithDashes = ProjectVersionHelper.GetCurrentDatabaseVersion().Replace('.', '-'); var expectedFileFilter = new FileFilterGenerator(expectedFileExtension, "Riskeer project"); string expectedSuggestedFileName = $"{originalFileName}_{versionWithDashes}"; string expectedReturnPath = TestHelper.GetScratchPadPath("Im_a_file_path_to_the_migrated_file.risk"); var mocks = new MockRepository(); var inquiryHelper = mocks.StrictMock <IInquiryHelper>(); inquiryHelper.Expect(h => h.GetTargetFileLocation(expectedFileFilter.Filter, expectedSuggestedFileName)) .Return(expectedReturnPath); mocks.ReplayAll(); var migrator = new ProjectMigrator(inquiryHelper); // Call string targetFilePath = migrator.DetermineMigrationLocation(validFilePath); // Assert Assert.AreEqual(expectedReturnPath, targetFilePath); mocks.VerifyAll(); }
public void Migrate_InvalidSourceFilePath_ThrowsArgumentException(string invalidFilePath) { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); var migrator = new ProjectMigrator(inquiryHelper); string targetFileName = $"{nameof(ProjectMigratorTest)}." + $"{nameof(Migrate_InvalidSourceFilePath_ThrowsArgumentException)}.rtd"; string targetFilePath = TestHelper.GetScratchPadPath(targetFileName); // Call void Call() => migrator.Migrate(invalidFilePath, targetFilePath); // Assert var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>( Call, "Bronprojectpad moet een geldig projectpad zijn."); Assert.AreEqual("sourceFilePath", exception.ParamName); mocks.VerifyAll(); }
public void GivenRiskeerGui_WhenRunWithUnmigratedFileAndNoInquireContinuation_MigratedProjectNotSet(string sourceFilePath) { // Given var projectStore = new StorageSqLite(); var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); inquiryHelper.Expect(helper => helper.InquireContinuation(null)) .IgnoreArguments() .Return(false); mocks.ReplayAll(); var projectMigrator = new ProjectMigrator(inquiryHelper); using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), new GuiCoreSettings())) { // When gui.Run(sourceFilePath); // Then Assert.IsNull(gui.ProjectFilePath); Assert.IsNull(gui.Project); } mocks.VerifyAll(); }
public void DetermineMigrationLocation_TargetFilePathIsEmpty_LogsMessageAndReturnsEmptyTargetPath() { // Setup const string originalFileName = "Im_a_valid_file_path"; const string expectedFileExtension = "risk"; string validFilePath = TestHelper.GetScratchPadPath($"{originalFileName}.{expectedFileExtension}"); var expectedFileFilter = new FileFilterGenerator(expectedFileExtension, "Riskeer project"); string versionWithDashes = ProjectVersionHelper.GetCurrentDatabaseVersion().Replace('.', '-'); var expectedSuggestedFileName = $"{originalFileName}_{versionWithDashes}"; var mocks = new MockRepository(); var inquiryHelper = mocks.StrictMock <IInquiryHelper>(); inquiryHelper.Expect(h => h.GetTargetFileLocation(expectedFileFilter.Filter, expectedSuggestedFileName)) .Return(null); mocks.ReplayAll(); var migrator = new ProjectMigrator(inquiryHelper); var targetFilePath = "arbitraryPath"; // Call void Call() => targetFilePath = migrator.DetermineMigrationLocation(validFilePath); // Assert var expectedLogMessage = Tuple.Create($"Het migreren van het projectbestand '{validFilePath}' is geannuleerd.", LogLevelConstant.Warn); TestHelper.AssertLogMessageWithLevelIsGenerated(Call, expectedLogMessage, 1); Assert.IsNull(targetFilePath); mocks.VerifyAll(); }
public int Execute() { var projectsToMigrate = GetProjectsToMigrate(_projectArg); var msBuildTemplate = _templateFile != null? ProjectRootElement.TryOpen(_templateFile) : _temporaryDotnetNewProject.MSBuildProject; var sdkVersion = _sdkVersion ?? _temporaryDotnetNewProject.MSBuildProject.GetSdkVersion(); EnsureNotNull(sdkVersion, "Null Sdk Version"); MigrationReport migrationReport = null; foreach (var project in projectsToMigrate) { var projectDirectory = Path.GetDirectoryName(project); var outputDirectory = projectDirectory; var migrationSettings = new MigrationSettings(projectDirectory, outputDirectory, sdkVersion, msBuildTemplate, _xprojFilePath); var projectMigrationReport = new ProjectMigrator().Migrate(migrationSettings, _skipProjectReferences); if (migrationReport == null) { migrationReport = projectMigrationReport; } else { migrationReport = migrationReport.Merge(projectMigrationReport); } } WriteReport(migrationReport); return(migrationReport.FailedProjectsCount); }
public void ShouldMigrate_OutdatedProjectUnsupported_ReturnsNotSupportedAndGeneratesLogMessages() { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); string sourceFilePath = ProjectMigrationTestHelper.GetOutdatedUnSupportedProjectFilePath(); var versionedFile = new ProjectVersionedFile(sourceFilePath); string fileVersion = versionedFile.GetVersion(); var migrator = new ProjectMigrator(inquiryHelper); var shouldMigrate = MigrationRequired.Yes; // Call void Call() => shouldMigrate = migrator.ShouldMigrate(sourceFilePath); // Assert var expectedMessage = $"Het migreren van een projectbestand met versie '{fileVersion}' naar versie '{currentDatabaseVersion}' is niet ondersteund."; TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage); Assert.AreEqual(MigrationRequired.NotSupported, shouldMigrate); mocks.VerifyAll(); }
public void It_throws_when_migrating_a_non_csharp_app() { var testProjectDirectory = TestAssetsManager.CreateTestInstance("FSharpTestProjects/TestApp", callingMethod: "z") .WithLockFiles().Path; var mockProj = ProjectRootElement.Create(); var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, "1.0.0", mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); Action migrateAction = () => projectMigrator.Migrate(testSettings); migrateAction.ShouldThrow <Exception>().Where( e => e.Message.Contains("MIGRATE20013::Non-Csharp App: Cannot migrate project")); }
public void Can_Rollback_If_Error(string scenario, string json, string xproj, string launchSettingsJson) { using (ApprovalResults.ForScenario(scenario + "_project_json")) { // arrange var testXProj = VsProjectHelper.LoadTestProject(xproj); var testFileUpgradeContext = new TestJsonBaseProjectUpgradeContext(json, testXProj, launchSettingsJson); var migrator = new ProjectMigrator(testFileUpgradeContext); var options = new ProjectMigrationOptions(ReleaseVersion.RTM); // options.UpgradeToPreview1 = true; // project.json files will be updated to the preview 1 schema. // options.UpgradePackagesToRc2 = true; // rc1 packages will be migrated to rc2 packages, including commands (migrated to tools). options.AddNetStandardTargetForLibraries = true; // libraries will have the netStandard TFM added (and dependency). options.AddNetCoreTargetForApplications = true; // applications will have the netCore app TFM added (and dependency) // add an upgrade that throws an exception.. var additionalUpgrades = new List <IProjectUpgradeAction>(); additionalUpgrades.Add(new ExceptionuringUpgradeAction()); try { // migrate migrator.Apply(options, additionalUpgrades); testFileUpgradeContext.SaveChanges(); } catch (Exception e) { // throw; } // assert. var modifiedContents = testFileUpgradeContext.ProjectJsonObject.ToString(); Approvals.Verify(modifiedContents); using (ApprovalResults.ForScenario(scenario + "_xproj")) { var projContents = VsProjectHelper.ToString(testFileUpgradeContext.VsProjectFile); Approvals.VerifyXml(projContents); } using (ApprovalResults.ForScenario(scenario + "_launchSettings")) { var modifiedLaunchSettingsContents = testFileUpgradeContext.LaunchSettingsObject.ToString(); Approvals.Verify(modifiedLaunchSettingsContents); } } }
public void Constructor_ReturnsExpectedProperties() { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); // Call var migrator = new ProjectMigrator(inquiryHelper); // Assert Assert.IsInstanceOf <IMigrateProject>(migrator); mocks.VerifyAll(); }
public void ItHasErrorWhenMigratingANonCsharpApp() { var testProjectDirectory = TestAssetsManager.CreateTestInstance("FSharpTestProjects/TestApp", callingMethod: "z") .Path; var mockProj = ProjectRootElement.Create(); var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(testProjectDirectory, testProjectDirectory, mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); var report = projectMigrator.Migrate(testSettings); var projectReport = report.ProjectMigrationReports.First(); var errorMessage = projectReport.Errors.First().GetFormattedErrorMessage(); errorMessage.Should().Contain("MIGRATE20013::Non-Csharp App: Cannot migrate project"); }
public void It_throws_when_migrating_a_deprecated_projectJson() { var testProjectDirectory = TestAssetsManager.CreateTestInstance("TestLibraryWithDeprecatedProjectFile", callingMethod: "z") .WithLockFiles().Path; var mockProj = ProjectRootElement.Create(); var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, "1.0.0", mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); Action migrateAction = () => projectMigrator.Migrate(testSettings); migrateAction.ShouldThrow <Exception>().Where( e => e.Message.Contains("MIGRATE1011::Deprecated Project:") && e.Message.Contains("The 'packInclude' option is deprecated. Use 'files' in 'packOptions' instead.") && e.Message.Contains("The 'compilationOptions' option is deprecated. Use 'buildOptions' instead.")); }
public void Migrate_UnableToSaveAtTargetFilePath_MigrationFailsAndLogsError() { // Setup string sourceFilePath = ProjectMigrationTestHelper.GetOutdatedSupportedProjectFilePath(); string targetFile = $"{nameof(ProjectMigratorTest)}." + $"{nameof(Migrate_UnableToSaveAtTargetFilePath_MigrationFailsAndLogsError)}.rtd"; string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, targetFile); var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); var logDirectory = $"{nameof(Migrate_UnableToSaveAtTargetFilePath_MigrationFailsAndLogsError)}_log"; using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), logDirectory)) using (new UseCustomSettingsHelper(new TestSettingsHelper { TempPath = TestHelper.GetScratchPadPath(logDirectory) })) using (var fileDisposeHelper = new FileDisposeHelper(targetFilePath)) { var migrator = new ProjectMigrator(inquiryHelper); fileDisposeHelper.LockFiles(); var migrationSuccessful = true; // Call void Call() => migrationSuccessful = migrator.Migrate(sourceFilePath, targetFilePath); // Assert TestHelper.AssertLogMessages(Call, messages => { string[] msgs = messages.ToArray(); Assert.AreEqual(1, msgs.Length); StringAssert.StartsWith($"Het migreren van het projectbestand '{sourceFilePath}' is mislukt: ", msgs[0]); }); Assert.IsFalse(migrationSuccessful); string logPath = Path.Combine(TestHelper.GetScratchPadPath(), logDirectory, "RiskeerMigrationLog.sqlite"); Assert.IsFalse(File.Exists(logPath)); } mocks.VerifyAll(); }
private void OnStartup(object sender, StartupEventArgs e) { ParseArguments(e.Args); DeleteOldLogFiles(); Resources.Add(SystemParameters.MenuPopupAnimationKey, PopupAnimation.None); var settings = new GuiCoreSettings { ApplicationName = "Riskeer", ApplicationIcon = ApplicationResources.Riskeer, SupportHeader = ApplicationResources.SupportHeader, SupportText = ApplicationResources.SupportText, SupportWebsiteAddressUrl = "https://iplo.nl/contact/", SupportPhoneNumber = "088-7970790", ManualFilePath = "Gebruikershandleiding Riskeer 22.1.1.pdf", MadeByBitmapImage = new BitmapImage(new Uri($"{PackUriHelper.UriSchemePack}://application:,,,/Resources/MadeBy.png")) }; var mainWindow = new MainWindow(); var projectMigrator = new ProjectMigrator(new DialogBasedInquiryHelper(mainWindow)); var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(mainWindow); var projectFactory = new RiskeerProjectFactory(() => assessmentSectionFromFileHandler.GetAssessmentSectionFromFile()); gui = new GuiCore(mainWindow, new StorageSqLite(), projectMigrator, projectFactory, settings) { Plugins = { new RiskeerPlugin(), new ClosingStructuresPlugin(), new StabilityPointStructuresPlugin(), new WaveImpactAsphaltCoverPlugin(), new GrassCoverErosionInwardsPlugin(), new GrassCoverErosionOutwardsPlugin(), new PipingPlugin(), new HeightStructuresPlugin(), new StabilityStoneCoverPlugin(), new DuneErosionPlugin(), new MacroStabilityInwardsPlugin() } }; RunRiskeer(); }
public void Migrate_MigrationLogDatabaseInUse_MigrationFailsAndLogsError() { // Setup string sourceFilePath = ProjectMigrationTestHelper.GetOutdatedSupportedProjectFilePath(); string targetFile = $"{nameof(ProjectMigratorTest)}." + $"{nameof(Migrate_MigrationLogDatabaseInUse_MigrationFailsAndLogsError)}.rtd"; string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, targetFile); var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); var logDirectory = $"{nameof(Migrate_MigrationLogDatabaseInUse_MigrationFailsAndLogsError)}_log"; string logPath = Path.Combine(TestHelper.GetScratchPadPath(), logDirectory, "RiskeerMigrationLog.sqlite"); using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), logDirectory)) using (new UseCustomSettingsHelper(new TestSettingsHelper { TempPath = TestHelper.GetScratchPadPath(logDirectory) })) using (var fileDisposeHelper = new FileDisposeHelper(logPath)) { var migrator = new ProjectMigrator(inquiryHelper); fileDisposeHelper.LockFiles(); var migrationSuccessful = true; // Call void Call() => migrationSuccessful = migrator.Migrate(sourceFilePath, targetFilePath); // Assert var logMessage = Tuple.Create( $"Het is niet mogelijk om het Riskeer logbestand '{logPath}' aan te maken.", LogLevelConstant.Error); TestHelper.AssertLogMessageWithLevelIsGenerated(Call, logMessage); Assert.IsFalse(migrationSuccessful); Assert.IsTrue(File.Exists(logPath)); } mocks.VerifyAll(); }
public void ShouldMigrate_LatestProjectVersion_ReturnsFalse() { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); string sourceFilePath = ProjectMigrationTestHelper.GetLatestProjectFilePath(); var migrator = new ProjectMigrator(inquiryHelper); // Call MigrationRequired shouldMigrate = migrator.ShouldMigrate(sourceFilePath); // Assert Assert.AreEqual(MigrationRequired.No, shouldMigrate); mocks.VerifyAll(); }
public int Execute() { var temporaryDotnetNewProject = new TemporaryDotnetNewTemplateProject(); var projectsToMigrate = GetProjectsToMigrate(_projectArg); var msBuildTemplatePath = _templateFile ?? temporaryDotnetNewProject.MSBuildProjectPath; var sdkVersion = _sdkVersion ?? temporaryDotnetNewProject.MSBuildProject.GetSdkVersion(); EnsureNotNull(sdkVersion, "Null Sdk Version"); MigrationReport migrationReport = null; foreach (var project in projectsToMigrate) { var projectDirectory = Path.GetDirectoryName(project); var outputDirectory = projectDirectory; var migrationSettings = new MigrationSettings( projectDirectory, outputDirectory, sdkVersion, msBuildTemplatePath, _xprojFilePath); var projectMigrationReport = new ProjectMigrator().Migrate(migrationSettings, _skipProjectReferences); if (migrationReport == null) { migrationReport = projectMigrationReport; } else { migrationReport = migrationReport.Merge(projectMigrationReport); } } WriteReport(migrationReport); temporaryDotnetNewProject.Clean(); MoveProjectJsonArtifactsToBackup(migrationReport); return(migrationReport.FailedProjectsCount); }
public int Execute() { var temporaryDotnetNewProject = new TemporaryDotnetNewTemplateProject(_dotnetCoreTemplateCreator); var projectsToMigrate = GetProjectsToMigrate(_projectArg); var msBuildTemplatePath = _templateFile ?? temporaryDotnetNewProject.MSBuildProjectPath; MigrationReport migrationReport = null; foreach (var project in projectsToMigrate) { var projectDirectory = Path.GetDirectoryName(project); var outputDirectory = projectDirectory; var migrationSettings = new MigrationSettings( projectDirectory, outputDirectory, msBuildTemplatePath, _xprojFilePath, null, _slnFile); var projectMigrationReport = new ProjectMigrator().Migrate(migrationSettings, _skipProjectReferences); if (migrationReport == null) { migrationReport = projectMigrationReport; } else { migrationReport = migrationReport.Merge(projectMigrationReport); } } WriteReport(migrationReport); temporaryDotnetNewProject.Clean(); UpdateSolutionFile(migrationReport); MoveProjectJsonArtifactsToBackup(migrationReport); return(migrationReport.FailedProjectsCount); }
public void Migrate_TargetPathNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); var migrator = new ProjectMigrator(inquiryHelper); string sourceFilePath = ProjectMigrationTestHelper.GetOutdatedSupportedProjectFilePath(); // Call void Call() => migrator.Migrate(sourceFilePath, null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("targetFilePath", exception.ParamName); }
public void Can_Apply(string scenario, string json) { using (ApprovalResults.ForScenario(scenario)) { // arrange var testFileUpgradeContext = new TestJsonBaseProjectUpgradeContext(json, null, null); // get target nuget packages for RC2, Preview1 tooling. var toolPackageMigrations = ProjectMigrator.GetToolPackageMigrationList(ToolingVersion.Preview2, testFileUpgradeContext); var sut = new MigrateToolPackages(toolPackageMigrations); // act sut.Apply(testFileUpgradeContext); testFileUpgradeContext.SaveChanges(); // assert. var modifiedContents = testFileUpgradeContext.ModifiedProjectJsonContents; Approvals.VerifyJson(modifiedContents); } }
public void ShouldMigrate_FilePathNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); var migrator = new ProjectMigrator(inquiryHelper); // Call void Call() => migrator.ShouldMigrate(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("filePath", exception.ParamName); mocks.VerifyAll(); }
public void It_copies_ProjectDirectory_contents_to_OutputDirectory_when_the_directories_are_different() { var testProjectDirectory = TestAssetsManager.CreateTestInstance("TestAppSimple", callingMethod: "z") .WithLockFiles().Path; var outputDirectory = Temp.CreateDirectory().Path; var projectDirectoryRelativeFilePaths = EnumerateFilesWithRelativePath(testProjectDirectory); var mockProj = ProjectRootElement.Create(); var testSettings = new MigrationSettings(testProjectDirectory, outputDirectory, "1.0.0", mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); projectMigrator.Migrate(testSettings); foreach (var projectDirectoryRelativeFilePath in projectDirectoryRelativeFilePaths) { File.Exists(Path.Combine(outputDirectory, projectDirectoryRelativeFilePath)).Should().BeTrue(); } }
public void ItHasErrorWhenMigratingADeprecatedProjectJson() { var testProjectDirectory = TestAssetsManager.CreateTestInstance("TestLibraryWithDeprecatedProjectFile", callingMethod: "z") .Path; var mockProj = ProjectRootElement.Create(); var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(testProjectDirectory, testProjectDirectory, mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); var report = projectMigrator.Migrate(testSettings); var projectReport = report.ProjectMigrationReports.First(); var errorMessage = projectReport.Errors.First().GetFormattedErrorMessage(); errorMessage.Should().Contain("MIGRATE1011::Deprecated Project:"); errorMessage.Should().Contain("The 'packInclude' option is deprecated. Use 'files' in 'packOptions' instead. (line: 6, file:"); errorMessage.Should().Contain("The 'compilationOptions' option is deprecated. Use 'buildOptions' instead. (line: 3, file:"); }
// Use this for initialization void Start() { FutileParams futileParams = new FutileParams(true, true, true, true); futileParams.AddResolutionLevel(windowRes.x, 1f, 1f, string.Empty); futileParams.origin = new Vector2(0f, 0f); Futile.instance.Init(futileParams); Futile.displayScale = 1f; // Load Resources Futile.atlasManager.LoadAtlas("Atlases/mainAtlas"); Futile.atlasManager.LoadAtlas("Atlases/fontAtlas"); Futile.atlasManager.LoadFont("Raleway32", "Raleway32", "Atlases/Raleway32", 0f, 0f); Futile.atlasManager.LoadFont("Raleway24", "Raleway24", "Atlases/Raleway24", 0f, 0f); Futile.atlasManager.LoadFont("Raleway16", "Raleway16", "Atlases/Raleway16", 0f, 0f); LoadConfigFile(); projectScrollOff = ProjectIcon.size * 0.5f; ProjectMigrator migrate = new ProjectMigrator(); activeProcess = new ProjectsProcess(); }
public void Can_Apply(string scenario, string json, string xproj, string launchSettings, ReleaseVersion version) { using (ApprovalResults.ForScenario(scenario + "_project_json")) { // arrange var testXProj = VsProjectHelper.LoadTestProject(xproj); var testFileUpgradeContext = new TestJsonBaseProjectUpgradeContext(json, testXProj, launchSettings, new [] { "appSettings.json" }); var migrator = new ProjectMigrator(testFileUpgradeContext); var options = new ProjectMigrationOptions(version); // options.UpgradeToPreview1 = true; // project.json files will be updated to the preview 1 schema. // options.UpgradePackagesToRc2 = true; // rc1 packages will be migrated to rc2 packages, including commands (migrated to tools). options.AddNetStandardTargetForLibraries = true; // libraries will have the netStandard TFM added (and dependency). options.AddNetCoreTargetForApplications = true; // applications will have the netCore app TFM added (and dependency) // migrate migrator.Apply(options); // save the changes. testFileUpgradeContext.SaveChanges(); // assert. var modifiedContents = testFileUpgradeContext.ModifiedProjectJsonContents; Approvals.Verify(modifiedContents); // Approvals.VerifyJson(modifiedContents); using (ApprovalResults.ForScenario(scenario + "_xproj")) { var projContents = VsProjectHelper.ToString(testFileUpgradeContext.VsProjectFile); Approvals.VerifyXml(projContents); } using (ApprovalResults.ForScenario(scenario + "_launchSettings")) { var modifiedLaunchSettingsContents = testFileUpgradeContext.ModifiedLaunchSettingsJsonContents; Approvals.Verify(modifiedLaunchSettingsContents); } } }
public void DetermineMigrationLocation_InvalidOriginalFilePath_ThrowsArgumentException(string invalidFilePath) { // Setup var mocks = new MockRepository(); var inquiryHelper = mocks.Stub <IInquiryHelper>(); mocks.ReplayAll(); var migrator = new ProjectMigrator(inquiryHelper); // Call void Call() => migrator.DetermineMigrationLocation(invalidFilePath); // Assert var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>( Call, "Bronprojectpad moet een geldig projectpad zijn."); Assert.AreEqual("originalFilePath", exception.ParamName); mocks.VerifyAll(); }
public void ItCopiesProjectDirectoryContentsToOutputDirectoryWhenTheDirectoriesAreDifferent() { var testProjectDirectory = TestAssetsManager .CreateTestInstance("PJTestAppSimple", callingMethod: "z") .Path; var outputDirectory = Temp.CreateDirectory().Path; var projectDirectoryRelativeFilePaths = EnumerateFilesWithRelativePath(testProjectDirectory); var mockProj = ProjectRootElement.Create(); var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(testProjectDirectory, outputDirectory, mockProj); var projectMigrator = new ProjectMigrator(new FakeEmptyMigrationRule()); projectMigrator.Migrate(testSettings); foreach (var projectDirectoryRelativeFilePath in projectDirectoryRelativeFilePaths) { File.Exists(Path.Combine(outputDirectory, projectDirectoryRelativeFilePath)).Should().BeTrue(); } }