public void HashCode_Compute_Objects() { var now = DateTime.Now; var ranges = new[] { new TimeRange(null, null), new TimeRange(null, now), new TimeRange(now, null), new TimeRange(now, now) }; foreach (var range in ranges) { var hash1 = HashTool.Compute(range.Start, range.End); var hash2 = HashTool.Compute(range.End, range.Start); if (Equals(range.Start, range.End)) { hash1.Should().Be(hash2); hash1.Should().Not.Be(0); } else { hash1.Should().Not.Be.EqualTo(hash2); } } }
public override int GetHashCode() { return(HashTool.Compute(ProjectId, TaskId, StartTime, EndTime)); }
public override int GetHashCode() { return(HashTool.Compute(Culture, WeekOfYearRule, StartOffset, EndOffset)); }
public void DateRange_HashCode_Test() { DateTime now = DateTime.Now; var ranges = new[] { new TimeRange(null, null), new TimeRange(null, now), new TimeRange(now, null), new TimeRange(now, now) }; foreach (var range in ranges) { var hash1 = HashTool.Compute(range.Start, range.End); var hash2 = HashTool.Compute(range.End, range.Start); Console.WriteLine("Range=[{0}], hash1=[{1}], hash2=[{2}]", range, hash1, hash2); if (Equals(range.Start, range.End) == false) { Assert.AreNotEqual(hash1, hash2); } else { Assert.AreEqual(hash1, hash2); Assert.AreNotEqual(0, hash1, "TimeRange=" + range); } } }
public void HashCode_Compute() { HashToolFixture.Entity entity = null; HashTool.Compute(entity).Should().Be(0); entity = new HashToolFixture.Entity(Guid.NewGuid(), "abc"); HashTool.Compute(entity).Should().Not.Be.EqualTo(0).And.Be(entity.GetHashCode()); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(TimeRange, IsException)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(Id, Name, GetType().FullName)); }
public override int GetHashCode() { return(HashTool.Compute(Calendar, YearBaseMonth, FirstDayOfWeek, Date1, Date2, Difference)); }
/// <summary> /// Hash Code를 계산합니다. /// </summary> /// <returns></returns> public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(AssemblyName, Section, ResourceKey)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(SubmittedDate, Submitted)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(Name)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(GetType(), ReporterId, ReportDate)); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(Department, User)); }
/// <summary> /// Returns a hash code for the triple, suitable for use in a hash-table or other hashed collection. /// Two triples that compare equal (using Equals) will have the same hash code. The hash code for /// the triple is derived by combining the hash codes for each of the two elements of the triple. /// </summary> /// <returns>The hash code.</returns> public override int GetHashCode() { return(HashTool.Compute(First, Second, Third)); // Build the hash code from the hash codes of First and Second. //int hashFirst = (First == null) ? 0x61E04917 : First.GetHashCode(); //int hashSecond = (Second == null) ? 0x198ED6A3 : Second.GetHashCode(); //int hashThird = (Third == null) ? 0x40FC1877 : Third.GetHashCode(); //return hashFirst ^ hashSecond ^ hashThird; }
public override int GetHashCode() { //! NOTE: JSON 포맷에서는 DateTime 비교를 항상 JsonDateTime 포맷으로 해야합니다. // return(HashTool.Compute(Id, Name, Description, Number, Description, CreateAt.ToJsonDateTime())); }
public override int GetHashCode() { if (IsSaved) { return(base.GetHashCode()); } return(HashTool.Compute(ProjectId, TaskId, StartTime, EndTime, PeriodKind)); }
public void ValueType_Combine_ViseVersa(int x, int y) { int hash1 = HashTool.Compute(x, y); int hash2 = HashTool.Compute(y, x); if (x != y) { Assert.AreNotEqual(hash1, hash2, "HashCode 값의 순서에 따라 HashCode 값이 달라야 합니다."); } else { Assert.AreEqual(hash1, hash2); } }
public void NullableType_Compute_Test(int?x, int?y) { var hash1 = HashTool.Compute(x, y); var hash2 = HashTool.Compute(y, x); if (x.GetValueOrDefault() != y.GetValueOrDefault()) { Assert.AreNotEqual(hash1, hash2); } else { Assert.AreEqual(hash1, hash2); } }
public void NullableType_CombineInOrder_Test(int?x, int?y) { var hash1 = HashTool.Compute(x.GetValueOrDefault(), y.GetValueOrDefault()); var hash2 = HashTool.Compute(y.GetValueOrDefault(), x.GetValueOrDefault()); if (x.GetValueOrDefault() == y.GetValueOrDefault()) { Assert.AreEqual(hash1, hash2); } else { Assert.AreNotEqual(hash1, hash2); } }
public void Params_Combine_Test(int x, int y, int z, int k) { var codes = new[] { x, y, z, k }; var codesReverse = new[] { k, z, y, x }; var hash1 = HashTool.Compute(codes); var hash2 = HashTool.Compute(codesReverse); if (ArrayTool.Compare(codes, codesReverse)) { Assert.AreEqual(hash1, hash2, "두 Array의 값이 같다면, HashCode 값도 같아야 합니다."); } else { Assert.AreNotEqual(hash1, hash2, "HashTool.Compute은 입력 값의 순서에 따라서도 HashCode 값이 달라야 합니다."); } }
public void Params_CombineInOrder_Test(int x, int y, int z, int k) { var codes = new[] { x, y, z, k }; var codesReverse = codes.Reverse().ToArray(); int hash1 = HashTool.Compute(codes); int hash2 = HashTool.Compute(codesReverse); if (ArrayTool.Compare(codes, codesReverse)) { Assert.AreEqual(hash1, hash2, "hash1={0}, hash2={1}", hash1, hash2); } else { Assert.AreNotEqual(hash1, hash2, "hash1={0}, hash2={1}", hash1, hash2); } }
public void String_HashCode() { const int Count = 1000; const string productName = "NSoft.NFramework"; var productHashCode = HashTool.Compute(productName); var codes = Enumerable.Range(0, Count).Select(i => "CODE_ITEM_CODE_" + i.ToString("X4")).ToList(); var hashList = new HashSet <int>(); foreach (var code in codes) { hashList.Add(HashTool.Compute(productHashCode, HashTool.Compute(code))).Should().Be.True(); } Assert.AreEqual(Count, hashList.Count); }
public void ValueType_CombineInOrder_Test(int x, int y) { int hash1 = HashTool.Compute(x, y); int hash2 = HashTool.Compute(y, x); if (x == y) { hash1.Should().Be(hash2); } if (x != y) { hash1.Should().Not.Be.EqualTo(hash2); } //Assert.IsTrue(hash1 != hash2, "hash1={0}, hash2={1}", hash1, hash2); }
public override int GetHashCode() { return(HashTool.Compute(base.GetHashCode(), StartQuarter, QuarterCount, EndQuarter)); }
public override int GetHashCode() { return(IsSaved ? base.GetHashCode() : HashTool.Compute(Code)); }
public override int GetHashCode() { return(HashTool.Compute(_id, _name, _guid)); }
public override int GetHashCode() { return(HashTool.Compute(FullName, FileKind, Size, FileDateTime)); }
public override int GetHashCode() { return(HashTool.Compute(TargetType, MapOption)); }
public override int GetHashCode() { return(HashTool.Compute(CategoryId, CategoryName)); }
public override int GetHashCode() { return(HashTool.Compute(Name, Description)); }