public void Initialize() { Destination = new ExampleModelAllTypes(); Context = new UmbracoWebContext(); var fixture = new Fixture().Customize(new AutoMoqCustomization()); Source = fixture.Freeze <ExampleModelAllTypes>(); Source.IntArray = new [] { 1, 2, 3 }; Source.StringArray = new[] { "100", "200", "300" }; Source.Object = new { Name = "TestObject" }; Source.ExampleEnum = ExampleEnum.Harry; Source.TypeHandledString = " this string needs to be trimmed "; var specialCases = new NameValueCollection { { "IntArray", "1,2,3" }, { "StringArray", "100,200,300" }, { "ExampleEnum", "Harry" } }; Context.FillClassProperties(Destination, (alias, recursive) => { var property = typeof(ExampleModelAllTypes).GetProperties() .FirstOrDefault(p => string.Equals(p.Name, alias, StringComparison.InvariantCultureIgnoreCase)); if (property != null) { var hasSpecialValue = specialCases.AllKeys.Contains(property.Name); var value = hasSpecialValue // ReSharper disable once AssignNullToNotNullAttribute ? specialCases.GetValues(property.Name).First() : property.GetValue(Source).ToString(); return(value); } return(null); }); }
public void GetUmbracoEntityAliasesFromType_ShouldBeDistinct() { var aliases = UmbracoWebContext.GetUmbracoEntityAliasesFromType(typeof(ExampleRecursiveAttributesViewModel)).OrderBy(x => x); Assert.IsTrue(aliases.SequenceEqual(aliases.Distinct())); }