示例#1
0
        public void CanSetDocumentTypeDefaultValueForBooleanProperty()
        {
            var documentType = new Models.DocumentType();
            var propertyName = GetPropertyName(() => documentType.BooleanProperty);

            CanSetDefaultValueForDocumentType <bool>(documentType, propertyName);
        }
示例#2
0
        public void CanSetDocumentTypeDefaultValueForDateTimeProperty()
        {
            var documentType = new Models.DocumentType();
            var propertyName = GetPropertyName(() => documentType.DateTimeProperty);

            CanSetDefaultValueForDocumentType <DateTime>(documentType, propertyName);
        }
示例#3
0
        public void CanSetDocumentTypeDefaultValueForFloatingDecimalPointProperty()
        {
            var documentType = new Models.DocumentType();
            var propertyName = GetPropertyName(() => documentType.FloatingDecimalPointProperty);

            CanSetDefaultValueForDocumentType <decimal>(documentType, propertyName);
        }
示例#4
0
        public void CanSetDocumentTypeDefaultValueForIntegerProperty()
        {
            var documentType = new Models.DocumentType();
            var propertyName = GetPropertyName(() => documentType.IntegerProperty);

            CanSetDefaultValueForDocumentType <int>(documentType, propertyName);
        }
示例#5
0
        public void CanSetDocumentTypeDefaultValueForStringProperty()
        {
            var documentType = new Models.DocumentType();
            var propertyName = GetPropertyName(() => documentType.StringProperty);

            CanSetDefaultValueForDocumentType <string>(documentType, propertyName);
        }
示例#6
0
        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();
            }
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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));
 }
示例#13
0
        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)));
        }
示例#14
0
        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);
        }
示例#15
0
 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));
        }