public async Task WhenAddingANewProfile_AndAProfileNameIsNotProvided_AUniqueNameIsGenerated() { var profiles = new List <ILaunchProfile>(); var launchSettingsProvider = ILaunchSettingsProviderFactory.Create( addOrUpdateProfileCallback: (profile, addToFront) => profiles.Add(profile), getProfilesCallback: (p) => ImmutableList.CreateRange(profiles)); var service = new LaunchSettingsActionService(launchSettingsProvider); var newProfile1 = await service.AddLaunchProfileAsync(commandName : "Alpha", newProfileName : null); Assert.NotNull(newProfile1); Assert.Equal(expected: "Alpha", actual: newProfile1 !.CommandName); Assert.NotNull(newProfile1.Name); var newProfile2 = await service.AddLaunchProfileAsync(commandName : "Beta", newProfileName : null); Assert.NotNull(newProfile2); Assert.Equal(expected: "Beta", actual: newProfile2 !.CommandName); Assert.NotNull(newProfile2.Name); Assert.NotEqual(expected: newProfile1.Name, actual: newProfile2.Name); Assert.Equal(expected: 2, actual: profiles.Count); }
public async Task WhenAddingANewProfile_AndAProfileNameIsProvided_TheProvidedNameIsUsed() { var profiles = new List <ILaunchProfile>(); var launchSettingsProvider = ILaunchSettingsProviderFactory.Create( addOrUpdateProfileCallback: (profile, addToFront) => profiles.Add(profile), getProfilesCallback: (p) => ImmutableList.CreateRange(profiles)); var service = new LaunchSettingsActionService(launchSettingsProvider); var newProfile = await service.AddLaunchProfileAsync(commandName : "Alpha", newProfileName : "Beta"); Assert.NotNull(newProfile); Assert.Equal(expected: "Beta", actual: newProfile !.Name); Assert.Equal(expected: "Alpha", actual: newProfile !.CommandName); Assert.Single(profiles); }