Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(ProjectId,
                             TaskId,
                             StartTime,
                             EndTime));
 }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(Culture,
                             WeekOfYearRule,
                             StartOffset,
                             EndOffset));
 }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(TimeRange, IsException));
        }
Exemplo n.º 7
0
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(Id, Name, GetType().FullName));
        }
Exemplo n.º 8
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(Calendar,
                             YearBaseMonth,
                             FirstDayOfWeek,
                             Date1,
                             Date2,
                             Difference));
 }
Exemplo n.º 9
0
        /// <summary>
        /// Hash Code를 계산합니다.
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(AssemblyName, Section, ResourceKey));
        }
Exemplo n.º 10
0
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(SubmittedDate, Submitted));
        }
Exemplo n.º 11
0
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(Name));
        }
Exemplo n.º 12
0
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(GetType(), ReporterId, ReportDate));
        }
Exemplo n.º 13
0
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(Department, User));
        }
Exemplo n.º 14
0
        /// <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;
        }
Exemplo n.º 15
0
 public override int GetHashCode()
 {
     //! NOTE: JSON 포맷에서는 DateTime 비교를 항상 JsonDateTime 포맷으로 해야합니다.
     //
     return(HashTool.Compute(Id,
                             Name,
                             Description,
                             Number,
                             Description,
                             CreateAt.ToJsonDateTime()));
 }
Exemplo n.º 16
0
        public override int GetHashCode()
        {
            if (IsSaved)
            {
                return(base.GetHashCode());
            }

            return(HashTool.Compute(ProjectId,
                                    TaskId,
                                    StartTime,
                                    EndTime,
                                    PeriodKind));
        }
Exemplo n.º 17
0
        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);
            }
        }
Exemplo n.º 18
0
        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);
            }
        }
Exemplo n.º 19
0
        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);
            }
        }
Exemplo n.º 20
0
        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 값이 달라야 합니다.");
            }
        }
Exemplo n.º 21
0
        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);
            }
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(base.GetHashCode(), StartQuarter, QuarterCount, EndQuarter));
 }
Exemplo n.º 25
0
 public override int GetHashCode()
 {
     return(IsSaved ? base.GetHashCode() : HashTool.Compute(Code));
 }
Exemplo n.º 26
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(_id, _name, _guid));
 }
Exemplo n.º 27
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(FullName, FileKind, Size, FileDateTime));
 }
Exemplo n.º 28
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(TargetType, MapOption));
 }
Exemplo n.º 29
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(CategoryId, CategoryName));
 }
Exemplo n.º 30
0
 public override int GetHashCode()
 {
     return(HashTool.Compute(Name, Description));
 }