示例#1
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));
        }
示例#2
0
        public void TryGetOtherSettings_Returns_ExpectedValue()
        {
            var launchSettingsJson = JObject.Parse(LaunchSettings);
            var profiles           = launchSettingsJson?.GetValue("profiles") as JObject;
            var profilesData       = LaunchProfileData.DeserializeProfiles(profiles);

            var appUrl = profilesData ["EnvironmentsSample"].TryGetApplicationUrl();

            Assert.That(appUrl, Is.EqualTo("http://localhost:54340/"));
        }
示例#3
0
        public void ToSerializableForm_Returns_ExpectedValues()
        {
            var launchSettingsJson = JObject.Parse(LaunchSettings);
            var profiles           = launchSettingsJson?.GetValue("profiles") as JObject;
            var profilesData       = LaunchProfileData.DeserializeProfiles(profiles);
            var result             = profilesData.ToSerializableForm();

            Assert.That(result, Is.Not.Null, "ToSerializableForm returned null; expected not null");
            Assert.That(result ["IIS Express"], Has.Count.EqualTo(3), "IIS Express profile expects 3 elements");
            Assert.That(result ["EnvironmentsSample"], Has.Count.EqualTo(4), "EnvironmentsSample profile expects 4 elements");
            Assert.True(result ["EnvironmentsSample"].ContainsKey("applicationUrl"), "EnvironmentsSample does not contains applicationUrl");
            Assert.That(result ["EnvironmentsSample"] ["applicationUrl"], Is.EqualTo("http://localhost:54340/"), "EnvironmentsSample applicationUrl is incorrect");
            Assert.That(result ["Kestrel Staging"], Has.Count.EqualTo(4), "Kestrel Staging profile expects 4 elements");
            Assert.True(result ["Kestrel Staging"].ContainsKey("environmentVariables"), "Kestrel Staging profile does not contains environmentVariables");
            Assert.That(result ["Kestrel Staging"] ["environmentVariables"], Has.Count.EqualTo(3), "Kestrel Staging profile, environmentVariables count is incorrect");
        }