Ejemplo n.º 1
0
        public void SetUp()
        {
            _builder = new Builder(1)
                       .SetCollectionSize <ResourceClassSimple>(20, 20)
                       .SetMaximumDepth(5)
                       .For <ResourceClassComplex>().Set(c => c.StringConversionProperty, "10");

            _resourceObj = _builder.Build <ResourceClassComplex>();
        }
Ejemplo n.º 2
0
        private static void AssertAreEqual(ResourceClassComplex resource, DomainClassComplex domain)
        {
            AssertAreEqual(resource.ExampleProperty, domain.ExampleProperty);

            if (resource.ExamplePropertyArray != null)
            {
                Assert.AreEqual(resource.ExamplePropertyArray.Count, domain.ExamplePropertyArray.Length);
                int index = 0;
                foreach (var simple in resource.ExamplePropertyArray)
                {
                    AssertAreEqual(simple, domain.ExamplePropertyArray[index++]);
                }
            }
            else
            {
                Assert.IsNull(domain.ExamplePropertyArray);
            }

            if (resource.ExamplePropertyList != null)
            {
                Assert.AreEqual(resource.ExamplePropertyList.Length, domain.ExamplePropertyList.Count);
                var index = 0;
                foreach (var simple in resource.ExamplePropertyList)
                {
                    AssertAreEqual(simple, domain.ExamplePropertyList[index++]);
                }
            }
            else
            {
                Assert.IsNull(domain.ExamplePropertyList);
            }

            if (resource.RecursiveExampleProperty != null)
            {
                Assert.IsNotNull(domain.RecursiveExampleProperty);
                AssertAreEqual(resource.RecursiveExampleProperty, domain.RecursiveExampleProperty);
            }
            else
            {
                Assert.IsNull(domain.RecursiveExampleProperty);
            }
        }
Ejemplo n.º 3
0
 private static void Map(ResourceClassComplex from, DomainClassComplex to)
 {
     to.ExampleProperty = from.ExampleProperty == null ? null : new DomainClassSimple()
     {
         ExampleProperty = from.ExampleProperty.ExampleProperty
     };
     to.IntConversionProperty    = from.IntConversionProperty.ToString();
     to.StringConversionProperty = int.Parse(from.StringConversionProperty);
     to.ExamplePropertyList      = from.ExamplePropertyList == null ? null : from.ExamplePropertyList.Select(p => p == null ? null : new DomainClassSimple()
     {
         ExampleProperty = p.ExampleProperty
     }).ToList();
     to.ExamplePropertyArray = from.ExamplePropertyArray == null ? null : from.ExamplePropertyArray.Select(p => p == null ? null : new DomainClassSimple()
     {
         ExampleProperty = p.ExampleProperty
     }).ToArray();
     if (from.RecursiveExampleProperty != null)
     {
         to.RecursiveExampleProperty = new DomainClassComplex();
         Map(from.RecursiveExampleProperty, to.RecursiveExampleProperty);
     }
 }