public void Prompt_InNonInteractiveEnvironment_ThrowsNonInteractiveSessionException() { // Arrange MockContext.Stub(r => r.InteractionType).Return( InteractionType.NonInteractive ); // Act ILocalOperations operations = new BasicLocalOperations(MockContext); operations.PromptWithNoValidation("What?"); }
public void Prompt_WithDefaultResponseAndNormalInput_ReturnsNormalInput() { // Arrange MockContext.Stub(r => r.InteractionType).Return( InteractionType.AskForInput ); const string normalInput = "Response."; const string defaultResponse = "Default."; var input = new StringReader(normalInput + "\n"); // Act ILocalOperations operations = new BasicLocalOperations(MockContext); var response = operations.PromptWithNoValidation("What?", defaultResponse, inputStream: input); // Assert Assert.AreEqual(normalInput, response); /* Console.WriteLine(Context.Operations.Prompt("Valid.", validateCallable: (r => r == "hello"), validationFailedMessage: "Please enter hello.")); Console.WriteLine(Context.Operations.Prompt("Regex.", validateRegex: @"\d+", validationFailedMessage: "Please enter a number."));*/ }
public void Prompt_WithDefaultResponseInUseDefaultsEnvironment_ReturnsDefaultValue() { // Arrange MockContext.Stub(r => r.InteractionType).Return( InteractionType.UseDefaults ); const string defaultResponse = "Default."; // Act ILocalOperations operations = new BasicLocalOperations(MockContext); var response = operations.PromptWithNoValidation("What?", defaultResponse); // Assert Assert.AreEqual(defaultResponse, response); }
public void Prompt_WithSampleResponseInInteractiveEnvironment_ReturnsResponse() { // Arrange MockContext.Stub(r => r.InteractionType).Return( InteractionType.AskForInput ); const string sampleResponse = "Response."; var input = new StringReader(sampleResponse + "\n"); // Act ILocalOperations operations = new BasicLocalOperations(MockContext); var response = operations.PromptWithNoValidation("What?", inputStream: input); // Assert Assert.AreEqual(sampleResponse, response); }