示例#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 UrlGenerator(UrlHelper urlHelper, IRouteNameProvider routeNameProvider)
 {
     _urlHelper         = urlHelper;
     _routeNameProvider = routeNameProvider;
 }