public void TestCreatedOnWithTable() { var o = new DateTable { Name = "tom" }; DbEntry.Insert(o); Assert.AreEqual("INSERT INTO [DateTable] ([CreatedOn],[Name]) VALUES (DATETIME(CURRENT_TIMESTAMP, 'localtime'),@Name_0);\nSELECT LAST_INSERT_ROWID();\n<Text><30>(@Name_0=tom:String)", StaticRecorder.LastMessage); }
public void TestInsert() { var u = new lzUser2 { Name = "tom" }; u.Profile.Value = "test"; DbEntry.Insert(u); Assert.AreEqual("INSERT INTO [lz_User2] ([Name],[Profile]) VALUES (@Name_0,@Profile_1);\nSELECT LAST_INSERT_ROWID();\n<Text><30>(@Name_0=tom:String,@Profile_1=test:String)", StaticRecorder.LastMessage); }
public void TestNotPublicClass() { try { var obj = new NotPublic { Name = "tom" }; DbEntry.Insert(obj); Assert.IsTrue(false); } catch (DataException ex) { Assert.AreEqual("[Leafing.UnitTest.Data.Inner.NotPublic]The model class should be public.", ex.Message); } }
public void Test1() { SqlRecorder.Start(); var o = new LeafingEnum { Name = "test", Type = 10, Value = null }; DbEntry.Insert(o); AssertSql(@"INSERT INTO [Leafing_Enum] ([Type],[Name],[Value]) VALUES (@Type_0,@Name_1,@Value_2); SELECT LAST_INSERT_ROWID(); <Text><30>(@Type_0=10:Int32,@Name_1=test:String,@Value_2=<NULL>:Int32)", SqlRecorder.LastMessage); SqlRecorder.Stop(); }
public void Test3() { var gid = Guid.NewGuid(); var o1 = new SelfGuid { Id = gid, Name = "tom" }; DbEntry.Insert(o1); var o2 = DbEntry.GetObject <SelfGuid>(gid); Assert.IsNotNull(o2); Assert.AreEqual("tom", o2.Name); }
public void TestForFirebird() { // try create table first. DbEntry.From <Mkey3>().Where(Condition.Empty).GetCount(); StaticRecorder.ClearMessages(); // real test var o = new Mkey3 { Name = "test", Age = 18, Gender = true }; DbEntry.Insert(o); Assert.AreEqual(1, StaticRecorder.Messages.Count); AssertSql(@"INSERT INTO ""MKEY3"" (""NAME"",""AGE"",""GENDER"") VALUES (@Name_0,@Age_1,@Gender_2);<Text><30>(@Name_0=test:String,@Age_1=18:Int32,@Gender_2=True:Boolean)"); }
public void TestForMkey() { DbEntry.Create(typeof(Mkey)); var p1 = new Mkey { FirstName = "test", LastName = "next", Age = 11 }; DbEntry.Insert(p1); var p2 = DbEntry.From <Mkey>().Where(p => p.FirstName == "test" && p.LastName == "next").Select()[0]; Assert.AreEqual(11, p2.Age); p2.Age = 18; DbEntry.Update(p2); var p3 = DbEntry.From <Mkey>().Where(p => p.FirstName == "test" && p.LastName == "next").Select()[0]; Assert.AreEqual(18, p3.Age); }