Exemple #1
0
 public void Template_For_Complex_Type_Is_Applied()
 {
     var ufo = new Ufo()
     {
         Name = "Conqueror III",
         Speed = 10,
         Origin = new Planet()
         {
             Name = "Alpha Centauri 3",
             DaysPerYear = 452
         }
     };
     var dumper = new ObjectDumper<Ufo>();
     dumper.AddTemplateFor(u => u.Origin, o => string.Format("Planet: {0}", o.Name));
     var desc = dumper.Dump(ufo);
     Assert.IsTrue(desc.Any(kvp =>
         kvp.Key == "Origin" && kvp.Value == string.Format("Planet: {0}", ufo.Origin.Name)));
 }
Exemple #2
0
        public void Template_For_Complex_Type_Is_Applied()
        {
            var ufo = new Ufo()
            {
                Name   = "Conqueror III",
                Speed  = 10,
                Origin = new Planet()
                {
                    Name        = "Alpha Centauri 3",
                    DaysPerYear = 452
                }
            };
            var dumper = new ObjectDumper <Ufo>();

            dumper.AddTemplateFor(u => u.Origin, o => string.Format("Planet: {0}", o.Name));
            var desc = dumper.Dump(ufo);

            Assert.IsNotNull(desc.SingleOrDefault(kvp =>
                                                  kvp.Key == "Origin" && kvp.Value == string.Format("Planet: {0}", ufo.Origin.Name)));
        }