예제 #1
0
        public void GetHashCode_One_Object()
        {
            var income = new Income
            {
                Amount   = 120,
                Category = new IncomeCategory
                {
                    Id   = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date     = DateTime.Today,
                Id       = 0,
                Method   = new PaymentMethod
                {
                    Id   = 0,
                    Name = "Method"
                }
            };

            Assert.AreEqual(income.GetHashCode(), income.GetHashCode());
        }
예제 #2
0
        public void GetHashCode_Two_Objects()
        {
            var first = new Income
            {
                Amount   = 120,
                Category = new IncomeCategory
                {
                    Id   = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date     = DateTime.Today,
                Id       = 0,
                Method   = new PaymentMethod
                {
                    Id   = 0,
                    Name = "Method"
                }
            };

            var second = new Income
            {
                Amount   = 120,
                Category = new IncomeCategory
                {
                    Id   = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date     = DateTime.Today,
                Id       = 0,
                Method   = new PaymentMethod
                {
                    Id   = 0,
                    Name = "Method"
                }
            };

            Assert.AreNotSame(first, second);
            Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
        }
예제 #3
0
        public void GetHashCode_Two_Objects()
        {
            var first = new Income
            {
                Amount = 120,
                Category = new IncomeCategory
                {
                    Id = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date = DateTime.Today,
                Id = 0,
                Method = new PaymentMethod
                {
                    Id = 0,
                    Name = "Method"
                }
            };

            var second = new Income
            {
                Amount = 120,
                Category = new IncomeCategory
                {
                    Id = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date = DateTime.Today,
                Id = 0,
                Method = new PaymentMethod
                {
                    Id = 0,
                    Name = "Method"
                }
            };

            Assert.AreNotSame(first, second);
            Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
        }
예제 #4
0
        public void GetHashCode_One_Object()
        {
            var Income = new Income
            {
                Amount = 120,
                Category = new IncomeCategory
                {
                    Id = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date = DateTime.Today,
                Id = 0,
                Method = new PaymentMethod
                {
                    Id = 0,
                    Name = "Method"
                }
            };

            Assert.AreEqual(Income.GetHashCode(), Income.GetHashCode());
        }