public void LibraryMethod_NegativeData_ThrowException(bool val) { // Act var ex = Assert.Throws <Exception>(() => SampleClass.LibraryMethod(val)); // Assert Assert.Equal("Something happened", ex.Message); Assert.Equal("USER_DB is not path pattern user_adminXXXX (Parameter 'con')", ex.InnerException?.Message); }
public void IgnoreAttributeTest() { // Prepare var sample = new SampleClass(); var date = DateTime.Now; const string str1 = "aBC"; var workbook = GetSimpleWorkbook(date, str1); workbook.GetSheetAt(1).GetRow(0).CreateCell(41).SetCellValue(nameof(sample.IgnoredAttributeProperty)); workbook.GetSheetAt(1).CreateRow(21).CreateCell(41).SetCellValue(str1); var importer = new Mapper(workbook); // Act var objs = importer.Take <SampleClass>(1).ToList(); // Assert Assert.IsNull(objs[0].Value.IgnoredAttributeProperty); }
public void UseLastNonBlankValueAttributeTest() { // Prepare var sample = new SampleClass(); var date = DateTime.Now; const string str1 = "aBC"; const string str2 = "BCD"; var workbook = GetSimpleWorkbook(date, str1); var header = workbook.GetSheetAt(1).GetRow(0).CreateCell(41); header.SetCellValue(nameof(sample.UseLastNonBlankValueAttributeProperty)); // Create 4 rows, row 22 and 23 have empty values. workbook.GetSheetAt(1).CreateRow(21).CreateCell(41).SetCellValue(str1); workbook.GetSheetAt(1).CreateRow(22).CreateCell(41).SetCellValue(string.Empty); workbook.GetSheetAt(1).CreateRow(23).CreateCell(41).SetCellValue(string.Empty); workbook.GetSheetAt(1).CreateRow(24).CreateCell(41).SetCellValue(str2); var importer = new Mapper(workbook); importer.SkipBlankRows = false; // Act var objs = importer.Take <SampleClass>(1).ToList(); // Assert Assert.IsNotNull(objs); Assert.AreEqual(5, objs.Count); var obj = objs[1]; Assert.AreEqual(str1, obj.Value.UseLastNonBlankValueAttributeProperty); obj = objs[2]; Assert.AreEqual(str1, obj.Value.UseLastNonBlankValueAttributeProperty); obj = objs[3]; Assert.AreEqual(str1, obj.Value.UseLastNonBlankValueAttributeProperty); obj = objs[4]; Assert.AreEqual(str2, obj.Value.UseLastNonBlankValueAttributeProperty); }
private static void Main(string[] args) { Rectangle r = new Rectangle(); r.length = 4.5; r.width = 3.5; r.Display(); ExecuteRectangle execute = new ExecuteRectangle(); execute.addNum(4, 5); execute.chageNumType(); object obj; obj = 100; Console.WriteLine(obj); Console.WriteLine(obj.GetType()); dynamic c = 12.6f; Console.WriteLine(c); string str = @"<script type=""text/javascript""> <!-- --> </script>"; Console.WriteLine(str); //execute.tryInput(); SampleClass sample = new SampleClass(11, 22); Console.WriteLine("x={0}, y={1}", sample.x, sample.y); Console.WriteLine("c1={0}, c2={1}", SampleClass.c1, SampleClass.c2); myClass mc = new myClass(); mc.aFunc(); mc.afunc1(); mc.afun2(); Console.ReadLine(); Console.WriteLine("=================="); myClass myClass = new myClass(); myClass.afunc1(); }
public void Limit_Smaller0_ThrowException(int value) { Assert.Throws <ArgumentException>(() => SampleClass.Limit(value)); }
public void Limit_Smaller100_ReturnCorrectData(int value) { Assert.Equal(value, SampleClass.Limit(value)); }
public void Limit_Greater100_ReturnCorrectData(int value) { Assert.Equal(100, SampleClass.Limit(value)); }