public void CultureUpdateTest() { GXLanguage item = new GXLanguage() { Id = "fi", EnglishName = "Finland", }; GXUpdateArgs args = GXUpdateArgs.Update(item); args.Exclude <GXLanguage>(e => e.EnglishName); Assert.AreEqual("Mikko", args.ToString()); }
public void RemoveUsersTest() { RemoveUser req = new RemoveUser(); req.Ids = new string[] { Guid.Empty.ToString(), Guid.Empty.ToString() }; //Set removed time for all the removed users. GXUser u = new GXUser() { Removed = DateTime.Now }; GXUpdateArgs update = GXUpdateArgs.Update(u, q => q.Removed); update.Where.And <GXUser>(q => req.Ids.Contains(q.Id)); Assert.AreEqual("", update.ToString()); }
public void UpdateConfigurationTest() { List <GXConfigurationValue> list = new List <GXConfigurationValue>(); list.Add(new GXConfigurationValue() { Id = Guid.NewGuid(), Name = "SiteName", }); list.Add(new GXConfigurationValue() { Id = Guid.NewGuid(), Name = "Email", }); list.Add(new GXConfigurationValue() { Id = Guid.NewGuid(), Name = "Slogan", }); // GXInsertArgs insert = GXInsertArgs.InsertRange(list, c => new { c.Id, c.Generation }); GXUpdateArgs args = GXUpdateArgs.UpdateRange(list); args.Exclude <GXConfigurationValue>(e => e.Group); Assert.AreEqual("Mikko", args.ToString()); }
public void EpochTimeFormatTest() { TestClass t = new TestClass(); t.Time = DateTime.SpecifyKind(new DateTime(2014, 1, 2), DateTimeKind.Utc); t.Id = 1; GXUpdateArgs args = GXUpdateArgs.Update(t); args.Settings.UseEpochTimeFormat = true; args.Add <TestClass>(t, x => x.Time); Assert.AreEqual("UPDATE TestClass SET `Time` = 1388620800 WHERE `ID` = 1", args.ToString()); }
public void UpdateTest() { TestClass t = new TestClass(); t.Id = 2; t.Time = DateTime.SpecifyKind(new DateTime(2014, 1, 2), DateTimeKind.Utc); GXUpdateArgs args = GXUpdateArgs.Update(t, x => new { x.Id, x.Guid, x.Time }); Assert.AreEqual("UPDATE TestClass SET `ID` = 2, `Guid` = '00000000000000000000000000000000', `Time` = '2014-01-02 00:00:00' WHERE `ID` = 2", args.ToString()); }
public void UpdateUserTest() { GXUser user = new GXUser(); user.Id = "1"; user.UserName = "******"; GXUpdateArgs arg2 = GXUpdateArgs.Update(user); arg2.Exclude <GXUser>(q => new { q.PasswordHash, q.SecurityStamp, q.CreationTime }); Assert.AreEqual("UPDATE [GXUser] SET [UserName] = 'Gurux', [NormalizedUserName] = NULL, [Email] = NULL, [NormalizedEmail] = NULL, [EmailConfirmed] = 0, [ConcurrencyStamp] = NULL, [PhoneNumber] = NULL, [PhoneNumberConfirmed] = 0, [TwoFactorEnabled] = 0, [LockoutEnd] = '00010101 00:00:00 +00:00', [LockoutEnabled] = 0, [AccessFailedCount] = 0, [Updated] = '00010101 00:00:00', [Detected] = '00010101 00:00:00', [Removed] = '00010101 00:00:00', [DateOfBirth] = NULL WHERE [ID] = '1'", arg2.ToString()); }
public void ExcludeUpdateTest() { string format = "yyyy-MM-dd HH:mm:ss"; DateTime dt = DateTime.ParseExact("2014-01-02 00:00:00", format, CultureInfo.CurrentCulture); TestClass t = new TestClass(); t.Id = 2; t.Time = DateTime.SpecifyKind(new DateTime(2014, 1, 2), DateTimeKind.Utc); GXUpdateArgs args = GXUpdateArgs.Update(t, x => new { x.Id, x.Guid, x.Time }); args.Exclude <TestClass>(x => new { x.Text, x.Text2, x.Text3, x.Text4, x.BooleanTest, x.IntTest, x.DoubleTest, x.FloatTest, x.Span, x.Object, x.Status }); Assert.AreEqual("UPDATE TestClass SET `ID` = 2, `Guid` = '00000000000000000000000000000000', `Time` = '" + dt.ToString(format) + "' WHERE `ID` = 2", args.ToString()); }
public void UpdateTest() { string format = "yyyy-MM-dd HH:mm:ss"; DateTime dt = DateTime.ParseExact("2014-01-02 00:00:00", format, CultureInfo.CurrentCulture); TestClass t = new TestClass(); t.Id = 2; t.Time = DateTime.SpecifyKind(new DateTime(2014, 1, 2), DateTimeKind.Utc); GXUpdateArgs args = GXUpdateArgs.Update(t, x => new { x.Id, x.Guid, x.Time }); Assert.AreEqual("UPDATE TestClass SET `ID` = 2, `Guid` = '00000000000000000000000000000000', `Time` = '" + dt.ToString(format) + "' WHERE `ID` = 2", args.ToString()); }