public void Verify_that_equals_returns_expected_result() { this.cachekey_1 = new CacheKey(this.guid_1, null); this.cachekey_2 = new CacheKey(this.guid_1, null); Assert.IsTrue(cachekey_1.Equals(cachekey_2)); this.cachekey_1 = new CacheKey(this.guid_1, null); this.cachekey_2 = new CacheKey(this.guid_2, null); Assert.IsFalse(cachekey_1.Equals(cachekey_2)); this.cachekey_1 = new CacheKey(this.guid_1, this.guid_2); this.cachekey_2 = new CacheKey(this.guid_1, this.guid_2); Assert.IsTrue(cachekey_1.Equals(cachekey_2)); this.cachekey_1 = new CacheKey(this.guid_1, this.guid_2); this.cachekey_2 = new CacheKey(this.guid_2, this.guid_1); Assert.IsFalse(cachekey_1.Equals(cachekey_2)); this.cachekey_1 = new CacheKey(this.guid_1, this.guid_2); this.cachekey_2 = new CacheKey(this.guid_1, null); Assert.IsFalse(cachekey_1.Equals(cachekey_2)); this.cachekey_1 = new CacheKey(this.guid_1, null); this.cachekey_2 = new CacheKey(this.guid_1, this.guid_2); Assert.IsFalse(cachekey_1.Equals(cachekey_2)); }
public void Equals_WithNullReference_ReturnsFalse() { var subjectA = new CacheKey("OK", 0, 0); var subjectB = (CacheKey)null; Assert.That(subjectA.Equals(subjectB), Is.False); }
public void Equals_WithIdenticalCacheKeys_ReturnsTrue([Values(0, 1, 2)] int stateKey, [Values(0, 1, 2)] int location) { var subjectA = new CacheKey("OK", stateKey, location); var subjectB = new CacheKey("OK", stateKey, location); Assert.That(subjectA.Equals(subjectB), Is.True); }
public void Equals_WithDifferentCacheKeys_ReturnsFalse() { var subjectA = new CacheKey("OK", 0, 0); var subjectB = new CacheKey("OK", 1, 0); Assert.That(subjectA.Equals(subjectB), Is.False); }
/// <summary> /// Compara a instancia o objeto informado. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { bool flag = false; MetaInformation information = obj as MetaInformation; if (information != null) { flag = CacheKey.Equals(information.CacheKey); } return(flag); }
private static void DoTestClassEquals(long firstLong, long secondLong) { // Two cache keys are equal except for the parameter. CacheKey key = new CacheKey(); key.Update(firstLong); CacheKey aDifferentKey = new CacheKey(); key.Update(secondLong); Assert.IsFalse(aDifferentKey.Equals(key)); // should not be equal. }
public void KeysShouldBeEqualWhenItemAndProviderAreEqual() { // Arrange const int itemId = 1; const int providerId = 2; var a = new CacheKey(providerId, itemId); var b = new CacheKey(providerId, itemId); // Act var ab = a.Equals(b); var ba = b.Equals(a); // Assert Assert.True(ab); Assert.True(ba); }
public void KeysShouldBeDifferentWhenDifferentItemIdIsUsed() { // Arrange const int providerId = 1; const int itemA = 2; const int itemB = 3; var a = new CacheKey(providerId, itemA); var b = new CacheKey(providerId, itemB); // Act var ab = a.Equals(b); var ba = b.Equals(a); // Assert Assert.False(ab); Assert.False(ba); }
public void KeysShouldBeDifferentWhenDifferentProviderIsUsed() { // Arrange const string providerA = "1"; const string providerB = "2"; const string itemId = "3"; var a = new CacheKey(providerA, itemId); var b = new CacheKey(providerB, itemId); // Act var ab = a.Equals(b); var ba = b.Equals(a); // Assert Assert.False(ab); Assert.False(ba); }
public void CacheKeyWithTwoParamsSameHashcode() { CacheKey key1 = new CacheKey(); CacheKey key2 = new CacheKey(); key1.Update("HS1CS001"); key1.Update("HS1D4001"); key2.Update("HS1D4001"); key2.Update("HS1CS001"); #if dotnet2 Assert.Ignore("The .NET 2.0 CLR uses a different algorithm for string hashing than the .NET 1.1 CLR."); #else Assert.AreEqual(key1.GetHashCode(), key2.GetHashCode(), "Expect same hashcode."); Assert.IsFalse(key1.Equals(key2), "Expect not equal"); #endif }
public void CacheKeyWithSameHashcode() { CacheKey key1 = new CacheKey(); CacheKey key2 = new CacheKey(); key1.Update("HS1CS001"); key2.Update("HS1D4001"); /* * The string hash algorithm is not an industry standard and is not guaranteed to produce the same behaviour between versions. * And in fact it does not. The .NET 2.0 CLR uses a different algorithm for string hashing than the .NET 1.1 CLR. */ #if dotnet2 Assert.Ignore("The .NET 2.0 CLR uses a different algorithm for string hashing than the .NET 1.1 CLR."); #else Assert.AreEqual(key1.GetHashCode(), key2.GetHashCode(), "Expect same hashcode."); Assert.IsFalse(key1.Equals(key2), "Expect not equal"); #endif }