Example #1
0
        public void StringSelectorClone()
        {
            tlog.Debug(tag, $"StringSelectorClone START");

            Selector <string> selector = new Selector <string>
            {
                Pressed          = image_path,
                Disabled         = image_path,
                DisabledFocused  = image_path,
                DisabledSelected = image_path,
                Other            = image_path
            };

            var testingTarget = new StringSelector(selector);

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <StringSelector>(testingTarget, "Should return StringSelector instance.");

            try
            {
                var result = testingTarget.Clone();
                tlog.Debug(tag, "result : " + result);
            }
            catch (Exception)
            {
                //  System.InvalidCastException : Unable to cast object
                //  of type 'Tizen.NUI.BaseComponents.Selector`1[Tizen.NUI.String]'
                //  to type 'Tizen.NUI.Components.StringSelector'

                // To fix

                tlog.Debug(tag, $"StringSelectorClone END (OK)");
                Assert.Pass("Passed!");
            }
        }
Example #2
0
        public void Should_Add_Selector_To_Back_Of_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector <string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors <string>().First();

            Assert.IsInstanceOf <StringSelector>(firstselector);

            //Add the second selector (FullNameSelector) to the back of the processing queue
            table.AddSelector(stringSelector2, SelectorPosition.Last);
            Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <StringSelector>(firstselector);

            var lastselector = table.GetSelectors <string>().Last();

            Assert.IsInstanceOf <FullNameSelector>(lastselector);
        }
Example #3
0
        public void Should_Add_Type_Selectors_For_Single_Type_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();
            var stringSelector3 = new EmailSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector <string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors <string>().First();

            Assert.IsInstanceOf <StringSelector>(firstselector);

            //Add the second selector (the full name selector)
            table.AddSelector <string>(stringSelector2);
            Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <FullNameSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!

            //Add the thrid selector (the email address selector)
            table.AddSelector <string>(stringSelector3);
            Assert.AreEqual(3, table.CountSelectors <string>(), "should have THREE type selectors for type 'string'");

            firstselector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <EmailSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!
        }
        public void Should_Use_Custom_StringLength_Boundaries_for_String_Value_Injection()
        {
            //Create an instance of our test class
            var testInstance = new SimpleStringTestClass();

            var stringLengthMax = 30;
            var stringLengthMin = 10;

            //Create an instance of our IntSelector and set some custom bounds
            var selector =
                new StringSelector().SetMax(() => stringLengthMax)
                .SetMin(() => stringLengthMin);

            //Iterate over the test object's properties
            foreach (var property in testInstance.GetType().GetProperties())
            {
                Assert.IsTrue(selector.CanBind(property),
                              string.Format("should have been able to bind to property {0}", property.Name));

                //Inject the value into this property on our test instance class
                selector.Generate(testInstance, property);

                //Get the value out of the property
                var fieldValue = (string)property.GetValue(testInstance, null);
                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsTrue(fieldValue.Length <= stringLengthMax && fieldValue.Length >= stringLengthMin, "Custom range should have worked");
            }
        }
Example #5
0
        public void Should_Add_Selector_To_Back_Of_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            //Add the second selector (FullNameSelector) to the back of the processing queue
            table.AddSelector(stringSelector2, SelectorPosition.Last);
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            var lastselector = table.GetSelectors<string>().Last();
            Assert.IsInstanceOf<FullNameSelector>(lastselector);
        }
Example #6
0
 public RenderingRule(string mark, string openingTag, string closingTag, int priorotyLevel)
 {
     Mark          = mark;
     OpeningTag    = openingTag;
     ClosingTag    = closingTag;
     PriorityLevel = priorotyLevel;
     Selector      = new StringSelector();
 }
