示例#1
0
 public void ShouldResetContentsOnBind()
 {
     listElement = new ListElement(property);
     listElement.Controls.ItemsSection.Clear();
     TestWindow.rootVisualElement.Add(listElement);
     listElement.BindProperty(property);
     Assert.Greater(listElement.Controls.ItemsSection.childCount, 0);
 }
示例#2
0
        public void ShouldHaveContents()
        {
            listElement = new ListElement(true);
            TestWindow.rootVisualElement.Add(listElement);
            listElement.BindProperty(property);

            Assert.Greater(listElement.childCount, 0);
        }
示例#3
0
        public void ShouldClearTheControlContents()
        {
            VisualElement testElement = new VisualElement();

            listElement = new ListElement(true);
            listElement.Add(testElement);
            listElement.BindProperty(property);

            Assert.IsFalse(listElement.Contains(testElement));
        }
示例#4
0
        public void ShouldSendListResetEvent()
        {
            listElement = new ListElement(true);
            TestWindow.rootVisualElement.Add(listElement);

            listElement.RegisterCallback <ListResetEvent>(e => Assert.Pass());
            listElement.BindProperty(property);

            Assert.Fail("ListResetEvent Callback Not Called");
        }
示例#5
0
        public void ShouldBeSetFromFromUxml()
        {
            VisualElement test = new VisualElement();

            SingleAssetLoader.Load <VisualTreeAsset>(TestHelpers.DefaultTestTemplateWthOptionsSetName).CloneTree(test);

            ListElement listElement = test.Q <ListElement>();

            listElement.BindProperty(TestHelpers.GetProperty());
            //yield return null;
            var results = CompareSetsAreEqual(listElement.Options, testSet);

            if (results.Count > 0)
            {
                string errorLine = string.Join("\n",
                                               results.Select(x =>
                                                              $"{x.Name} was set to '{x.GetValue(GetListOptions(listElement.Options))}', should be '{x.GetValue(testSet)}'"));
                Assert.Fail($"Following options were not set correctly from UXML:\n{errorLine}");
            }
        }
示例#6
0
 public void WhenPropertyBoundAfter_ShouldInitialise()
 {
     listElement = new ListElement();
     listElement.BindProperty(property);
     Assert.IsTrue(listElement.IsInitialised);
 }