本文整理汇总了C#中App.ProcessInput方法的典型用法代码示例。如果您正苦于以下问题:C# App.ProcessInput方法的具体用法?C# App.ProcessInput怎么用?C# App.ProcessInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App.ProcessInput方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessInput_EnsureTheCommandTextIsCaseInsensitiveAndTrimmed
public void ProcessInput_EnsureTheCommandTextIsCaseInsensitiveAndTrimmed(string commandText)
{
var inputParserMock = new Mock<IInputParser>();
inputParserMock.Setup(x => x.Parse(It.IsAny<string>()))
.Returns(new ParsedInput { UserName = "Frantisek", CommandText = commandText });
var commandMock = new Mock<ICommand>();
commandMock.SetupGet(x => x.CommandText).Returns("Wall").Verifiable();
commandMock.Setup(x => x.Execute(It.IsAny<string>(), It.IsAny<string>()))
.Verifiable();
var app = new App(inputParserMock.Object, new List<ICommand> { commandMock.Object }) as IApp;
app.ProcessInput($"Frantisek {commandText}");
commandMock.Verify();
}
示例2: ProcessInput_WhenCommandExists_ProcessIt
public void ProcessInput_WhenCommandExists_ProcessIt()
{
var inputParserMock = new Mock<IInputParser>();
inputParserMock.Setup(x => x.Parse(It.Is<string>(p => p == "Frantisek Wall data")))
.Returns(new ParsedInput { UserName = "Frantisek", CommandText = "Wall", Data = "data" })
.Verifiable();
var commandMock = new Mock<ICommand>();
commandMock.SetupGet(x => x.CommandText).Returns("Wall").Verifiable();
commandMock.Setup(x => x.Execute(It.Is<string>(p => p == "Frantisek"), It.Is<string>(p => p == "data")))
.Returns(new List<string>())
.Verifiable();
var app = new App(inputParserMock.Object, new List<ICommand> { commandMock.Object }) as IApp;
var result = app.ProcessInput("Frantisek Wall data");
inputParserMock.Verify();
commandMock.Verify();
Assert.IsEmpty(result);
}
示例3: ProcessInput_WhenCommandDoesNotExist_ReturnErrorMessage
public void ProcessInput_WhenCommandDoesNotExist_ReturnErrorMessage()
{
var inputParserMock = new Mock<IInputParser>();
inputParserMock.Setup(x => x.Parse(It.Is<string>(p => p == "Frantisek Wall data")))
.Returns(new ParsedInput { UserName = "Frantisek", CommandText = "Wall", Data = "data" })
.Verifiable();
var commandMock = new Mock<ICommand>();
commandMock.SetupGet(x => x.CommandText).Returns("Follow").Verifiable();
commandMock.Setup(x => x.Execute(It.Is<string>(p => p == "Frantisek"), It.Is<string>(p => p == "data")))
.Throws(new AssertionException("Should not be called."));
var app = new App(inputParserMock.Object, new List<ICommand> { commandMock.Object }) as IApp;
var result = app.ProcessInput("Frantisek Wall data");
inputParserMock.Verify();
commandMock.Verify();
Assert.IsNotNull(result);
Assert.AreEqual(1, result.Count);
Assert.AreEqual(string.Format(App.ErrorTextCommandNotFound, "Wall"), result.First());
}
示例4: ProcessInput_WhenCommandTestIsNull_UseDefaultCommand
public void ProcessInput_WhenCommandTestIsNull_UseDefaultCommand()
{
var inputParserMock = new Mock<IInputParser>();
inputParserMock.Setup(x => x.Parse(It.IsAny<string>()))
.Returns(new ParsedInput { UserName = "Frantisek", CommandText = null });
var commandMock = new Mock<ICommand>();
commandMock.SetupGet(x => x.CommandText).Returns(App.DefaultCommandText);
commandMock.Setup(x => x.Execute(It.IsAny<string>(), It.IsAny<string>()))
.Verifiable();
var app = new App(inputParserMock.Object, new List<ICommand> { commandMock.Object }) as IApp;
app.ProcessInput("Frantisek");
commandMock.Verify();
}
示例5: ProcessInput_WhenInputIsInvalid_ReturnErrorMessage
public void ProcessInput_WhenInputIsInvalid_ReturnErrorMessage()
{
var inputParserMock = new Mock<IInputParser>();
inputParserMock.Setup(x => x.Parse(It.IsAny<string>()))
.Returns<ParsedInput>(null);
var app = new App(inputParserMock.Object, new List<ICommand>()) as IApp;
var result = app.ProcessInput("input text");
Assert.IsNotNull(result);
Assert.AreEqual(1, result.Count);
Assert.AreEqual(string.Format(App.ErrorTextInvalidInput, "input text"), result.First());
}