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


C# ValuesController.Get方法代码示例

本文整理汇总了C#中ValuesController.Get方法的典型用法代码示例。如果您正苦于以下问题:C# ValuesController.Get方法的具体用法?C# ValuesController.Get怎么用?C# ValuesController.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ValuesController的用法示例。


在下文中一共展示了ValuesController.Get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetById

        public void GetById() {
            // Arrange
            ValuesController controller = new ValuesController();

            // Act
            string result = controller.Get(5);

            // Assert
            Assert.AreEqual("value", result);
        }
开发者ID:PeteGoo,项目名称:NHibernate.QueryService,代码行数:10,代码来源:ValuesControllerTest.cs

示例2: GetById

        public void GetById()
        {
            // Упорядочение
            ValuesController controller = new ValuesController();

            // Действие
            string result = controller.Get(5);

            // Утверждение
            Assert.AreEqual("value", result);
        }
开发者ID:Neanderthal,项目名称:MakeBetter,代码行数:11,代码来源:ValuesControllerTest.cs

示例3: GetById

        public void GetById()
        {
            // Arrange
            ValuesController controller = new ValuesController();

            // Act
            string result = controller.Get(5);

            // Assert
            Assert.That("value", Is.EqualTo(result));
        }
开发者ID:ngnono,项目名称:NGnono.Example.Web,代码行数:11,代码来源:ValuesControllerTest.cs

示例4: Get

        public void Get() {
            // Arrange
            ValuesController controller = new ValuesController();

            // Act
            IQueryable<string> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Assert.AreEqual("value1", result.ElementAt(0));
            Assert.AreEqual("value2", result.ElementAt(1));
        }
开发者ID:PeteGoo,项目名称:NHibernate.QueryService,代码行数:13,代码来源:ValuesControllerTest.cs

示例5: Get

        public void Get()
        {
            // Arrange
            ValuesController controller = new ValuesController();

            // Act
            IEnumerable<string> result = controller.Get();

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(2, Is.EqualTo(result.Count()));
            Assert.That("value1", Is.EqualTo(result.ElementAt(0)));
            Assert.That("value2", Is.EqualTo(result.ElementAt(1)));
        }
开发者ID:ngnono,项目名称:NGnono.Example.Web,代码行数:14,代码来源:ValuesControllerTest.cs

示例6: Get

        public void Get()
        {
            // Réorganiser
            ValuesController controller = new ValuesController();

            // Agir
            IEnumerable<string> result = controller.Get();

            // Déclarer
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Assert.AreEqual("value1", result.ElementAt(0));
            Assert.AreEqual("value2", result.ElementAt(1));
        }
开发者ID:ylasmak,项目名称:SQLi.NoSql.API,代码行数:14,代码来源:ValuesControllerTest.cs

示例7: Get

        public void Get()
        {
            // Arrange
            var controller = new ValuesController();

            // Act
            var result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Assert.AreEqual("Mike", result.ElementAt(0).Name);
            Assert.AreEqual("Smith", result.ElementAt(1).Name);
        }
开发者ID:edgardojimenez,项目名称:mobws,代码行数:14,代码来源:ValuesControllerTest.cs

示例8: Get

        public void Get()
        {
            // Arrange
            ValuesController controller = new ValuesController();

            // Act
            RecommendedItem[] result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Assert.AreEqual("12", result.ElementAt(0).Price);
            //Assert.AreEqual("value2", result.ElementAt(1));
        }
开发者ID:chocolatemurderer,项目名称:Stylish-Weather,代码行数:14,代码来源:ValuesControllerTest.cs

示例9: GetAHeading

        public void GetAHeading()
        {
            // Arrange
            ValuesController controller = new ValuesController();
            const string testInput = "This is a heading.\nOh that is a heading.";

            // Act
            string result = controller.Get(testInput);

            // Assert
            const string expectedOutput = "<h6>This is a heading.</h6>";

            Assert.IsNotNull(result);
            Assert.AreEqual(expectedOutput, result);
        }
开发者ID:ScottHenwood,项目名称:OhJustThat,代码行数:15,代码来源:ValuesControllerTest.cs

示例10: GetAParagraph

        public void GetAParagraph()
        {
            // Arrange
            ValuesController controller = new ValuesController();
            const string testInput = "This is a paragraph.";

            // Act
            string result = controller.Get(testInput);

            // Assert
            const string expectedOutput = "<p>This is a paragraph.</p>";

            Assert.IsNotNull(result);
            Assert.AreEqual(expectedOutput, result);
        }
开发者ID:ScottHenwood,项目名称:OhJustThat,代码行数:15,代码来源:ValuesControllerTest.cs

