public void GenerateUrl_should_return_correct_url_for_route()
        {
            Mock <INavigatable> navigationItem = new Mock <INavigatable>();

            navigationItem.SetupGet(item => item.RouteName).Returns("ProductList");
            navigationItem.SetupGet(item => item.RouteValues).Returns(new RouteValueDictionary());

            string url = _urlGenerator.Generate(TestHelper.CreateRequestContext(), navigationItem.Object);

            Assert.Contains("/Products", url);
        }
Example #2
0
        public static bool Create(Address address, List <string> urlsCollection)
        {
            bool urlExists = UrlValidator.Validate(address.LongUrl);

            if (urlExists)
            {
                address.ShortUrl     = UrlGenerator.Generate(urlsCollection);
                address.CreationData = DateTime.Now.ToString("yyyy-MM-dd h:mm tt");
            }
            return(urlExists);
        }
Example #3
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tTreeView", writer);

            objectWriter.Start();

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            if (!ShowLines)
            {
                objectWriter.Append("showLines", ShowLines);
            }

            if (ShowCheckBox)
            {
                objectWriter.Append("showCheckBox", ShowCheckBox);
            }

            if (DragAndDrop.Enabled)
            {
                if (DragAndDrop.DropTargets.HasValue())
                {
                    var dragAndDropOptions = new Dictionary <string, string>();

                    dragAndDropOptions["dropTargets"] = DragAndDrop.DropTargets;

                    objectWriter.AppendObject("dragAndDrop", dragAndDropOptions);
                }
                else
                {
                    objectWriter.Append("dragAndDrop", true);
                }
            }

            if (Ajax.Enabled)
            {
                Dictionary <string, string> ajax = new Dictionary <string, string>();

                ajax["selectUrl"] = UrlGenerator.Generate(ViewContext.RequestContext, Ajax.Select);

                objectWriter.AppendObject("ajax", ajax);
            }

            if (WebService.Enabled)
            {
                Dictionary <string, string> webService = new Dictionary <string, string>();

                webService["selectUrl"] = UrlGenerator.Generate(ViewContext.RequestContext, WebService.Select.Url);

                objectWriter.AppendObject("ws", webService);
            }

            objectWriter.AppendClientEvent("onExpand", ClientEvents.OnExpand);
            objectWriter.AppendClientEvent("onCollapse", ClientEvents.OnCollapse);
            objectWriter.AppendClientEvent("onSelect", ClientEvents.OnSelect);
            objectWriter.AppendClientEvent("onLoad", ClientEvents.OnLoad);
            objectWriter.AppendClientEvent("onError", ClientEvents.OnError);
            objectWriter.AppendClientEvent("onChecked", ClientEvents.OnChecked);
            objectWriter.AppendClientEvent("onNodeDragStart", ClientEvents.OnNodeDragStart);
            objectWriter.AppendClientEvent("onNodeDragging", ClientEvents.OnNodeDragging);
            objectWriter.AppendClientEvent("onNodeDragCancelled", ClientEvents.OnNodeDragCancelled);
            objectWriter.AppendClientEvent("onNodeDrop", ClientEvents.OnNodeDrop);
            objectWriter.AppendClientEvent("onNodeDropped", ClientEvents.OnNodeDropped);
            objectWriter.AppendClientEvent("onDataBinding", ClientEvents.OnDataBinding);
            objectWriter.AppendClientEvent("onDataBound", ClientEvents.OnDataBound);

            objectWriter.Complete();
            base.WriteInitializationScript(writer);
        }
Example #4
0
 public static void Urlgenerator()
 {
     Assert.Equal(UrlGenerator.Generate(UrlType.EewJson, DateTime.Parse("2017/03/19 22:13:47")), "http://www.kmoni.bosai.go.jp/new/webservice/hypo/eew/20170319221347.json");
 }