当前位置: 首页>>代码示例>>C#>>正文


C# App.ProcessInput方法代码示例

本文整理汇总了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();
        }
开发者ID:skorunka,项目名称:CoduranceTechTest,代码行数:17,代码来源:AppUnitTests.cs

示例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);
        }
开发者ID:skorunka,项目名称:CoduranceTechTest,代码行数:21,代码来源:AppUnitTests.cs

示例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());
        }
开发者ID:skorunka,项目名称:CoduranceTechTest,代码行数:22,代码来源:AppUnitTests.cs

示例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();
        }
开发者ID:skorunka,项目名称:CoduranceTechTest,代码行数:17,代码来源:AppUnitTests.cs

示例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());
        }
开发者ID:skorunka,项目名称:CoduranceTechTest,代码行数:14,代码来源:AppUnitTests.cs


注:本文中的App.ProcessInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。