Beispiel #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();
        }
Beispiel #2
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();
        }