public void JointCollectionVM_JointsAddTest_ReturnsEqualCountTrue() { 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 = { firstJoint, secondJoint } }; var creatureStructureVM = new CreatureStructureVM(creatureStructure); int expected = creatureStructureVM.JointCollectionVM.Count; Assert.AreEqual(expected, creatureStructure.Joints.Count); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
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); }
public void Add_AddSameViewModelItem_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 boneVM = new BoneVM(new Bone(firstJoint, secondJoint) { SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density }); new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList()).Add(boneVM); Assert.Throws <NotSupportedException>(() => new EncapsulatingObservableCollection <BoneVM, Bone>(creatureStructure.Bones, creatureStructure.Bones.Select(b => new BoneVM(b)).ToList()).Add(boneVM)); }
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); }
public void BoneCollectionVM_BonesAddTest_ReturnsEqualCountFalse() { 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 = { firstJoint, secondJoint } }; int actual = creatureStructure.Bones.Count; var creatureStructureVM = new CreatureStructureVM(creatureStructure); creatureStructureVM.BoneCollectionVM.Add(new BoneVM(new Bone(firstJoint, secondJoint) { SecondJoint = secondJoint, FirstJoint = firstJoint, Density = density })); int expected = creatureStructureVM.BoneCollectionVM.Count; Assert.AreNotEqual(expected, actual); }