public void It_Should_Perform_Standard_Equality() { var comparer = TypeBySubclassAndAssignableImpl.TypeBySubclassAndAssignable(); Assert.Equal(0, comparer.Compare(null, null)); Assert.Equal(1, comparer.Compare(null, typeof(string))); Assert.Equal(-1, comparer.Compare(typeof(string), null)); }
public void Types_Should_Come_Before_AssignableTypes_Regardless_Of_Order() { var list = new List <Type> { typeof(List <string>), typeof(IEnumerable) }; var orderedList = list.OrderBy(x => x, TypeBySubclassAndAssignableImpl.TypeBySubclassAndAssignable()).ToList(); var enumerableIndex = orderedList.IndexOf(typeof(IEnumerable)); var listIndex = orderedList.IndexOf(typeof(List <string>)); Assert.True(listIndex < enumerableIndex); }
public void It_Should_Put_Subclasses_Before_Parent_Regardless_Of_Starting_Position() { var list = new List <Type> { typeof(B), typeof(A) }; var orderedList = list.OrderBy(x => x, TypeBySubclassAndAssignableImpl.TypeBySubclassAndAssignable()).ToList(); var rawTokenIndex = orderedList.IndexOf(typeof(B)); var parserOutputIndex = orderedList.IndexOf(typeof(A)); Assert.True(rawTokenIndex < parserOutputIndex); }
/// <summary> /// Builds a RegistrySettings class with all the provided details /// </summary> /// <returns>The registry settings</returns> public override RendererSettings BuildSettings() { var mergedGetters = RendererSettingsDefaults.DefaultValueGetters().MergeLeft(ValueGetters); mergedGetters = mergedGetters .OrderBy(x => x.Key, TypeBySubclassAndAssignableImpl.TypeBySubclassAndAssignable()) .ToDictionary(item => item.Key, item => item.Value); return(new RendererSettings( mergedGetters, TruthyChecks, TemplateLoader, PartialTemplateLoader, MaxRecursionDepth.HasValue ? (MaxRecursionDepth.Value > 0 ? MaxRecursionDepth.Value : uint.MaxValue) : 256, RenderSettings ?? RenderSettings.GetDefaultRenderSettings(), EnumerationConverters, IgnoreCaseOnKeyLookup, Parser ?? new CachedMustacheParser(), new TokenRendererPipeline <Context>(TokenRenderers), DefaultTags ?? new Tags("{{", "}}"), ParserPipeline ?? new ParserPipelineBuilder().Build())); }