Пример #1
0
        public void GetEnumrator_GetEnumratorTest_GetEnumratorTrue()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var model = new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            };
            var boneVM = new BoneVM(model);

            collObjectCollection.Insert(1, boneVM);

            // ReSharper disable once GenericEnumeratorNotDisposed
            var enumrator = collObjectCollection.GetEnumerator();

            int count = 0;

            while (enumrator.MoveNext())
            {
                count++;
            }

            Assert.AreEqual(count, 3);
        }
Пример #2
0
        public void CopyTo_CopyTest_CopyTrue()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var model = new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            };
            var boneVM = new BoneVM(model);

            collObjectCollection.Insert(1, boneVM);
            var boneVms = new BoneVM[collObjectCollection.Count];

            collObjectCollection.CopyTo(boneVms, 0);

            bool contains = boneVms[1].Density.Equals(density);

            Assert.True(contains);
        }
Пример #3
0
        public void Add_AddItem_AddedTrue()
        {//updates
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            // creatureStructure.Bones.Select(b=>new BoneVM(b)).ToList()
            // creatureStructure.Bones.Select(b=>new BoneVM(b)).ToList()
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var boneVM = new BoneVM(new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            });

            collObjectCollection.Add(boneVM);

            int afterCount = collObjectCollection.Count;

            Assert.AreEqual(afterCount, 3);
        }
Пример #4
0
        public void IndexOf_ViewModelIndexTest_SameIndexFalse()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var model = new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            };
            var boneVM = new BoneVM(model);

            collObjectCollection.Insert(1, boneVM);

            int index = collObjectCollection.IndexOf(boneVM);

            Assert.IsFalse(index != 1);
        }
Пример #5
0
        public void Remove_RemoveTest_RemoveFalse()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var model = new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            };
            var boneVM = new BoneVM(model);

            collObjectCollection.Add(boneVM);

            bool removed = collObjectCollection.Remove(boneVM);

            Assert.AreNotEqual(removed, false);
        }
Пример #6
0
        public void Clear_ClearTest_ClearTrue()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var model = new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            };
            var boneVM = new BoneVM(model);

            collObjectCollection.Add(boneVM);

            collObjectCollection.Clear();

            Assert.AreEqual(collObjectCollection.Count, 0);
        }
Пример #7
0
        public void Insert_InsertSameModelItem_NotSupportedExceptionTrue()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var model = new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            };
            var boneVM = new BoneVM(model);

            collObjectCollection.Insert(0, boneVM);
            var boneVM2 = new BoneVM(model);

            Assert.Throws <NotSupportedException>(() => collObjectCollection.Insert(0, boneVM2));
        }
Пример #8
0
        public void Insert_InsertItem_InsertedFalse()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());
            var boneVM = new BoneVM(new Bone(firstJoint, secondJoint)
            {
                SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density
            });

            collObjectCollection.Insert(0, boneVM);

            int afterCount = collObjectCollection.Count;

            Assert.AreNotEqual(afterCount, 2);
        }
Пример #9
0
        public void RemoveAt_RemoveAtTest_RemovedFalse()
        {
            const float density    = 2;
            var         firstJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var secondJoint = new Joint()
            {
                Position = new Vector2(5, 10)
            };
            var creatureStructure = new CreatureStructure()
            {
                Bones =
                {
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    },
                    new Bone(firstJoint, secondJoint)
                    {
                        SecondJoint = secondJoint,FirstJoint           = firstJoint, Density = density
                    }
                },
                Joints = { new Joint()
                           {
                               Position = new Vector2(5, 10)
                           }, new Joint()
                           {
                               Position = new Vector2(5, 10)
                           } }
            };
            var collObjectCollection = new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList());

            collObjectCollection.RemoveAt(0);

            Assert.AreNotEqual(collObjectCollection.Count, 2);
        }