public void ItemsDatasourceDoesNotChangeCase()
        {
            var page = new PivotDatasourcePage();

            page.DataSources.Add(new ItemsDatasourceTagHelper {
                Items = new[] {
                    new {
                        CamelCaseName      = "Value1",
                        lowerCamelCaseName = "value2"
                    }
                }
            });

            page.ExecuteSynchronously();

            var dataSourceConfig = page.TopLevelTag.GetConfigValue <IDictionary <string, object> >("dataSource");

            AssertIgnoreWhitespaces.Contains(
                @"""data"": [
                    {
                        ""CamelCaseName"": ""Value1"",
                        ""lowerCamelCaseName"": ""value2""
                    }
                ]",
                JsonConvert.SerializeObject(dataSourceConfig["store"])
                );
        }
        public void RendersItemsDatasource()
        {
            var jsonFormatter = new JsonOutputFormatter(
                new JsonSerializerSettings {
                ContractResolver = new DefaultContractResolver {
                    NamingStrategy = new CamelCaseNamingStrategy()
                }
            },
                ArrayPool <char> .Shared
                );

            page.Datasource = new ItemsDatasourceTagHelper(jsonFormatter)
            {
                Items = new[] { 123, 456, 789 }
            };

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains(
                @"""dataSource"": {
                    ""store"": new DevExpress.data.ArrayStore({
                        ""data"": [ 123, 456, 789 ]
                    })
                }",
                page.GetOutputText());
        }
        public void RendersRawUnquoted()
        {
            page.Widget.SetConfigValue("abc", "OnClick", isRaw: true);

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains("\"abc\": OnClick", page.GetOutputText());
        }
        public void StoreDatasourceRendersKey(string rawKey, string expectedSerializedKey)
        {
            page.Datasource = new TestStoreDatasourceTagHelper()
            {
                DatasourceKey = rawKey
            };

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains($"\"key\": {expectedSerializedKey}", page.GetOutputText());
        }
        public void RendersLoadActionDatasource_OnBeforeSend()
        {
            page.Datasource = new LoadActionDatasourceTagHelper(new UrlHelperFactoryMock())
            {
                OnBeforeSend = "OnBeforeSendFunc"
            };

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains(@"""onBeforeSend"": OnBeforeSendFunc", page.GetOutputText());
        }
        public void RendersInnerScript()
        {
            page.Widget.ID   = "id1";
            page.InnerScript = @"EXPECTED_INNER_SCRIPT";

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains(
                @"var options = { };
                  EXPECTED_INNER_SCRIPT
                  $(""#id1"")",
                page.GetOutputText()
                );
        }
Exemplo n.º 7
0
        public void RendersItemsDatasource()
        {
            page.Datasource = new ItemsDatasourceTagHelper {
                Items = new[] { 123, 456, 789 }
            };

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains(
                @"""dataSource"": {
                    ""store"": new DevExpress.data.ArrayStore({
                        ""data"": [ 123, 456, 789 ]
                    })
                }",
                page.GetOutputText());
        }
        public void RendersUrlDatasource()
        {
            page.Datasource = new UrlDatasourceTagHelper(new UrlHelperFactoryMock())
            {
                Url = "LoadUrl1"
            };

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains(
                @"""dataSource"": { 
                    ""store"": new DevExpress.data.CustomStore({
                        ""load"": function() { return $.getJSON(""ContentMock(LoadUrl1)""); }
                    })
                }",
                page.GetOutputText());
        }
        public void RendersLoadActionDatasource_AllActionsWithMethods()
        {
            page.Datasource = new LoadActionDatasourceTagHelper(new UrlHelperFactoryMock())
            {
                Controller   = "Controller1",
                UpdateMethod = "Method1",
                InsertMethod = "Method2",
                DeleteMethod = "Method3"
            };

            page.ExecuteSynchronously();

            var markup = page.GetOutputText();

            AssertIgnoreWhitespaces.Contains(@"""updateMethod"": ""Method1""", markup);
            AssertIgnoreWhitespaces.Contains(@"""insertMethod"": ""Method2""", markup);
            AssertIgnoreWhitespaces.Contains(@"""deleteMethod"": ""Method3""", markup);
        }
        public void RendersLoadActionDatasource_LoadOnly()
        {
            page.Datasource = new LoadActionDatasourceTagHelper(new UrlHelperFactoryMock())
            {
                Controller = "Controller1",
                LoadAction = "Action1"
            };

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Contains(
                @"""dataSource"": {
                    ""store"": DevExpress.data.AspNet.createStore({
                        ""loadUrl"": ""ActionMock(Controller1, Action1)""
                    })
                }",
                page.GetOutputText());
        }
        public void Sample1()
        {
            page.Widget.SetConfigValue("prop1", "value1");
            page.Widget.ID = "id1";

            page.ExecuteSynchronously();

            AssertIgnoreWhitespaces.Equal(
                @"<div id=""id1""></div>
                <script>
                    jQuery(function($) {
                        var options = { ""prop1"": ""value1"" };
                        $(""#id1"").dxTest(options);
                    });
                </script>",
                page.GetOutputText()
                );
        }
        public void RendersLoadActionDatasource_AllActions()
        {
            page.Datasource = new LoadActionDatasourceTagHelper(new UrlHelperFactoryMock())
            {
                Controller   = "Controller1",
                UpdateAction = "Action2",
                InsertAction = "Action3",
                DeleteAction = "Action4"
            };

            page.ExecuteSynchronously();

            var markup = page.GetOutputText();

            AssertIgnoreWhitespaces.Contains(@"""updateUrl"": ""ActionMock(Controller1, Action2)""", markup);
            AssertIgnoreWhitespaces.Contains(@"""insertUrl"": ""ActionMock(Controller1, Action3)""", markup);
            AssertIgnoreWhitespaces.Contains(@"""deleteUrl"": ""ActionMock(Controller1, Action4)""", markup);

            AssertIgnoreWhitespaces.DoesNotMatch("(update|insert|delete)Method", markup);
        }