Example #1
0
        public void Dump_Is_Sorted_By_Property_Name()
        {
            var dumper = new ObjectDumper<Test3Class>();
            var desc = dumper.Dump(new Test3Class()).Select(kvp => kvp.Key);

            CollectionAssert.AreEqual(desc.ToList(), new List<string>() { "AProperty", "BProperty", "ZProperty" });
        }
Example #2
0
        public void Run()
        {
            var logEntries = GetEntries()
                .OrderBy(e => e.TimeGenerated) // want the most recent at the bottom;
                .ToList();

            if (logEntries.Count == 0)
            {
                Log("No entries found");
            }
            else
            {
                var dumper = new ObjectDumper<EventLogEntry>(GetDump);
                Log(dumper.Dump(logEntries));
            }
        }
Example #3
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)));
 }
Example #4
0
        public void Not_Listed_Property_Is_Not_Invoked()
        {
            var dumper = new ObjectDumper<CrashedUfo>();
            var crashed = new CrashedUfo()
            {
                Name = "Conqueror III",
                Speed = 10,
                Origin = new Planet()
                {
                    Name = "Alpha Centauri 3",
                    DaysPerYear = 452
                }
            };

            var desc = dumper.Dump(crashed);
            var twoPropertiesList = desc.Take(2).ToList();
            // No exception at this point because ZLastProperty is *never* invoked
            Assert.AreEqual(2, twoPropertiesList.Count);
        }
Example #5
0
 public static void Write(object o, int depth)
 {
     ObjectDumper dumper = new ObjectDumper(depth);
       dumper.WriteObject(null, o);
 }
Example #6
0
 void IDumpabled.Dump(string name, ObjectDumper dumper)
 {
     dumper.DumpText(name, ToString());
 }
Example #7
0
 public static void Write( object element, int depth, TextWriter log )
 {
     ObjectDumper dumper = new ObjectDumper(depth);
     dumper.writer = log;
     dumper.WriteObject(null, element);
 }
Example #8
0
        public void Template_For_Simple_Type_Is_Applied()
        {
            const string IS_42 = "Answer to everything";
            const string IS_NOT_42 = "not meaningful";

            var dumper = new ObjectDumper<Test2Class.Test2Inner>();
            dumper.AddTemplateFor(o => o.Value, v => v == 42 ? IS_42 : IS_NOT_42);

            var data = new Test2Class.Test2Inner()
            {
                Name = "Some name",
                Value = 42
            };

            var desc = dumper.Dump(data);
            Assert.IsTrue(desc.Any(kvp => kvp.Key == "Value" && kvp.Value == IS_42));
        }
Example #9
0
 public void Only_Properties_With_Getter_Are_Dump()
 {
     var dumper = new ObjectDumper<Test1Class>();
     var desc = dumper.Dump(new Test1Class());
     Assert.AreEqual(1, desc.Count());
 }
Example #10
0
 public void Dumping_Null_Returns_Empty_Collection()
 {
     var dumper = new ObjectDumper<Test1Class>();
     var result = dumper.Dump(null);
     Assert.IsFalse(result.Any());
 }
Example #11
0
 public void Default_Template_Is_To_String()
 {
     var dumper = new ObjectDumper<Test2Class>();
     var desc = dumper.Dump(new Test2Class());
     Assert.AreEqual(new Test2Class.Test2Inner().ToString(), desc.First().Value);
 }
Example #12
0
        static void Main(string[] args)
        {
            string referencedAssemblyPath = args[0];

            string[] files = Directory.GetFiles(referencedAssemblyPath);

            Log.Info("Found {0} files to enumerate in {1}", files.Length, referencedAssemblyPath);

            var assemblyExtensions = new List<string> { ".exe", ".dll" };
            var assemblies = new List<Assembly>();

            foreach (string file in files)
            {
                var fileInfo = new FileInfo(file);
                if (assemblyExtensions.Contains(fileInfo.Extension))
                {
                    try
                    {
                        assemblies.Add(Assembly.LoadFrom(file));
                    }
                    catch (Exception ex)
                    {
                        Log.InfoException("Failed to load " + fileInfo.Name, ex);
                        continue;
                    }
                }
                else
                {
                    Log.Debug("Ignoring {0}", fileInfo.Name);
                }
            }

            Log.Info("Found {0} assemblies. Proceeding to dump:", assemblies.Count);

            assemblies.Sort((x, y) => x.FullName.CompareTo(y.FullName));

            var objectDumper = new ObjectDumper<Assembly>(GetAssemblyDump);
            Log.Info(objectDumper.Dump(assemblies));

            Log.Info("Finished");
        }
Example #13
0
 public void Dump(object value, string name)
 {
     var dumper = new ObjectDumper("[DUMP]");
     dumper.DumpObject(name, value);
 }
Example #14
0
 public void Dump(object value)
 {
     var dumper = new ObjectDumper("[DUMP]");
     dumper.DumpObject(value);
 }