コード例 #1
0
 public static void AreEqual(TestNullableObject object1, TestNullableObject object2)
 {
     Assert.AreEqual(object1.Id, object2.Id);
     Assert.AreEqual(object1.StringValue, object2.StringValue);
     Assert.AreEqual(object1.IntValue, object2.IntValue);
     Assert.AreEqual(object1.LongValue, object2.LongValue);
     Assert.AreEqual(object1.DecimalValue, object2.DecimalValue);
     Assert.AreEqual(object1.BoolValue, object2.BoolValue);
     Assert.AreEqual(object1.DateTimeValue, object2.DateTimeValue);
     Assert.AreEqual(object1.EnumValue, object2.EnumValue);
 }
コード例 #2
0
        public void TestNullableObjectCRUD()
        {
            //property not null
            Random             random  = new Random();
            TestNullableObject object1 = new TestNullableObject();

            object1.StringValue  = new string(Enumerable.Repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 10).Select(s => s[random.Next(s.Length)]).ToArray());
            object1.IntValue     = random.Next();
            object1.LongValue    = random.Next();
            object1.DecimalValue = Math.Round(Convert.ToDecimal(random.NextDouble()), 4);
            object1.BoolValue    = random.Next(100) < 50;
            DateTime now = DateTime.Now;

            now = now.AddTicks(-(now.Ticks % TimeSpan.TicksPerSecond));
            //Console.Out.WriteLine(now.ToString("yyyy-MM-dd HH:mm:ss:fffffff"));
            object1.DateTimeValue = now;
            object1.EnumValue     = (TestEnum)Enum.Parse(typeof(TestEnum), random.Next(1, 3).ToString());
            _testNullableObjectDao.Insert(object1);

            TestNullableObject object2 = _testNullableObjectDao.SelectById(object1.Id);

            AssertHelper.AreEqual(object1, object2);

            _testNullableObjectDao.DeleteById(object1.Id);
            Assert.IsNull(_testNullableObjectDao.SelectById(object1.Id));

            //property null
            TestNullableObject object4 = new TestNullableObject();

            _testNullableObjectDao.Insert(object4);

            TestNullableObject object5 = _testNullableObjectDao.SelectById(object4.Id);

            AssertHelper.AreEqual(object4, object5);
            Assert.IsNull(object5.EnumValue);
            //if config nullValue="Enum1"
            //Assert.AreEqual(object5.EnumValue, TestEnum.Enum1);

            _testNullableObjectDao.DeleteById(object4.Id);
            Assert.IsNull(_testNullableObjectDao.SelectById(object4.Id));
        }
コード例 #3
0
 public void Update(TestNullableObject testNullableObject)
 {
     _sqlMapper.Update("TestNullableObject.Update", testNullableObject);
 }
コード例 #4
0
 public void Insert(TestNullableObject testNullableObject)
 {
     _sqlMapper.Insert("TestNullableObject.Insert", testNullableObject);
 }