Example #7
0
        public void Should_Add_Type_Selectors_For_Multiple_Types_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some string selectors that we're going to add
            var stringSelector1 = new StringSelector();

            //Create some long selectors that we're going to use...
            var longSelector1 = new LongSelector();
            var longSelector2 = new TimeStampSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");
            Assert.AreEqual(0, table.CountSelectors <long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet");

            //Add the first and only string selector (our default string selector)
            table.AddSelector <string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(0, table.CountSelectors <long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet"); //Assert that we haven't added any long selectors yet

            var firstStringSelector = table.GetSelectors <string>().First();

            Assert.IsInstanceOf <StringSelector>(firstStringSelector);

            var currentLongSelector = table.GetSelectors <long>().FirstOrDefault();

            Assert.IsNull(currentLongSelector); //Since we haven't added any long selectors yet, this should return null

            //Add the first long selector (our default long selector)
            table.AddSelector <long>(longSelector1);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(1, table.CountSelectors <long>(), "should have ONE type selectors for type 'long'");

            firstStringSelector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors <long>().FirstOrDefault();
            Assert.IsInstanceOf <LongSelector>(currentLongSelector);

            //Add the final long selector (our timestamp selector)
            table.AddSelector <long>(longSelector2);
            Assert.AreEqual(1, table.CountSelectors <string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(2, table.CountSelectors <long>(), "should have TWO type selectors for type 'long'");

            firstStringSelector = table.GetSelectors <string>().First();
            Assert.IsInstanceOf <StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors <long>().FirstOrDefault();
            Assert.IsInstanceOf <TimeStampSelector>(currentLongSelector);
        }
Example #8
0
        public void Should_Add_Type_Selectors_For_Multiple_Types_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some string selectors that we're going to add
            var stringSelector1 = new StringSelector();

            //Create some long selectors that we're going to use...
            var longSelector1 = new LongSelector();
            var longSelector2 = new TimeStampSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");
            Assert.AreEqual(0, table.CountSelectors<long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet");

            //Add the first and only string selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(0, table.CountSelectors<long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet"); //Assert that we haven't added any long selectors yet

            var firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            var currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsNull(currentLongSelector); //Since we haven't added any long selectors yet, this should return null

            //Add the first long selector (our default long selector)
            table.AddSelector<long>(longSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(1, table.CountSelectors<long>(), "should have ONE type selectors for type 'long'");

            firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsInstanceOf<LongSelector>(currentLongSelector);

            //Add the final long selector (our timestamp selector)
            table.AddSelector<long>(longSelector2);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(2, table.CountSelectors<long>(), "should have TWO type selectors for type 'long'");

            firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsInstanceOf<TimeStampSelector>(currentLongSelector);
        }
Example #9
0
        public void StringSelectorTest()
        {
            // Arrange
            var data = MakeObject();
            var op   = new StringSelector {
                Key = "a"
            };

            // Act
            var result = op.RunAsSequence(data);

            // Assert
            Json.Array(result)
            .DeepEqual(Utils.JsonNumberArray(1))
            .Should().BeTrue();
        }
Example #10
0
        public void OptionalStringSelectorTest()
        {
            // Arrange
            var data = MakeArray();
            var op   = new StringSelector {
                Key = "a", IsOptional = true
            };

            // Act
            var result = op.RunAsSequence(data);

            // Assert
            Json.Array(result)
            .DeepEqual("[]".AsJson())
            .Should().BeTrue();
        }
Example #11
0
        public void IconURLSelector_SET_GET_VALUE()
        {
            /* TEST CODE */
            var button = new Components.Button();

            Assert.IsNotNull(button, "Should be not null");
            Assert.IsInstanceOf <Components.Button>(button, "Should be equal!");
            var stringSelector = new StringSelector
            {
                Normal   = _image_path,
                Selected = _image_path,
            };

            Assert.IsNotNull(stringSelector, "Should be not null");
            Assert.IsInstanceOf <StringSelector>(stringSelector, "Should be equal!");

            button.IconURLSelector = stringSelector;
            Assert.AreEqual(stringSelector.Normal, button.IconURLSelector.Normal, "Should be equals to the set value of IconURLSelector Normal");
            Assert.AreEqual(stringSelector.Selected, button.IconURLSelector.Selected, "Should be equals to the set value of IconURLSelector Selected");
        }
Example #12
0
        public void TextSelector_SET_GET_VALUE()
        {
            /* TEST CODE */
            var button = new Components.Button();

            Assert.IsNotNull(button, "Should be not null");
            Assert.IsInstanceOf <Components.Button>(button, "Should be equal!");
            var stringSelector = new StringSelector
            {
                Normal   = "Normal",
                Selected = "Selected",
            };

            Assert.IsNotNull(stringSelector, "Should be not null");
            Assert.IsInstanceOf <StringSelector>(stringSelector, "Should be equal!");

            button.TextSelector = stringSelector;
            Assert.AreEqual(stringSelector.Normal, button.TextSelector.Normal, "Should be equals to the set value of TextSelector");
            Assert.AreEqual(stringSelector.Selected, button.TextSelector.Selected, "Should be equals to the set value of TextSelector");
        }
Example #13
0
        public void String_Selector_Injects_All_Strings()
        {
            var stringSelector     = new StringSelector();
            var randomStringsClass = new RandomStringsClass();

            //Iterate over all of the properties in the fullNameClass object...
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                //Inject the value into the property
                stringSelector.Generate(randomStringsClass, property);
            }

            //Iterate over all of the properties again
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                var fieldValue = property.GetValue(randomStringsClass, null) as string;

                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsAssignableFrom <string>(fieldValue, "Should be type of string...");
                Assert.That(fieldValue.Length > 0);
            }
        }
Example #14
0
        public void TranslatableTextSelector_SET_GET_VALUE()
        {
            /* TEST CODE */
            ResourceManager testRm = new ResourceManager("Tizen.NUI.Devel.Tests.Properties.Resources", typeof(ButtonTests).Assembly);

            NUIApplication.MultilingualResourceManager = testRm;

            var button = new Components.Button();

            Assert.IsNotNull(button, "Should be not null");
            Assert.IsInstanceOf <Components.Button>(button, "Should be equal!");
            var stringSelector = new StringSelector
            {
                Normal   = "Normal",
                Selected = "Selected",
            };

            Assert.IsNotNull(stringSelector, "Should be not null");
            Assert.IsInstanceOf <StringSelector>(stringSelector, "Should be equal!");

            button.TranslatableTextSelector = stringSelector;
            Assert.AreEqual(stringSelector.Normal, button.TranslatableTextSelector.Normal, "Should be equals to the set value of TranslatableTextSelector");
            Assert.AreEqual(stringSelector.Selected, button.TranslatableTextSelector.Selected, "Should be equals to the set value of TranslatableTextSelector");
        }
Example #15
0
        public void Should_Clear_TypeSelector_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors <string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add some type selectors to our typetable
            table.AddSelector(stringSelector1);
            table.AddSelector(stringSelector2);

            //Check to see that our table contains at least two items...
            Assert.AreEqual(2, table.CountSelectors <string>(), "should have TWO type selectors for type 'string'");

            //Clear all of the string selectors
            table.ClearSelectors <string>();

            //Count the new number of string selectors (should equal zero)
            Assert.AreEqual(0, table.CountSelectors <string>());
        }
