public static void FunctionalMatch() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); var profile = profiles .Use("does-not-exist") .Match(() => default, x => x);
public void VisualStudio_launch_settings_should_deserialize_correctly() { var actual = GetFirstOrEmptyProfile(VisualStudioLaunchSettings.FromCaller()); var expected = StubbedProfiles.First; actual.Should().BeEquivalentTo(expected); }
public static void FirstOrEmpty() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); var profile = profiles.FirstOrEmpty(); WriteOut.EnvironmentalVariables(profile); }
public static void CheckingIfNamedProfileExists() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); var(exists, _) = profiles.Use("does-not-exist"); // Do something else if it doesn't exist WriteOut.Line($"The profile does {(exists ? "" : "not")} exist."); }
public void Missing_visual_studio_launch_settings_file_should_return_empty_profile() { var filePath = "non-existent-file.json"; var actual = GetFirstOrEmptyProfile(VisualStudioLaunchSettings.FromCaller(filePath)); var expected = StubbedProfiles.Empty; actual.Should().BeEquivalentTo(expected); }
public void Empty_file_should_return_empty_profile() { var filePath = Path.GetTempFileName(); var actual = GetFirstOrEmptyProfile(VisualStudioLaunchSettings.FromCaller(filePath)); var expected = StubbedProfiles.Empty; actual.Should().BeEquivalentTo(expected); }
public static void Match() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); profiles .Use("does-not-exist") .Match( () => { WriteOut.Line("The profile does not exist."); }, WriteOut.EnvironmentalVariables); }
public static void UseNamedProfile() { var launchSettings = VisualStudioLaunchSettings.FromCaller(); var profiles = launchSettings.GetProfiles(); var(exists, profile) = profiles.Use("does-not-exist"); try { // You can not just use it. If the profile is missing, it will blow up! WriteOut.EnvironmentalVariables(profile); } catch (NullReferenceException) { WriteOut.Line("The profile was null and it caused an exception!"); } }