public void ExecuteAsync_KnownEndpointWithRequestMethods_NoWarning() { ChangeDirectoryCommand command = new ChangeDirectoryCommand(); Setup(commandText: "cd AnEndpoint", out MockedShellState mockedShellState, out HttpState httpState, out ICoreParseResult parseResult); DirectoryStructure directoryStructure = new DirectoryStructure(null); DirectoryStructure childDirectory = directoryStructure.DeclareDirectory("AnEndpoint"); RequestInfo childRequestInfo = new RequestInfo(); childRequestInfo.AddMethod("GET"); childDirectory.RequestInfo = childRequestInfo; ApiDefinition apiDefinition = new ApiDefinition() { DirectoryStructure = directoryStructure }; httpState.ApiDefinition = apiDefinition; string expectedOutput = "/AnEndpoint [GET]"; command.ExecuteAsync(mockedShellState, httpState, parseResult, CancellationToken.None); Assert.Single(mockedShellState.Output); Assert.Equal(expectedOutput, mockedShellState.Output[0]); }
public void ExecuteAsync_UnknownEndpoint_DisplaysWarning() { ChangeDirectoryCommand command = new ChangeDirectoryCommand(); Setup(commandText: "cd NotAnEndpoint", out MockedShellState mockedShellState, out HttpState httpState, out ICoreParseResult parseResult); httpState.Structure = new DirectoryStructure(null); string expectedFirstLine = string.Format(Resources.Strings.ChangeDirectoryCommand_Warning_UnknownEndpoint, "/NotAnEndpoint").SetColor(httpState.WarningColor); string expectedSecondLine = "/NotAnEndpoint []"; command.ExecuteAsync(mockedShellState, httpState, parseResult, CancellationToken.None); Assert.Equal(2, mockedShellState.Output.Count); Assert.Equal(expectedFirstLine, mockedShellState.Output[0]); Assert.Equal(expectedSecondLine, mockedShellState.Output[1]); }
public void ExecuteAsync_KnownEndpointWithSubdirectory_NoWarning() { ChangeDirectoryCommand command = new ChangeDirectoryCommand(); Setup(commandText: "cd AnEndpoint", out MockedShellState mockedShellState, out HttpState httpState, out ICoreParseResult parseResult); DirectoryStructure directoryStructure = new DirectoryStructure(null); DirectoryStructure childDirectory = directoryStructure.DeclareDirectory("AnEndpoint"); DirectoryStructure grandchildDirectory = childDirectory.DeclareDirectory("AnotherEndpoint"); httpState.Structure = directoryStructure; string expectedOutput = "/AnEndpoint []"; command.ExecuteAsync(mockedShellState, httpState, parseResult, CancellationToken.None); Assert.Single(mockedShellState.Output); Assert.Equal(expectedOutput, mockedShellState.Output[0]); }