Example #1
0
        public void ShouldWriteMapForMapMapping()
        {
            var mapping = CollectionMapping.Map();

            writer.VerifyXml(mapping)
            .RootElement.HasName("map");
        }
Example #2
0
 // I'm not proud of this. The fluent interface for maps really needs to be rethought. But I've let maps sit unsupported for way too long
 // so a hack is better than nothing.
 /// <summary>
 /// Use a map collection
 /// </summary>
 /// <typeparam name="TIndex">Index type</typeparam>
 /// <param name="customIndexMapping">Index mapping</param>
 /// <param name="customElementMapping">Element mapping</param>
 public T AsMap <TIndex>(Action <IndexPart> customIndexMapping, Action <ElementPart> customElementMapping)
 {
     collectionBuilder = attrs => CollectionMapping.Map(attrs);
     AsIndexedCollection <TIndex>(string.Empty, customIndexMapping);
     Element(string.Empty);
     customElementMapping(elementPart);
     return((T)this);
 }
        public void ShouldNotWriteCollectionTypeWhenEmpty()
        {
            var mapping = CollectionMapping.Map();

            mapping.Set(x => x.CollectionType, Layer.Defaults, TypeReference.Empty);
            writer.VerifyXml(mapping)
            .DoesntHaveAttribute("collection-type");
        }
Example #4
0
        public void ShouldWriteMap()
        {
            var mapping = new SubclassMapping(SubclassType.JoinedSubclass);

            mapping.AddCollection(CollectionMapping.Map());

            writer.VerifyXml(mapping)
            .Element("map").Exists();
        }
        public void ShouldWriteMaps()
        {
            var mapping = new ComponentMapping(ComponentType.DynamicComponent);

            mapping.AddCollection(CollectionMapping.Map());

            writer.VerifyXml(mapping)
            .Element("map").Exists();
        }
        public void ShouldWriteMaps()
        {
            var mapping = CreateInstance();

            mapping.AddCollection(CollectionMapping.Map());

            writer.VerifyXml(mapping)
            .Element("map").Exists();
        }
        public void ShouldWriteElement()
        {
            var mapping = CollectionMapping.Map();

            mapping.Set(x => x.Element, Layer.Defaults, new ElementMapping());

            writer.VerifyXml(mapping)
            .Element("element").Exists();
        }
        public void ShouldWriteCacheElement()
        {
            var mapping = CollectionMapping.Map();

            mapping.Set(x => x.Cache, Layer.Defaults, new CacheMapping());

            writer.VerifyXml(mapping)
            .Element("cache").Exists();
        }
        public void ShouldWriteIndexElement()
        {
            var mapping = CollectionMapping.Map();

            mapping.Set(x => x.Index, Layer.Defaults, new IndexMapping());

            writer.VerifyXml(mapping)
            .Element("index").Exists();
        }
        public void ShouldWriteRelationshipElement()
        {
            var mapping = CollectionMapping.Map();

            mapping.Set(x => x.Relationship, Layer.Defaults, new OneToManyMapping());

            writer.VerifyXml(mapping)
            .Element("one-to-many").Exists();
        }
        public void ShouldWriteKey()
        {
            var mapping = CollectionMapping.Map();

            mapping.Set(x => x.Key, Layer.Defaults, new KeyMapping());

            writer.VerifyXml(mapping)
            .Element("key").Exists();
        }
Example #12
0
 /// <summary>
 /// Use a map collection
 /// </summary>
 /// <typeparam name="TIndex">Index type</typeparam>
 /// <param name="indexSelector">Index property</param>
 /// <param name="customIndexMapping">Index mapping</param>
 /// <param name="sort">Sorting</param>
 public T AsMap <TIndex>(Expression <Func <TChild, TIndex> > indexSelector, Action <IndexPart> customIndexMapping, SortType sort)
 {
     collectionBuilder = attrs =>
     {
         var collection = CollectionMapping.Map(attrs);
         collection.Set(x => x.Sort, Layer.UserSupplied, sort.ToLowerInvariantString());
         return(collection);
     };
     return(AsIndexedCollection(indexSelector, customIndexMapping));
 }
Example #13
0
 /// <summary>
 /// Use a map collection
 /// </summary>
 /// <typeparam name="TIndex">Index type</typeparam>
 /// <typeparam name="TComparer">Comparer</typeparam>
 /// <param name="indexColumnName">Index column name</param>
 public T AsMap <TIndex, TComparer>(string indexColumnName) where TComparer : IComparer <TChild>
 {
     collectionBuilder = attrs =>
     {
         var collection = CollectionMapping.Map(attrs);
         collection.Set(x => x.Sort, Layer.UserSupplied, typeof(TComparer).AssemblyQualifiedName);
         return(collection);
     };
     AsIndexedCollection <TIndex>(indexColumnName, null);
     return((T)this);
 }
Example #14
0
 /// <summary>
 /// Use a map collection
 /// </summary>
 /// <typeparam name="TIndex">Index type</typeparam>
 /// <param name="indexColumnName">Index column name</param>
 /// <param name="sort">Sorting</param>
 public T AsMap <TIndex>(string indexColumnName, SortType sort)
 {
     collectionBuilder = attrs =>
     {
         var collection = CollectionMapping.Map(attrs);
         collection.Set(x => x.Sort, Layer.UserSupplied, sort.ToLowerInvariantString());
         return(collection);
     };
     AsIndexedCollection <TIndex>(indexColumnName, null);
     return((T)this);
 }
Example #15
0
 /// <summary>
 /// Use a map collection
 /// </summary>
 /// <typeparam name="TIndex">Index type</typeparam>
 /// <param name="indexSelector">Index property</param>
 /// <param name="customIndexMapping">Index mapping</param>
 public T AsMap <TIndex>(Expression <Func <TChild, TIndex> > indexSelector, Action <IndexPart> customIndexMapping)
 {
     collectionBuilder = attrs => CollectionMapping.Map(attrs);
     return(AsIndexedCollection(indexSelector, customIndexMapping));
 }
Example #16
0
 /// <summary>
 /// Use a map collection
 /// </summary>
 /// <typeparam name="TIndex">Index type</typeparam>
 /// <param name="indexColumnName">Index column name</param>
 public T AsMap <TIndex>(string indexColumnName)
 {
     collectionBuilder = attrs => CollectionMapping.Map(attrs);
     AsIndexedCollection <TIndex>(indexColumnName, null);
     return((T)this);
 }