예제 #1
0
        public void TestCollection()
        {
            ObservableNumericValueCollection collection = new ObservableNumericValueCollection();

            ObservableInt oInt = new ObservableInt {
                Value = 1, Min = -1, Max = 1
            };

            collection.Add(oInt);

            Assert.AreEqual(1, collection.Count);
            Assert.AreEqual(1, collection.Get(0).Value);

            Console.WriteLine(collection.Get(0).Value);

            collection.Add(oInt);

            Assert.AreEqual(2, collection.Count);
            Assert.AreEqual(1, collection[1].Value);
            Console.WriteLine(collection[1].Value);
            Console.WriteLine(collection[1].Value.GetType());

            collection[0].Value = 0;

            foreach (IObservableNumericValue val in collection)
            {
                Console.WriteLine(val.Value);
            }
        }
예제 #2
0
        public void TestIndexOf()
        {
            ObservableNumericValueCollection collection = new ObservableNumericValueCollection();

            ObservableInt oInt = new ObservableInt {
                Label = "int1", Value = 1, Min = -1, Max = 1
            };
            ObservableInt oInt2 = new ObservableInt {
                Value = 2, Min = -1, Max = 1
            };
            ObservableInt dontContain = new ObservableInt {
                Value = 3, Min = -1, Max = 1
            };

            collection.Add(oInt);
            collection.Add(oInt2);

            // This is a new observable int that is not added to the list, but has a label and value that exists
            ObservableInt checkExists = new ObservableInt {
                Label = "int1", Value = 1, Min = -1, Max = 1
            };

            Assert.AreEqual(0, collection.IndexOf(oInt));
            Assert.AreEqual(0, collection.IndexOf(checkExists));
            Assert.AreEqual(1, collection.IndexOf(oInt2));
            Assert.AreEqual(-1, collection.IndexOf(dontContain));
        }
예제 #3
0
        public void TestCollectionInsert()
        {
            ObservableNumericValueCollection collection = new ObservableNumericValueCollection();

            ObservableInt oInt = new ObservableInt {
                Value = 1, Min = -1, Max = 1
            };
            ObservableInt oInt2 = new ObservableInt {
                Value = 2, Min = -1, Max = 1
            };
            ObservableInt oInt3 = new ObservableInt {
                Value = 3, Min = -1, Max = 1
            };
            ObservableFloat oFloat = new ObservableFloat {
                Value = 4.0f, Min = -1.0f, Max = 1.0f
            };

            collection.Add(oInt);
            collection.Add(oInt2);
            collection.Add(oInt3);

            collection.Insert(1, oFloat);

            Assert.AreEqual(1, collection[0].Value);
            Assert.AreEqual(4.0f, collection[1].Value);
            Assert.AreEqual(2, collection[2].Value);
            Assert.AreEqual(3, collection[3].Value);
        }
예제 #4
0
        public void TestConainsLabel()
        {
            ObservableNumericValueCollection collection = new ObservableNumericValueCollection();

            ObservableInt oInt = new ObservableInt {
                Label = "int1", Value = 1, Min = -1, Max = 1
            };

            collection.Add(oInt);

            Assert.IsTrue(collection.ContainsLabel("int1"));
            Assert.IsFalse(collection.ContainsLabel("iDoNotExist"));
        }
예제 #5
0
        public void TestStringIndexAccess()
        {
            ObservableNumericValueCollection collection = new ObservableNumericValueCollection();

            ObservableInt oInt = new ObservableInt {
                Label = "int1", Value = 1, Min = -1, Max = 1
            };
            ObservableInt oInt2 = new ObservableInt {
                Value = 1, Min = -1, Max = 1
            };

            collection.Add(oInt);
            collection.Add(oInt2);

            Assert.AreEqual(oInt, collection["int1"]);
        }
예제 #6
0
        public void TestContains()
        {
            ObservableNumericValueCollection collection = new ObservableNumericValueCollection();

            ObservableInt oInt = new ObservableInt {
                Value = 1, Min = -1, Max = 1
            };
            ObservableInt oInt2 = new ObservableInt {
                Value = 2, Min = -1, Max = 1
            };
            ObservableInt oInt3 = new ObservableInt {
                Value = 3, Min = -1, Max = 1
            };

            collection.Add(oInt);
            collection.Add(oInt2);
            collection.Add(oInt3);

            Assert.IsTrue(collection.Contains(oInt));
            Assert.IsTrue(collection.Contains(oInt2));
            Assert.IsTrue(collection.Contains(oInt3));
        }