示例11: Get

        public void Get()
        {
            // Arrange
            ValuesController controller = new ValuesController();

            // Act
            IEnumerable<string> result = controller.Get();

            Debug.WriteLine("Running a cool test");

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count());
            Assert.AreEqual("value1", result.ElementAt(0));
            Assert.AreEqual("value2", result.ElementAt(1));
        }
开发者ID:Gope,项目名称:CloudSamples,代码行数:16,代码来源:ValuesControllerTest.cs

示例12: GetARealHeading

        public void GetARealHeading()
        {
            // Arrange
            ValuesController controller = new ValuesController();
            const string testInput = "This is a heading.\nOh that is really a heading.\nThis is a paragraph.";

            // Act
            string result = controller.Get(testInput);

            // Assert
            const string expectedOutput = "<h5>This is a heading.</h5><p>This is a paragraph.</p>";

            Assert.IsNotNull(result);
            Assert.AreEqual(expectedOutput, result);
        }
开发者ID:ScottHenwood,项目名称:OhJustThat,代码行数:15,代码来源:ValuesControllerTest.cs

示例13: ValuesController_Behavior_Unchanged_By_Tracing

        public void ValuesController_Behavior_Unchanged_By_Tracing(ITestTraceWriter traceWriter)
        {
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional });

            // The null trace writer case is tested as well to verify the
            // ValuesController works as expected without tracing.
            if (traceWriter != null)
            {
                config.Services.Replace(typeof(ITraceWriter), traceWriter);
                traceWriter.Start();
            }

            ValuesController valuesController = new ValuesController();

            using (HttpServer server = new HttpServer(config))
            {
                using (HttpClient client = new HttpClient(server))
                {
                    if (traceWriter != null)
                    {
                        traceWriter.Start();
                    }

                    // Calls ValuesController.Get()
                    string uri = _baseAddress + "/api/Values";
                    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
                    HttpResponseMessage response = client.SendAsync(request).Result;
                    Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                    string[] expectedGetResponse = valuesController.Get().ToArray();
                    string[] actualGetResponse = response.Content.ReadAsAsync<string[]>().Result;
                    Assert.Equal(expectedGetResponse, actualGetResponse);
                    if (traceWriter != null)
                    {
                        traceWriter.Finish();
                        Assert.True(traceWriter.DidReceiveTraceRequests);
                        traceWriter.Start();
                    }

                    // Calls ValuesController.Get(id) using query string
                    uri = _baseAddress + "/api/Values?id=5";
                    request = new HttpRequestMessage(HttpMethod.Get, uri);
                    response = client.SendAsync(request).Result;
                    Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                    string expectedGetQueryStringResponse = valuesController.Get(5);
                    string actualGetQueryStringResponse = response.Content.ReadAsAsync<string>().Result;
                    Assert.Equal(expectedGetQueryStringResponse, actualGetQueryStringResponse);
                    if (traceWriter != null)
                    {
                        traceWriter.Finish();
                        Assert.True(traceWriter.DidReceiveTraceRequests);
                        traceWriter.Start();
                    }

                    // Calls ValuesController.Get(id) using route
                    uri = _baseAddress + "/api/Values/5";
                    request = new HttpRequestMessage(HttpMethod.Get, uri);
                    response = client.SendAsync(request).Result;
                    Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                    string expectedGetRouteResponse = valuesController.Get(5);
                    string actualGetRouteResponse = response.Content.ReadAsAsync<string>().Result;
                    Assert.Equal(expectedGetQueryStringResponse, actualGetRouteResponse);
                    if (traceWriter != null)
                    {
                        traceWriter.Finish();
                        Assert.True(traceWriter.DidReceiveTraceRequests);
                        traceWriter.Start();
                    }

                    // Calls ValuesController.Get(id) using query string that causes model binding error
                    uri = _baseAddress + "/api/Values?id=x";
                    request = new HttpRequestMessage(HttpMethod.Get, uri);
                    response = client.SendAsync(request).Result;
                    Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
                    if (traceWriter != null)
                    {
                        traceWriter.Finish();
                        Assert.True(traceWriter.DidReceiveTraceRequests);
                        traceWriter.Start();
                    }

                    // Calls ValuesController.Post(value) with no parameters
                    uri = _baseAddress + "/api/Values";
                    request = new HttpRequestMessage(HttpMethod.Post, uri);
                    response = client.SendAsync(request).Result;
                    Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
                    if (traceWriter != null)
                    {
                        traceWriter.Finish();
                        Assert.True(traceWriter.DidReceiveTraceRequests);
                        traceWriter.Start();
                    }

                    // Calls ValuesController.Post(value) using query string
                    uri = _baseAddress + "/api/Values?value=hello";
                    request = new HttpRequestMessage(HttpMethod.Post, uri);
                    response = client.SendAsync(request).Result;
                    Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
                    if (traceWriter != null)
                    {
//.........这里部分代码省略.........
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:101,代码来源:TracingTest.cs


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