public void FillGridRow(GridModel model) { HeaderServices headerServices = new HeaderServices(); var properties = model.GetType().GetProperties(); FillDate(model); foreach (var property in properties) { var value = property.GetValue(model); var header = headerServices.GetHeaderNameByProperty(property); if (value != default && header != default) { GridInputCell(model.RowIndex, GetIndexOfHeader(header)) .SetText(value.ToString()); } } UpdateButton.Click(); Wait.WaitUntillReady(RowIdColumn); }
public void GetSelectorMetadataTest() { var model = new GridModel(); var parentModel = new ParentModel(); var modelMetadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(model, model.GetType()); var parentModelPropertyMetadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(parentModel, parentModel.GetType()); var parentModelPropertiesMetadata = parentModelPropertyMetadata as List <ModelMetadata> ?? parentModelPropertyMetadata.ToList(); var modelPropertiesMetadata = modelMetadata as List <ModelMetadata> ?? modelMetadata.ToList(); ModelMetadata actual = GridHelper.GetSelectorMetadata(modelPropertiesMetadata.FirstOrDefault(), modelPropertiesMetadata, parentModelPropertiesMetadata.FirstOrDefault(), parentModelPropertiesMetadata); Assert.IsNull(actual); var s = parentModelPropertiesMetadata.First(p => p.PropertyName == "SingleSelectGrid"); ModelMetadata actual1 = GridHelper.GetSelectorMetadata(modelPropertiesMetadata.FirstOrDefault(), modelPropertiesMetadata, s, parentModelPropertiesMetadata); Assert.IsNotNull(actual1); Assert.IsTrue(actual1.ContainerType == typeof(ParentModel)); var m = parentModelPropertiesMetadata.First(p => p.PropertyName == "MultipleSelectGrid"); ModelMetadata actual2 = GridHelper.GetSelectorMetadata(modelPropertiesMetadata.FirstOrDefault(), modelPropertiesMetadata, m, parentModelPropertiesMetadata); Assert.IsNotNull(actual2); Assert.IsTrue(actual2.ContainerType == typeof(GridModel)); }
public void GetSelectionTypeTest() { var model = new GridModel(); var parentModel = new ParentModel(); var modelMetadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(model, model.GetType()); var parentModelPropertyMetadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(parentModel, parentModel.GetType()); var modelPropertyMetadata = parentModelPropertyMetadata as List <ModelMetadata> ?? parentModelPropertyMetadata.ToList(); var d = modelPropertyMetadata.First(p => p.PropertyName == "DisplayGrid"); var modelMetadatas = modelMetadata as List <ModelMetadata> ?? modelMetadata.ToList(); SelectionType actual = GridHelper.GetSelectionType(modelMetadatas.FirstOrDefault(), d); Assert.AreEqual(SelectionType.None, actual); var s = modelPropertyMetadata.First(p => p.PropertyName == "SingleSelectGrid"); actual = GridHelper.GetSelectionType(modelMetadatas.FirstOrDefault(), s); Assert.AreEqual(SelectionType.Single, actual); var m = modelPropertyMetadata.First(p => p.PropertyName == "MultipleSelectGrid"); actual = GridHelper.GetSelectionType(modelMetadatas.FirstOrDefault(), m); Assert.AreEqual(SelectionType.Multiple, actual); }