tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Properties/InterceptedProjectProperties/ActiveLaunchProfilesValueProviderTests.cs
/// <summary>
/// Creates a mock <see cref="ILaunchSettingsProvider"/> for testing purposes.
/// </summary>
/// <param name="activeProfileName">The name of the active profile in the new object.</param>
/// <param name="setActiveProfileCallback">An optional method to call when the active profile is set.</param>
Creates a mock  for testing purposes.
Creates a mock for testing purposes .
private static ILaunchSettingsProvider CreateLaunchSettingsProvider(string activeProfileName, Action<string>? setActiveProfileCallback = null)
        {
            var launchProfile = new LaunchProfile { Name = activeProfileName };
            var launchSettingsMock = new Mock<ILaunchSettings>();
            launchSettingsMock.Setup(t => t.ActiveProfile).Returns(launchProfile);
            var launchSettings = launchSettingsMock.Object;
            var settingsProviderMock = new Mock<ILaunchSettingsProvider>();
            settingsProviderMock.Setup(t => t.WaitForFirstSnapshot(It.IsAny<int>())).Returns(Task.FromResult(launchSettings));
            if (setActiveProfileCallback != null)
            {
                settingsProviderMock.Setup(t => t.SetActiveProfileAsync(It.IsAny<string>()))
                    .Returns<string>(v =>
                    {
                        setActiveProfileCallback(v);
                        return Task.CompletedTask;
                    });
            }
            var settingsProvider = settingsProviderMock.Object;
            return settingsProvider;
        }
private static ILaunchSettingsProvider CreateLaunchSettingsProvider ( string activeProfileName , Action < string > ? setActiveProfileCallback = null ) { var launchProfile = new LaunchProfile { Name = activeProfileName } ; var launchSettingsMock = new Mock < ILaunchSettings > ( ) ; launchSettingsMock . Setup ( t => t . ActiveProfile ) . Returns ( launchProfile ) ; var launchSettings = launchSettingsMock . Object ; var settingsProviderMock = new Mock < ILaunchSettingsProvider > ( ) ; settingsProviderMock . Setup ( t => t . WaitForFirstSnapshot ( It . IsAny < int > ( ) ) ) . Returns ( Task . FromResult ( launchSettings ) ) ; if ( setActiveProfileCallback != null ) { settingsProviderMock . Setup ( t => t . SetActiveProfileAsync ( It . IsAny < string > ( ) ) ) . Returns < string > ( v => { setActiveProfileCallback ( v ) ; return Task . CompletedTask ; } ) ; } var settingsProvider = settingsProviderMock . Object ; return settingsProvider ; }
Creates a mock  for testing purposes.
Creates a mock for testing purposes .
activeProfileName
string
The name of the active profile in the new object.
The name of the active profile in the new object .
setActiveProfileCallback
Action<string>?
An optional method to call when the active profile is set.
An optional method to call when the active profile is set .