コード例 #1
0
        public async Task RefreshLaunchSettings_returns_expected_Profile()
        {
            var solutionFileName = Util.GetSampleProject("aspnetcore-empty-22", "aspnetcore-empty-22.sln");

            solution = (Solution)await MonoDevelop.Projects.Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            var project = (DotNetProject)solution.GetAllProjects().Single();

            var launchProfileProvider = new LaunchProfileProvider(project.BaseDirectory, project.DefaultNamespace);

            launchProfileProvider.LoadLaunchSettings();

            Assert.That(launchProfileProvider.ProfilesObject, Is.Not.Null);
            Assert.That(launchProfileProvider.GlobalSettings, Is.Not.Empty);
            Assert.That(project.RunConfigurations, Has.Count.EqualTo(1));

            //modifiying launchSettings.json externally and loading it again
            System.IO.File.WriteAllText(launchProfileProvider.LaunchSettingsJsonPath, LaunchSettings);
            solution = (Solution)await MonoDevelop.Projects.Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            project = (DotNetProject)solution.GetAllProjects().Single();

            var config = project.GetDefaultRunConfiguration() as AspNetCoreRunConfiguration;

            Assert.That(config, Is.Not.Null, "GetDefaultRunConfiguration cast to AspNetCoreRunConfiguration is null");
            Assert.That(project.RunConfigurations, Has.Count.EqualTo(3));
            Assert.That(config.CurrentProfile, Is.Not.Null);
        }
コード例 #2
0
        public async Task Checks_Adding_Removing_Profiles()
        {
            var solutionFileName = Util.GetSampleProject("aspnetcore-empty-22", "aspnetcore-empty-22.sln");

            solution = (Solution)await MonoDevelop.Projects.Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            var project = (DotNetProject)solution.GetAllProjects().Single();

            var launchProfileProvider = new LaunchProfileProvider(project.BaseDirectory, project.DefaultNamespace);

            launchProfileProvider.LoadLaunchSettings();

            Assert.That(launchProfileProvider.ProfilesObject, Is.Not.Null);
            Assert.That(launchProfileProvider.GlobalSettings, Is.Not.Empty);

            Assert.That(launchProfileProvider.Profiles, Has.Count.EqualTo(2));

            launchProfileProvider.Profiles ["Test"] = new LaunchProfileData();

            launchProfileProvider.SaveLaunchSettings();

            launchProfileProvider = new LaunchProfileProvider(project.BaseDirectory, project.DefaultNamespace);
            launchProfileProvider.LoadLaunchSettings();

            Assert.That(launchProfileProvider.Profiles, Has.Count.EqualTo(3));
        }
コード例 #3
0
        public async Task Checks_Adding_Removing_Profiles()
        {
            var solutionFileName = Util.GetSampleProject("aspnetcore-empty-22", "aspnetcore-empty-22.sln");

            solution = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            var project = (DotNetProject)solution.GetAllProjects().Single();

            var launchProfileProvider = new LaunchProfileProvider(project);

            launchProfileProvider.LoadLaunchSettings();

            Assert.That(launchProfileProvider.ProfilesObject, Is.Not.Null);
            Assert.That(launchProfileProvider.GlobalSettings, Is.Not.Empty);

            var profiles = LaunchProfileData.DeserializeProfiles(launchProfileProvider.ProfilesObject);

            Assert.That(profiles, Has.Count.EqualTo(2));

            profiles.Add("Test", new LaunchProfileData());

            launchProfileProvider.SaveLaunchSettings(profiles.ToSerializableForm());

            launchProfileProvider = new LaunchProfileProvider(project);
            launchProfileProvider.LoadLaunchSettings();

            profiles = LaunchProfileData.DeserializeProfiles(launchProfileProvider.ProfilesObject);

            Assert.That(profiles, Has.Count.EqualTo(3));
        }
