/// <summary> /// Tests the ObjectId method using polymorphism. /// </summary> public void GetObjectIdTest(DiaryProduct product, ObjectId objectId) { var actual = product.GetObjectId(); Assert.AreEqual(objectId.AsInt(), actual.AsInt(), "Data"); Assert.AreEqual(objectId.GetHashCode(), actual.GetHashCode(), "Identity"); }
public void CopyConstructorTest() { var objectId = new ObjectId(); var objectId2 = new ObjectId(objectId.AsInt()); Assert.AreEqual(objectId.ToString(), objectId2.ToString(), "Data is equal"); Assert.AreNotEqual(objectId, objectId2, "Identity is unequal"); }
public void GetObjectIdTest() { var objectId = new ObjectId(); var expected = ToString(1, "1"); var actual = ToString(objectId.AsInt(), objectId.ToString()); Assert.AreEqual(expected, actual); var objectId2 = new ObjectId(); expected = ToString(2, "2"); actual = ToString(objectId2.AsInt(), objectId2.ToString()); Assert.AreEqual(expected, actual); }
public void TestKeyLookup() { var keyFile = new KeyFile("C:/Persistence", "Test"); var objectId = new ObjectId(); var deepCopiedObjectId = new ObjectId(objectId.AsInt()); keyFile.Update(objectId, 100, 1000); int offset = 0; int dataSizeBytes = 0; Assert.IsTrue(keyFile.Get(objectId, ref offset, ref dataSizeBytes), "Original"); Assert.IsTrue(keyFile.Get(deepCopiedObjectId, ref offset, ref dataSizeBytes), "Deep copy"); }
public void CompareToTest() { var objectId = new ObjectId(); var objectId2 = new ObjectId(); var objectId3 = new ObjectId(objectId2.AsInt()); var actual = objectId.CompareTo(objectId2); Assert.AreEqual(-1, actual, "Input ObjectId:<{0}>. Input Compare ObjectId:<{1}>.", objectId.AsInt(), objectId2.AsInt()); actual = objectId2.CompareTo(objectId); Assert.AreEqual(1, actual, "Input ObjectId:<{0}>. Input Compare ObjectId:<{1}>.", objectId2.AsInt(), objectId.AsInt()); actual = objectId2.CompareTo(objectId3); Assert.AreEqual(0, actual, "Input ObjectId:<{0}>. Input Compare ObjectId:<{1}>.", objectId2.AsInt(), objectId3.AsInt()); }