コード例 #1
0
        public void GetItemUrl_ItemId_UrlReceived()
        {
            var urlHelper = Substitute.For <UrlHelper>();

            _routeNameProvider = Substitute.For <IRouteNameProvider>();
            _itemUrlGenerator  = new UrlGenerator(urlHelper, _routeNameProvider);

            _routeNameProvider.GetRouteName().Returns(RouteConfig.DefaultApi);
            urlHelper.Route(RouteConfig.DefaultApi, Arg.Is <object>(o => ContainsCorrectId(o))).Returns($"api/{FakeId}/v2.1/itemlist");

            var id = FakeId;

            var requestedUrl = $"api/{FakeId}/v2.1/itemlist";

            var receivedUrl = _itemUrlGenerator.GetItemUrl(id);

            Assert.That(receivedUrl, Is.EqualTo(requestedUrl));
        }
コード例 #2
0
 public string GetItemUrl(Guid id)
 => _urlHelper.Route(_routeNameProvider.GetRouteName(), new { id });