예제 #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 TestContainsAttribute()
        {
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute      attribute = new Attribute("SnagL");
            AttributeValue original  = new AttributeValue("SnagL");

            globalAttributeCollection.Add(attribute, original);
            Assert.IsTrue(globalAttributeCollection.ContainsAttribute(attribute));
        }
예제 #3
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);
        }
예제 #4
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"));
        }
예제 #5
0
        public void VerifyCollectionContainsAttributeAfterAddingIt()
        {
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute      attribute = new Attribute("SnagL");
            AttributeValue value     = new AttributeValue("SnagL");
            bool           actual;

            globalAttributeCollection.Add(attribute, value);
            actual = globalAttributeCollection.ContainsAttribute(attribute);

            Assert.IsTrue(actual);
        }
예제 #6
0
        public void TestGetAttributeByName()
        {
            Attribute                 actual;
            Attribute                 expected = new Attribute("SnagL");
            AttributeValue            value    = new AttributeValue("SnagL");
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");

            globalAttributeCollection.Add(expected, value);
            actual = globalAttributeCollection.GetAttribute(expected.Name);

            Assert.AreEqual <Attribute>(expected, actual);
        }
예제 #7
0
        public void TestRemoveByAttributeRemovesAttribute()
        {
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute      attribute = new Attribute("SnagL");
            AttributeValue original  = new AttributeValue("SnagL");

            globalAttributeCollection.Add(attribute, original);

            if (!globalAttributeCollection.ContainsAttribute(attribute))
            {
                Assert.Inconclusive("The Attribute that was just added to the GlobalAttributeCollection was not found");
            }

            globalAttributeCollection.Remove(attribute);
            Assert.IsFalse(globalAttributeCollection.ContainsAttribute(attribute));
        }
예제 #8
0
        public void TestAddMethodThrowsExceptionIfNullAttributeValue()
        {
            bool exceptionCaught = false;
            GlobalAttributeCollection globalAttributeCollection = GlobalAttributeCollection.GetInstance("SnagL");
            Attribute attribute = new Attribute("SnagL");

            try
            {
                globalAttributeCollection.Add(attribute, null);
            }
            catch (System.ArgumentNullException)
            {
                exceptionCaught = true;
            }

            Assert.IsTrue(exceptionCaught);
        }
예제 #9
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);
        }
예제 #10
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();
        }
예제 #11
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();
        }