コード例 #1
0
        public void TestCollectionChangedWithUpdate()
        {
            bool eventRaised = false;
            NotifyCollectionChangedAction action = NotifyCollectionChangedAction.Add;
            Attribute                 attribute  = new SnagL.Infrastructure.Data.Attributes.Attribute("SnagL");
            AttributeValue            original   = new AttributeValue("SnagL");
            AttributeValue            newValue   = new AttributeValue("SnagLNew");
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");

            globalAttributeCollection.Clear();

            globalAttributeCollection.AttributeListUpdated += (sender, e) =>
            {
                action      = e.Action;
                eventRaised = true;
            };

            EnqueueCallback(() => globalAttributeCollection.Add(attribute, original));
            EnqueueCallback(() => globalAttributeCollection.Update(attribute, newValue, original));
            EnqueueConditional(() => eventRaised);

            EnqueueCallback(() => Assert.IsTrue(action == NotifyCollectionChangedAction.Replace));
            EnqueueCallback(() => Assert.IsTrue(eventRaised));
            EnqueueTestComplete();
        }
コード例 #2
0
        public void TestStringAccessor()
        {
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute      attribute = new Attribute("SnagL");
            AttributeValue original  = new AttributeValue("SnagL");

            globalAttributeCollection.Clear();
            globalAttributeCollection.Add(attribute, original);
            Assert.IsTrue(globalAttributeCollection["SnagL"].Count > 0);
        }
コード例 #3
0
        public void TestAttributeAccessor()
        {
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute      attribute = new Attribute("SnagL");
            AttributeValue original  = new AttributeValue("SnagL");

            globalAttributeCollection.Clear();
            globalAttributeCollection.Add(attribute, original);
            Assert.IsTrue(globalAttributeCollection[attribute].Contains("SnagL"));
        }
コード例 #4
0
        public void TestClearMethodClearsGlobalAttributeCollection()
        {
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute      attribute = new Attribute("SnagL");
            AttributeValue original  = new AttributeValue("SnagL");

            globalAttributeCollection.Add(attribute, original);

            // Make sure everything is working. Otherwise, we might have an invalid test.
            if (!(globalAttributeCollection.GetAttributes().Count > 0))
            {
                Assert.Inconclusive("Attribute collection count wasn't > 0 after attribute added.");
            }

            globalAttributeCollection.Clear();
            Assert.IsTrue(globalAttributeCollection.GetAttributes().Count == 0);
        }
コード例 #5
0
        public void TestCollectionChangedWithAdd()
        {
            bool                      eventRaised = false;
            Attribute                 attribute   = new SnagL.Infrastructure.Data.Attributes.Attribute("SnagL");
            AttributeValue            newValue    = new AttributeValue("SnagL");
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");

            globalAttributeCollection.Clear();

            globalAttributeCollection.AttributeListUpdated += (sender, e) => {
                eventRaised = true;
            };

            EnqueueCallback(() => globalAttributeCollection.Add(attribute, newValue));
            EnqueueConditional(() => eventRaised);

            EnqueueCallback(() => Assert.IsTrue(eventRaised));
            EnqueueTestComplete();
        }
コード例 #6
0
        public void TestAttributeValueUpdated()
        {
            bool eventRaised = false;
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute      attribute = new Attribute("SnagL");
            AttributeValue original  = new AttributeValue("SnagL");
            AttributeValue expected  = new AttributeValue("SnagLNew");
            AttributeValue actual    = null;

            globalAttributeCollection.AttributeListUpdated += (sender, e) =>
            {
                actual      = e.NewValue;
                eventRaised = true;
            };

            EnqueueCallback(() => globalAttributeCollection.Clear());
            EnqueueCallback(() => globalAttributeCollection.Add(attribute, original));
            EnqueueCallback(() => globalAttributeCollection.Update(attribute, expected, original));
            EnqueueConditional(() => eventRaised);

            EnqueueCallback(() => Assert.IsTrue(globalAttributeCollection[attribute].Contains(expected.Value)));
            EnqueueCallback(() => Assert.AreEqual(expected.Value, actual.Value));
            EnqueueTestComplete();
        }