public void TestSaveMetaEntityUpdate() { var metaDataService = new MetaDataService(); var metaEntity = Repository.MetaEntities.First(); var entityValidator = new EntityValidator(metaEntity); var metaField = Repository.MetaFields.Single(mf => mf.Id == 1); var intFieldValidator = new FieldValidator <int?>(metaField, entityValidator); intFieldValidator.ValueCheckings.Add(CheckValue); entityValidator.FieldValidators.Add(intFieldValidator); metaField = Repository.MetaFields.Single(mf => mf.Id == 2); var stringFieldValidator = new FieldValidator <string>(metaField, entityValidator); stringFieldValidator.ValueCheckings.Add(CheckValue); entityValidator.FieldValidators.Add(stringFieldValidator); metaEntity.Label = "New Label"; var results = metaDataService.SaveMetaEntity(entityValidator, metaEntity); Assert.IsNotEmpty(results); Assert.AreEqual(2, results.Count); CollectionAssert.AllItemsAreNotNull(results); Assert.True(results.All(r => r.IsValid)); Assert.AreEqual(1, Repository.MetaEntities.Count); CollectionAssert.Contains(Repository.MetaEntities, metaEntity); Assert.AreEqual(1, metaEntity.Id); Assert.AreNotEqual(DateTime.MinValue, metaEntity.LastUpdateDate); Assert.NotNull(metaEntity.LastUpdateUser); Assert.AreNotEqual(metaEntity.CreationDate, metaEntity.LastUpdateDate); Assert.AreSame(metaEntity.CreationUser, metaEntity.LastUpdateUser); }
private void Validate(IEntityValidator entityValidator, IEntity entity) { MetaDataService.SaveMetaEntity(entityValidator, (IMetaEntity)entity); }