예제 #1
0
        public void GetHashCodeTest()
        {
            const int ReoccurEveryNWeek = 1;
            const bool Sunday = true;
            const bool Monday = true;
            const bool Tuesday = true;
            const bool Wednesday = true;
            const bool Thursday = true;
            const bool Friday = true;
            const bool Saturday = true;

            var hash = ReoccurEveryNWeek.GetHashCode()
                       ^ ((Sunday.GetHashCode() << 1) ^ (Monday.GetHashCode() << 2) ^ (Tuesday.GetHashCode() << 3) ^ (Wednesday.GetHashCode() << 4) ^ (Thursday.GetHashCode() << 5)
                          ^ (Friday.GetHashCode() << 6) ^ (Saturday.GetHashCode() << 7));

            var instance = new WeeklyPattern
                               {
                                   ReoccurEveryNWeek = ReoccurEveryNWeek,
                                   Sunday = Sunday,
                                   Monday = Monday,
                                   Tuesday = Tuesday,
                                   Wednesday = Wednesday,
                                   Thursday = Thursday,
                                   Friday = Friday,
                                   Saturday = Saturday
                               };

            var res = instance.GetHashCode();

            Assert.AreEqual(hash, res);
        }