public void TestNullableInt64() { NullableClass clazz = new NullableClass(); sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(clazz.Id, 1); Assert.IsNull(clazz.TestInt64); }
public void TestNullableTimeSpan() { NullableClass clazz = new NullableClass(); dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.IsNull(clazz.TestTimeSpan); }
public void TestNotNullableChar() { NullableClass clazz = new NullableClass(); clazz.TestChar = 'a'; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual('a', clazz.TestChar); }
public void TestNotNullableByte() { NullableClass clazz = new NullableClass(); clazz.TestByte = 155; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(155, clazz.TestByte); }
public void TestNotNullableBool() { NullableClass clazz = new NullableClass(); clazz.TestBool = false; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(false, clazz.TestBool); }
public void TestNotNullableBool() { NullableClass clazz = new NullableClass(); clazz.TestBool = false; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(false, clazz.TestBool); }
public void TestNotNullableChar() { NullableClass clazz = new NullableClass(); clazz.TestChar = 'a'; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual('a', clazz.TestChar); }
public void TestNotNullableDouble() { NullableClass clazz = new NullableClass(); clazz.TestDouble = 99.5125; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(99.5125, clazz.TestDouble); }
public void TestNotNullableInt16() { NullableClass clazz = new NullableClass(); clazz.TestInt16 = 45; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(45, clazz.TestInt16); }
public void TestNotNullableInt64() { NullableClass clazz = new NullableClass(); clazz.TestInt64 = 1234567890123456789; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(1234567890123456789, clazz.TestInt64); }
public void TestNotNullableSingle() { NullableClass clazz = new NullableClass(); clazz.TestSingle = 4578.46445454112f; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(4578.46445454112f, clazz.TestSingle); }
public void TestNotNullableDecimal() { NullableClass clazz = new NullableClass(); clazz.TestDecimal = 99.53M; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(99.53M, clazz.TestDecimal); }
public void TestNotNullableByte() { NullableClass clazz = new NullableClass(); clazz.TestByte = 155; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(155, clazz.TestByte); }
public void TestNotNullableDateTime() { NullableClass clazz = new NullableClass(); DateTime? date = new DateTime?(DateTime.Now); clazz.TestDateTime = date; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(date.Value.ToString(), clazz.TestDateTime.Value.ToString()); }
public void TestNotNullableGuid() { NullableClass clazz = new NullableClass(); Guid? guid = new Guid?(Guid.NewGuid()); clazz.TestGuid = guid; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(guid, clazz.TestGuid); }
public void TestNotNullableTimeSpan() { NullableClass clazz = new NullableClass(); TimeSpan? span = new TimeSpan?(new TimeSpan(1, 2, 3, 4, 5)); clazz.TestTimeSpan = span; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(span.Value.ToString(), clazz.TestTimeSpan.Value.ToString()); }
public void ConvertEntityToXml_NullableTest() { var nullableTestXml = @"<?xml version=""1.0"" encoding=""utf-8""?> <xml> <Id><![CDATA[10]]></Id> <Name><![CDATA[Jeffrey Su]]></Name> <AgentId></AgentId> <MchId>123</MchId> </xml>"; var doc = XDocument.Parse(nullableTestXml); var entity = new NullableClass(); EntityHelper.FillEntityWithXml(entity as RequestMessageBase, doc); Assert.AreEqual(10, entity.Id); Assert.AreEqual("Jeffrey Su", entity.Name); Assert.AreEqual(null, entity.AgentId); Assert.AreEqual(123, entity.MchId); }
public static void ConditionalNull() { NullableClass variable = null; int? k = variable?.K; NullableClass[] array = null; k = array?[0].K; k = array?[0]?.K; NullableClass[] notnullarray = new NullableClass[] { new() }; try { // vérifiez toujours que l'index est bien dans les limites du tableau k = notnullarray?[1]?.K; } catch (IndexOutOfRangeException e) { Console.WriteLine("L'index n'existe pas dans le tableau"); } }
public void TestNullableViaResultClass() { NullableClass clazz = new NullableClass(); dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetClassNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.IsNull(clazz.TestBool); Assert.IsNull(clazz.TestByte); Assert.IsNull(clazz.TestChar); Assert.IsNull(clazz.TestDateTime); Assert.IsNull(clazz.TestDecimal); Assert.IsNull(clazz.TestDouble); Assert.IsNull(clazz.TestGuid); Assert.IsNull(clazz.TestInt16); Assert.IsNull(clazz.TestInt32); Assert.IsNull(clazz.TestInt64); Assert.IsNull(clazz.TestSingle); }
public void TestNullableArgument() { NullableClass clazz = new NullableClass(); clazz.TestBool = true; clazz.TestByte = 155; clazz.TestChar = 'a'; DateTime?date = new DateTime?(DateTime.Now); clazz.TestDateTime = date; clazz.TestDecimal = 99.53M; clazz.TestDouble = 99.5125; Guid?guid = new Guid?(Guid.NewGuid()); clazz.TestGuid = guid; clazz.TestInt16 = 45; clazz.TestInt32 = null; clazz.TestInt64 = 1234567890123456789; clazz.TestSingle = 4578.46445454112f; dataMapper.Insert("InsertNullable", clazz); clazz = null; clazz = dataMapper.QueryForObject <NullableClass>("GetNullableConstructor", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.IsTrue(clazz.TestBool.Value); Assert.AreEqual(155, clazz.TestByte); Assert.AreEqual('a', clazz.TestChar); Assert.AreEqual(date.Value.ToString(), clazz.TestDateTime.Value.ToString()); Assert.AreEqual(99.53M, clazz.TestDecimal); Assert.AreEqual(99.5125, clazz.TestDouble); Assert.AreEqual(guid, clazz.TestGuid); Assert.AreEqual(45, clazz.TestInt16); Assert.IsNull(clazz.TestInt32); Assert.AreEqual(1234567890123456789, clazz.TestInt64); Assert.AreEqual(4578.46445454112f, clazz.TestSingle); }
public void SaveSheetUseFormatForNullable() { // Arrange var exporter = new Mapper(); var sheetName = "newSheet"; var dateFormat = "yyyy.MM.dd hh.mm.ss"; var obj1 = new NullableClass { NullableDateTime = null, DummyString = "dummy" }; var obj2 = new NullableClass { NullableDateTime = DateTime.Now }; if (File.Exists(FileName)) { File.Delete(FileName); } // Act exporter.UseFormat(typeof(DateTime?), dateFormat); // Issue #5, if the first data row has null value, then next rows will not be formated // So here we make the first date row has a null value for DateTime? property. exporter.Save(FileName, new[] { obj1, obj2 }, sheetName); var items = exporter.Take <NullableClass>(sheetName).ToList(); var dateCell = exporter.Workbook.GetSheetAt(0).GetRow(2).GetCell(0); // Assert Assert.AreEqual(3, exporter.Workbook.GetSheet(sheetName).PhysicalNumberOfRows); Assert.AreEqual(obj1.DummyString, items.First().Value.DummyString); Assert.AreEqual(obj2.NullableDateTime.Value.ToLongDateString(), items.Skip(1).First().Value.NullableDateTime.Value.ToLongDateString()); Assert.IsTrue(DateUtil.IsCellDateFormatted(dateCell)); Assert.AreEqual(obj2.NullableDateTime.Value.ToLongDateString(), items.Skip(1).First().Value.NullableDateTime.Value.ToLongDateString()); Assert.IsFalse(exporter.Take <NullableClass>(sheetName).First().Value.NullableDateTime.HasValue); }
public void TestNotNullableDateTime() { NullableClass clazz = new NullableClass(); DateTime? date = new DateTime?(DateTime.Now); clazz.TestDateTime = date; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(date.Value.ToString(), clazz.TestDateTime.Value.ToString()); }
public void TestNotNullableDouble() { NullableClass clazz = new NullableClass(); clazz.TestDouble = 99.5125; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(99.5125, clazz.TestDouble); }
public void TestNotNullableGuid() { NullableClass clazz = new NullableClass(); Guid? guid = new Guid?(Guid.NewGuid()); clazz.TestGuid = guid; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(guid, clazz.TestGuid); }
public void TestNotNullableInt16() { NullableClass clazz = new NullableClass(); clazz.TestInt16 = 45; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(45, clazz.TestInt16); }
public void TestNotNullableInt64() { NullableClass clazz = new NullableClass(); clazz.TestInt64 = 1234567890123456789; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(1234567890123456789, clazz.TestInt64); }
public void TestNotNullableTimeSpan() { NullableClass clazz = new NullableClass(); TimeSpan? span = new TimeSpan?(new TimeSpan(1, 2, 3, 4, 5)); clazz.TestTimeSpan = span; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.AreEqual(span.Value.ToString(), clazz.TestTimeSpan.Value.ToString()); }
public void TestNullableSingle() { NullableClass clazz = new NullableClass(); sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(clazz.Id, 1); Assert.IsNull(clazz.TestSingle); }
public void TestNullableTimeSpan() { NullableClass clazz = new NullableClass(); sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.IsNull(clazz.TestTimeSpan); }
public void TestNullableViaResultClass() { NullableClass clazz = new NullableClass(); sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetClassNullable", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.IsNull(clazz.TestBool); Assert.IsNull(clazz.TestByte); Assert.IsNull(clazz.TestChar); Assert.IsNull(clazz.TestDateTime); Assert.IsNull(clazz.TestDecimal); Assert.IsNull(clazz.TestDouble); Assert.IsNull(clazz.TestGuid); Assert.IsNull(clazz.TestInt16); Assert.IsNull(clazz.TestInt32); Assert.IsNull(clazz.TestInt64); Assert.IsNull(clazz.TestSingle); }
public void DesNullableTest() { object obj = NullableClass.GetSampleInstance(); PerformTest(obj); }
public void TestNullableArgument() { NullableClass clazz = new NullableClass(); clazz.TestBool = true; clazz.TestByte = 155; clazz.TestChar = 'a'; DateTime? date = new DateTime?(DateTime.Now); clazz.TestDateTime = date; clazz.TestDecimal = 99.53M; clazz.TestDouble = 99.5125; Guid? guid = new Guid?(Guid.NewGuid()); clazz.TestGuid = guid; clazz.TestInt16 = 45; clazz.TestInt32 = null; clazz.TestInt64 = 1234567890123456789; clazz.TestSingle = 4578.46445454112f; sqlMap.Insert("InsertNullable", clazz); clazz = null; clazz = sqlMap.QueryForObject<NullableClass>("GetNullableConstructor", 1); Assert.IsNotNull(clazz); Assert.AreEqual(1, clazz.Id); Assert.IsTrue(clazz.TestBool.Value); Assert.AreEqual(155, clazz.TestByte); Assert.AreEqual('a', clazz.TestChar); Assert.AreEqual(date.Value.ToString(), clazz.TestDateTime.Value.ToString()); Assert.AreEqual(99.53M, clazz.TestDecimal); Assert.AreEqual(99.5125, clazz.TestDouble); Assert.AreEqual(guid, clazz.TestGuid); Assert.AreEqual(45, clazz.TestInt16); Assert.IsNull(clazz.TestInt32); Assert.AreEqual(1234567890123456789, clazz.TestInt64); Assert.AreEqual(4578.46445454112f, clazz.TestSingle); }