예제 #1
0
        public void GetLinkAsyncReturnsCorrectUriForExpressionOfFuncWithComplexParameter(
            [Frozen]HttpRequestMessage request,
            RouteLinker forComparison,
            UrlHelper sut, SomeModel someModel)
        {
            request.AddDefaultRoute();

            var expected = forComparison.GetUriAsync<ModelAsyncController, object>(a => a.Get(someModel)).Result;
            var actual = sut.GetLinkAsync<ModelAsyncController, object>(a => a.Get(someModel)).Result;

            Assert.Equal(expected, actual);
        }
예제 #2
0
        public void GetUriFromModelControllerReturnsCorrectResponse(
            [Frozen]HttpRequestMessage request,
            [Frozen]Mock<IRouteValuesQuery> queryStub,
            [Frozen(As = typeof(IRouteDispatcher))]DefaultRouteDispatcher dummy,
            [Greedy]RouteLinker sut,
            SomeModel model)
        {
            request.AddDefaultRoute();
            queryStub.SetReturnsDefault<IDictionary<string, object>>(
                new Dictionary<string, object>
                {
                    { "number", model.Number.ToString() },
                    { "text", model.Text }
                });

            var actual = sut.GetUri<ModelController>(c => c.Get(model));

            var baseUri = request.RequestUri.GetLeftPart(UriPartial.Authority);
            var expected = new Uri(
                new Uri(baseUri),
                "api/model?number=" + model.Number + "&text=" + model.Text);
            Assert.Equal(expected, actual);
        }
예제 #3
0
 public object Get(SomeModel queryModel)
 {
     return new object();
 }
예제 #4
0
        public void GetLinkReturnsCorrectUriForExpressionOfActionWithComplexParameter(
            [Frozen]HttpRequestMessage request,
            RouteLinker forComparison,
            UrlHelper sut,
            SomeModel someModel)
        {
            request.AddDefaultRoute();

            var expected = forComparison.GetUri<ModelController>(a => a.Get(someModel));
            var actual = sut.GetLink<ModelController>(a => a.Get(someModel));

            Assert.Equal(expected, actual);
        }
예제 #5
0
 public object Get(SomeModel queryModel)
 {
     return(new object());
 }
예제 #6
0
 public Task<object> Get(SomeModel queryModel)
 {
     return Task.Factory.StartNew(() => new object());
 }
예제 #7
0
 public Task <object> Get(SomeModel queryModel)
 {
     return(Task.Factory.StartNew(() => new object()));
 }