public void CanSetDocumentTypeDefaultValueForBooleanProperty() { var documentType = new Models.DocumentType(); var propertyName = GetPropertyName(() => documentType.BooleanProperty); CanSetDefaultValueForDocumentType <bool>(documentType, propertyName); }
public void CanSetDocumentTypeDefaultValueForDateTimeProperty() { var documentType = new Models.DocumentType(); var propertyName = GetPropertyName(() => documentType.DateTimeProperty); CanSetDefaultValueForDocumentType <DateTime>(documentType, propertyName); }
public void CanSetDocumentTypeDefaultValueForFloatingDecimalPointProperty() { var documentType = new Models.DocumentType(); var propertyName = GetPropertyName(() => documentType.FloatingDecimalPointProperty); CanSetDefaultValueForDocumentType <decimal>(documentType, propertyName); }
public void CanSetDocumentTypeDefaultValueForIntegerProperty() { var documentType = new Models.DocumentType(); var propertyName = GetPropertyName(() => documentType.IntegerProperty); CanSetDefaultValueForDocumentType <int>(documentType, propertyName); }
public void CanSetDocumentTypeDefaultValueForStringProperty() { var documentType = new Models.DocumentType(); var propertyName = GetPropertyName(() => documentType.StringProperty); CanSetDefaultValueForDocumentType <string>(documentType, propertyName); }
public bool AddUpdateDocType(Models.DocumentType docType) { IScope scope = null; try { var dbDocType = _mapper.Map <UGraphSchema>(docType); dbDocType.LastUpdate = DateTime.Now; scope = _scopeProvider.CreateScope(); var hasDocType = GetDocType(scope, docType.Id) != null; if (hasDocType) { scope.Database.Update(dbDocType); } else { scope.Database.Insert <UGraphSchema>(dbDocType); } return(true); } catch (Exception ex) { return(false); } finally { scope?.Complete(); scope?.Dispose(); } }
public void CanGetFloatingBinaryPointProperty() { var document = new Models.DocumentType(); var documentType = new DocumentType(document.GetType()); var property = documentType.Properties.First(p => p.Name == GetPropertyName(() => document.FloatingBinaryPointProperty)); Assert.AreSame(typeof(float), property.Type); }
public void CanGetBooleanProperty() { var document = new Models.DocumentType(); var documentType = new DocumentType(document.GetType()); var property = documentType.Properties.First(p => p.Name == GetPropertyName(() => document.BooleanProperty)); Assert.AreSame(typeof(bool), property.Type); }
public void CannotGetPrivateProperty() { var document = new Models.DocumentType(); var documentType = new DocumentType(document.GetType()); var property = documentType.Properties.FirstOrDefault(p => p.Name == "PrivateStringProperty"); Assert.IsNull(property); }
public void CannotGetPropertyWithoutSetter() { var document = new Models.DocumentType(); var documentType = new DocumentType(document.GetType()); var property = documentType.Properties.FirstOrDefault(p => p.Name == GetPropertyName(() => document.StringPropertyWithoutSetter)); Assert.IsNull(property); }
public void CannotGetNonScaffoldedProperty() { var document = new Models.DocumentType(); var documentType = new DocumentType(document.GetType()); var property = documentType.Properties.FirstOrDefault(p => p.Name == GetPropertyName(() => document.NonScaffoldedStringProperty)); Assert.IsNull(property); }
public ActionResult CreateDocumentType(Models.DocumentType documentType) { if (ModelState.IsValid) { _typesHandler.Add(ConvertToBlModel(documentType)); return(RedirectToAction("DocumentTypes")); } return(View(documentType)); }
private static void CanSetDefaultValueForDocumentType <TPropertyType>(Models.DocumentType documentType, string propertyName) { var contentTypeMock = new Mock <IContentType>(); contentTypeMock.Setup(m => m.Alias).Returns(documentType.GetType().Name.Alias()); var contentMock = new Mock <IContent>(); contentMock.Setup(m => m.ContentType).Returns(contentTypeMock.Object); new DefaultValueService(GetTypeResolverMock(documentType.GetType()).Object, new Mock <ITypeRepository>().Object).SetDefaultValues(contentMock.Object); contentMock.Verify(m => m.SetValue(propertyName.Alias(), GetPropertyDefaultValue <TPropertyType>(documentType.GetType(), propertyName))); }
public Models.DocumentType GetDocType(int id) { Models.DocumentType docType = null; IScope scope = null; try { scope = _scopeProvider.CreateScope(); return(GetDocType(scope, id)); } catch { docType = null; } finally { scope?.Complete(); scope?.Dispose(); } return(docType); }
private void SaveGraphQLClassFile(Models.DocumentType docType) { }
public ActionResult EditDocumentType(Models.DocumentType documentType) { _typesHandler.Update(ConvertToBlModel(documentType)); return(RedirectToAction("DocumentTypes")); }
private static DocumentType ConvertToBlModel(Models.DocumentType type) { Mapper.CreateMap <Models.DocumentType, DocumentType>(); return(Mapper.Map <Models.DocumentType, DocumentType>(type)); }