Example #16
0
        public void Should_Use_Custom_StringLength_Boundaries_for_String_Value_Injection()
        {
            //Create an instance of our test class
            var testInstance = new SimpleStringTestClass();

            var stringLengthMax = 30;
            var stringLengthMin = 10;

            //Create an instance of our IntSelector and set some custom bounds
            var selector =
                new StringSelector().SetMax(() => stringLengthMax)
                                 .SetMin(() => stringLengthMin);

            //Iterate over the test object's properties
            foreach (var property in testInstance.GetType().GetProperties())
            {
                Assert.IsTrue(selector.CanBind(property),
                              string.Format("should have been able to bind to property {0}", property.Name));

                //Inject the value into this property on our test instance class
                selector.Generate(testInstance, property);

                //Get the value out of the property
                var fieldValue = (string)property.GetValue(testInstance, null);
                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsTrue(fieldValue.Length <= stringLengthMax && fieldValue.Length >= stringLengthMin, "Custom range should have worked");
            }
        }
        public void String_Selector_Injects_All_Strings()
        {
            var stringSelector = new StringSelector();
            var randomStringsClass = new RandomStringsClass();

            //Iterate over all of the properties in the fullNameClass object...
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                //Inject the value into the property
                stringSelector.Generate(randomStringsClass, property);
            }

            //Iterate over all of the properties again
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                var fieldValue = property.GetValue(randomStringsClass, null) as string;

                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsAssignableFrom<string>(fieldValue, "Should be type of string...");
                Assert.That(fieldValue.Length > 0);
            }
        }
        void Initialize()
        {
            Window.Instance.KeyEvent += WindowKeyEvent;

            MainView                        = new View();
            MainView.Size                   = new Size2D(CheckBoxSize.Width + 100, 4 * CheckBoxSize.Height + 5 * Space);
            MainView.PivotPoint             = PivotPoint.Center;
            MainView.ParentOrigin           = ParentOrigin.Center;
            MainView.PositionUsesPivotPoint = true;
            MainView.BackgroundColor        = Color.White;
            Window.Instance.Add(MainView);

            // Default CheckBox
            CheckBoxExample                        = new CheckBox();
            CheckBoxExample.Size                   = CheckBoxSize;
            CheckBoxExample.ParentOrigin           = ParentOrigin.TopCenter;
            CheckBoxExample.PositionUsesPivotPoint = true;
            CheckBoxExample.PivotPoint             = PivotPoint.TopCenter;
            CheckBoxExample.Position               = new Position(0, Space);
            MainView.Add(CheckBoxExample);

            // Create with properties
            CheckBoxExample                        = new CheckBox();
            CheckBoxExample.Size                   = CheckBoxSize;
            CheckBoxExample.ParentOrigin           = ParentOrigin.Center;
            CheckBoxExample.PositionUsesPivotPoint = true;
            CheckBoxExample.PivotPoint             = PivotPoint.Center;
            CheckBoxExample.Position               = new Position(0, -(CheckBoxSize.Height + Space) / 2);
            // Set the icon images for different check box states
            StringSelector IconURL = new StringSelector()
            {
                Normal   = ImageURL + "Blue.png",
                Selected = ImageURL + "BlueCheckMark.png",
                Pressed  = ImageURL + "Red.png",
            };

            CheckBoxExample.IconURLSelector = IconURL;
            CheckBoxExample.Icon.Size       = new Size2D(160, 160);
            CheckBoxExample.BackgroundColor = new Color(0.57f, 0.7f, 1.0f, 0.8f);
            // CheckBox initial state set to be selected
            CheckBoxExample.IsSelected = true;
            // CheckBox can be selected
            CheckBoxExample.IsSelectable = true;
            // CheckBox is enabled
            CheckBoxExample.IsEnabled = true;
            MainView.Add(CheckBoxExample);

            // Create with style - since the CheckBox inherits after the Button class, the ButtonStyle is used
            ButtonStyle Style = new ButtonStyle
            {
                IsSelectable           = true,
                ParentOrigin           = ParentOrigin.Center,
                PositionUsesPivotPoint = true,
                PivotPoint             = PivotPoint.Center,
                Position = new Position(0, (CheckBoxSize.Height + Space) / 2),
                Size     = CheckBoxSize,
                // Gray structural background
                BackgroundImage = ImageURL + "Struct.png",
                // Image overlaid on the background
                Icon = new ImageViewStyle
                {
                    Size = CheckBoxSize,
                    // Different icon used depending on the status
                    ResourceUrl = new Selector <string>
                    {
                        Other    = ImageURL + "XSign.png",
                        Selected = ImageURL + "CheckMark.png"
                    },
                    // Icon opacity set to 0.8 for all checkbox states
                    Opacity = 0.8f,
                    // Shadow visible for all states
                    ImageShadow = new ImageShadow(ImageURL + "Shadow.png")
                },
                // Style of the overlay image
                Overlay = new ImageViewStyle()
                {
                    ResourceUrl = new Selector <string>
                    {
                        Pressed = ImageURL + "Red.png",
                        Other   = ImageURL + "LightBlue.png"
                    },
                    Opacity = new Selector <float?> {
                        Pressed = 0.3f, Other = 1.0f
                    }
                }
            };

            CheckBoxExample = new CheckBox(Style);
            MainView.Add(CheckBoxExample);

            // Create with custom style
            // Custom style registration
            Tizen.NUI.Components.StyleManager.Instance.RegisterStyle("_CustomCheckBoxStyle", null, typeof(NUI_CheckBox.CustomCheckBoxStyle));
            CustomCheckBox          = new CheckBox("_CustomCheckBoxStyle");
            CustomCheckBox.Position = new Position(0, -Space);
            // Click event handle
            CustomCheckBox.Clicked += OnClicked;
            MainView.Add(CustomCheckBox);
        }
Example #19
0
        public void Should_Add_Type_Selectors_For_Single_Type_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();
            var stringSelector3 = new EmailSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            //Add the second selector (the full name selector)
            table.AddSelector<string>(stringSelector2);
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<FullNameSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!

            //Add the thrid selector (the email address selector)
            table.AddSelector<string>(stringSelector3);
            Assert.AreEqual(3, table.CountSelectors<string>(), "should have THREE type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<EmailSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!
        }
Example #20
0
        public void Should_Clear_TypeSelector_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add some type selectors to our typetable
            table.AddSelector(stringSelector1);
            table.AddSelector(stringSelector2);

            //Check to see that our table contains at least two items...
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            //Clear all of the string selectors
            table.ClearSelectors<string>();

            //Count the new number of string selectors (should equal zero)
            Assert.AreEqual(0, table.CountSelectors<string>());
        }