コード例 #4
0
        public async Task If_launchSettings_is_emtpy_it_should_return_defaultProfile()
        {
            var solutionFileName = Util.GetSampleProject("aspnetcore-empty-22", "aspnetcore-empty-22.sln");

            solution = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            var project = (DotNetProject)solution.GetAllProjects().Single();

            var launchProfileProvider = new LaunchProfileProvider(project);

            launchProfileProvider.LoadLaunchSettings();

            Assert.That(launchProfileProvider.ProfilesObject, Is.Not.Null);
            Assert.That(launchProfileProvider.GlobalSettings, Is.Not.Empty);

            //modifiying launchSettings.json externally
            System.IO.File.WriteAllText(launchProfileProvider.launchSettingsJsonPath, string.Empty);

            var config = project.GetDefaultRunConfiguration() as AspNetCoreRunConfiguration;

            config.RefreshLaunchSettings();

            Assert.That(config, Is.Not.Null, "GetDefaultRunConfiguration cast to AspNetCoreRunConfiguration is null");
            Assert.That(config.ActiveProfile, Is.EqualTo(project.DefaultNamespace));
        }
コード例 #5
0
        public async Task RefreshLaunchSettings_returns_expected_Profile()
        {
            var solutionFileName = Util.GetSampleProject("aspnetcore-empty-22", "aspnetcore-empty-22.sln");

            solution = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            var project = (DotNetProject)solution.GetAllProjects().Single();

            var launchProfileProvider = new LaunchProfileProvider(project);

            launchProfileProvider.LoadLaunchSettings();

            Assert.That(launchProfileProvider.ProfilesObject, Is.Not.Null);
            Assert.That(launchProfileProvider.GlobalSettings, Is.Not.Empty);

            //modifiying launchSettings.json externally
            System.IO.File.WriteAllText(launchProfileProvider.launchSettingsJsonPath, LaunchSettings);
            var config = project.GetDefaultRunConfiguration() as AspNetCoreRunConfiguration;

            config.RefreshLaunchSettings();

            Assert.That(config, Is.Not.Null, "GetDefaultRunConfiguration cast to AspNetCoreRunConfiguration is null");
            Assert.That(config.ActiveProfile, Is.EqualTo("EnvironmentsSample"));
            Assert.That(config.CurrentProfile, Is.Not.Null);
            Assert.That(config.CurrentProfile.TryGetApplicationUrl(), Is.EqualTo("http://localhost:54340/"));
        }
コード例 #6
0
        public async Task CreateProfile_creates_http_only()
        {
            var solutionFileName = Util.GetSampleProject("aspnetcore-empty-30", "aspnetcore-empty-30.sln");

            solution = (Solution)await MonoDevelop.Projects.Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            var project = (DotNetProject)solution.GetAllProjects().Single();
            var launchProfileProvider = new LaunchProfileProvider(project);
            var launchProfile         = launchProfileProvider.CreateDefaultProfile();

            launchProfile.OtherSettings ["applicationUrl"] = "http://localhost:5000";
        }
コード例 #7
0
        public async Task SyncRunConfigurations_syncs_RunConfigs()
        {
            var solutionFileName = Util.GetSampleProject("aspnetcore-empty-22", "aspnetcore-empty-22.sln");

            solution = (Solution)await MonoDevelop.Projects.Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solutionFileName);

            var project = (DotNetProject)solution.GetAllProjects().Single();

            project.RunConfigurations.Clear();
            Assert.That(project.RunConfigurations, Is.Empty);

            var launchProfileProvider = new LaunchProfileProvider(project.BaseDirectory, project.DefaultNamespace);

            System.IO.File.WriteAllText(launchProfileProvider.LaunchSettingsJsonPath, LaunchSettings);
            launchProfileProvider.LoadLaunchSettings();
            launchProfileProvider.SyncRunConfigurations(project);

            Assert.That(project.RunConfigurations, Has.Count.EqualTo(2));
            Assert.That(project.RunConfigurations [0].Name, Is.EqualTo("Kestrel Staging"));
            Assert.False(project.RunConfigurations [0].StoreInUserFile);
            Assert.That(project.RunConfigurations [1].Name, Is.EqualTo("EnvironmentsSample"));
            Assert.False(project.RunConfigurations [1].StoreInUserFile);
        }