public void LoadInTest() { bool flag = true; string msg = string.Empty; try { DynamicEntity dey = MockData.CreateEntityWithReferenceEntity(); DateTime dt1 = DateTime.Now; DynamicEntity d = DESchemaObjectAdapter.Instance.Load(dey.ID) as DynamicEntity; d.Name = "这是一个新的Name"; DEObjectOperations.InstanceWithoutPermissions.UpdateEntity(d); d = DESchemaObjectAdapter.Instance.Load(d.ID, dt1, false) as DynamicEntity; DynamicEntity d2 = DESchemaObjectAdapter.Instance.Load(dey.ID) as DynamicEntity; if (d.Name == dey.Name && d2.Name == "这是一个新的Name") { flag = true; } } catch (Exception ex) { flag = false; msg = ex.Message; } Assert.IsTrue(flag, "时间穿梭失败" + msg); }
public void EntityInstanceDefaultValueTest() { DynamicEntity emptyEntity = MockData.CreateEntityWithReferenceEntity(); var emptyInstance = emptyEntity.CreateInstance(); Assert.AreEqual(99, Convert.ToDecimal(emptyInstance.Fields["总金额"].GetRealValue()), "实体实例默认值测试失败"); }
public void EntitySerialize() { DynamicEntity sourceEntity = MockData.CreateEntityWithReferenceEntity(); string json = JSONSerializerExecute.Serialize(sourceEntity); sourceEntity.Fields.ForEach(f => { Assert.IsTrue(json.Contains(f.Name), string.Format("不能再序列化的JSON中找到属性名{0}", f.Name)); }); }
public void EntityDeserializeTest() { DynamicEntity sourceEntity = MockData.CreateEntityWithReferenceEntity(); string json = JSONSerializerExecute.Serialize(sourceEntity); DynamicEntity targetEntity = JSONSerializerExecute.Deserialize <DynamicEntity>(json); Assert.IsNotNull(targetEntity); Assert.IsNotNull(targetEntity.Fields); Assert.AreEqual(sourceEntity.Fields.Count, targetEntity.Fields.Count); for (int i = 0; i < sourceEntity.Fields.Count; i++) { Assert.AreEqual(sourceEntity.Fields[i].Name, targetEntity.Fields[i].Name); } }