public async Task ExecuteAsync_SetCommandNoValue_SetToDefault() { IFileSystem fileSystem = new MockedFileSystem(); IUserProfileDirectoryProvider userProfileDirectoryProvider = new UserProfileDirectoryProvider(); UserFolderPreferences preferences = new UserFolderPreferences(fileSystem, userProfileDirectoryProvider, TestDefaultPreferences.GetDefaultPreferences()); HttpClient httpClient = new HttpClient(); HttpState httpState = new HttpState(fileSystem, preferences, httpClient); MockedShellState shellState = new MockedShellState(); PrefCommand command = new PrefCommand(preferences); // First, set it to something other than the default and make sure that works. string firstCommandExpectedValue = "BoldMagenta"; string firstCommandText = $"pref set {WellKnownPreference.ProtocolColor} {firstCommandExpectedValue}"; ICoreParseResult firstParseResult = CoreParseResultHelper.Create(firstCommandText); await command.ExecuteAsync(shellState, httpState, firstParseResult, CancellationToken.None); Assert.Empty(shellState.Output); Assert.Equal(firstCommandExpectedValue, preferences.CurrentPreferences[WellKnownPreference.ProtocolColor]); // Then, set it to nothing and make sure it goes back to the default string secondCommandText = $"pref set {WellKnownPreference.ProtocolColor}"; ICoreParseResult secondParseResult = CoreParseResultHelper.Create(secondCommandText); await command.ExecuteAsync(shellState, httpState, secondParseResult, CancellationToken.None); Assert.Empty(shellState.Output); Assert.Equal(preferences.DefaultPreferences[WellKnownPreference.ProtocolColor], preferences.CurrentPreferences[WellKnownPreference.ProtocolColor]); }
private static void Arrange(string commandText, out HttpState httpState, out MockedShellState shellState, out ICoreParseResult parseResult, out PrefCommand command, out UserFolderPreferences preferences) { IFileSystem fileSystem = new MockedFileSystem(); IUserProfileDirectoryProvider userProfileDirectoryProvider = new UserProfileDirectoryProvider(); preferences = new UserFolderPreferences(fileSystem, userProfileDirectoryProvider, TestDefaultPreferences.GetDefaultPreferences()); HttpClient httpClient = new HttpClient(); httpState = new HttpState(fileSystem, preferences, httpClient); shellState = new MockedShellState(); parseResult = CoreParseResultHelper.Create(commandText); command = new PrefCommand(preferences); }