public void InitValues() { var someValues = new List <SomeValues>(); var rd = new Random(DateTime.Now.Millisecond); for (int i = 0; i < 100; i++) { var sv = new SomeValues() { Id = i, ValueBit = false, ValueInt = i, ValueInt2 = rd.Next(Int32.MaxValue), ValueNVarchar = "测试", ValueVarchar = i + "abc" + i + "d" + i + "文本", ValueBigInt = i, ValueChar = 'A', ValueDate = DateTime.Today, ValueDatetime = DateTime.Now, ValueDatetime2 = DateTime.Now, ValueDatetimeOffset = DateTimeOffset.Now, ValueDecimal = (decimal)rd.NextDouble(), ValueFloat = (float)rd.NextDouble(), ValueNumeric = (decimal)rd.NextDouble(), ValueReal = rd.NextDouble(), ValueText = "测试" + i + "文本", ValueTinyint = (byte)i, ValueNChar = '测', }; someValues.Add(sv); } someValues[0].ValueVarchar = "testAProperty"; someValues[1].ValueVarchar = "testBField"; someValues[2].ValueVarchar = "testVarA"; someValues[3].ValueVarchar = "testVarB"; Context.DeleteBy <SomeValues>(null); var row = Context.Insert <SomeValues>(someValues); Assert.AreEqual(row, 100); }
public async Task Hello() { var f = new JilMediaTypeFormatter(); var value = new SomeValues { Id = 10, Name = "Elon Musk" }; var stream = new MemoryStream(); await f.WriteToStreamAsync(value.GetType(), value, stream, null, null); stream.Position = 0; var result = (SomeValues)await f.ReadFromStreamAsync(typeof(SomeValues), stream, null, null); Assert.That(result, Is.Not.Null); Assert.That(result.Id, Is.EqualTo(value.Id)); Assert.That(result.Name, Is.EqualTo(value.Name)); }
public GetAttributesAttribute(SomeValues TargetEnum) { }
public static void RunBookTest(bool isRun) { if (!isRun) { return; } Console.WriteLine("Hello World!"); int i = 10; int j = 10; Console.WriteLine("object.ReferenceEquals(i,j) = {0}", object.ReferenceEquals(i, j)); int iValue = 10; //Boxing int value object oValue = iValue; Console.WriteLine("Unboxing oValue result = " + (int)oValue); //执行到下面的代码会报错,提示非法的类型转换 //float fValue = (float)oValue; //Console.WriteLine("Unboxing oValue result = " + fValue); string str1 = "hello"; string str2 = "hello"; Console.WriteLine("object.ReferenceEquals(str1,str2) = {0}", object.ReferenceEquals(str1, str2)); string temp = "before changed"; ChangeStr(temp); Console.WriteLine(temp); TestUnsafe(false); TestInheritance.RunTest(false); Person person1 = new Person("God1"); person1.Print(); Person person2 = person1.Clone() as Person; person2.Name = "God2"; Console.WriteLine(person1.Name); Console.WriteLine(person2.Name); //person.PrintClassName(); //Person.PrintClassName(); //Global.PrintClassName(); SomeValues tmp = SomeValues.Value_0; Console.WriteLine(tmp.ToString()); Console.WriteLine(10.GetType ()); OuterClass outer_obj = new OuterClass(); outer_obj.ToString(); OuterClass.NestedClass nested_class = new OuterClass.NestedClass(); nested_class.PrintOuterObjCount(); nested_class.PrintNestedObjCount(); TestStaticMember(false); TestFuncArgTransmit(false); TestArgPass.RunTest(false); TestFraction.RunTest(false); TestStruct.RunTest(false); TestInterface.RunTest(false); TestDispose.RunTestDispose(false); TestArray.RunTest(true); TestString.RunTest(false); TestDelegateEvent.RunTest(false); //TestAttribute.RunTest (true); }