public void TimeBasedExport_5Exported_Ok()
        {
            // Create kangaroostore instance
            KangarooStore <Exception> kangaroo = new KangarooStore <Exception>(new KangarooSettings(TimeSpan.FromSeconds(1)));

            // Create kangaroo export handler
            KangarooExporter <Exception, string> exporter = KangarooExporterExceptionString.Object;

            // Add exporter to kangaroo store
            kangaroo.AddExporter(exporter);

            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine($">> Add {i + 1}. exception!");
                kangaroo.AddData(new ArgumentException($"This is an exception message! {i}"));
            }

            Task.Delay(1100).Wait();

            Console.WriteLine(">> END DEMO");

            kangaroo.StopTimebasedExport();

            KangrooExportWorker.Verify(x => x.Export(It.IsAny <string[]>()), Times.Once());
        }
Esempio n. 2
0
        public void KangarooStoreTestMethodStopTimebasedExport()
        {
            KangarooStore <Exception>            kangaroo = new KangarooStore <Exception>();
            KangarooExporter <Exception, string> exporter = new KangarooExceptionExporter();

            exporter.Converter = new KangarooConvertExcpetionToString();
            exporter.Filter    = (x) =>
            {
                return(x is NullReferenceException);
            };
            exporter.Worker = new KangarooExportWorkerStringToConsole();
            kangaroo.AddExporter(exporter);
            kangaroo.AddExporter(exporter, MyEnum.Debug);

            // Log the exception without specifying a category
            kangaroo.AddData(new Exception());
            // Log the exception with a specific category
            kangaroo.AddData(new Exception(), MyEnum.Debug);

            kangaroo.StopTimebasedExport();
        }
Esempio n. 3
0
        public static void StartTimebasedExport()
        {
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine(">>>> Kangaroo Demo: Automatic export afte 1 sec");
            Console.ResetColor();

            // Create kangaroostore instance
            KangarooStore <Exception> kangaroo = new KangarooStore <Exception>(new KangarooSettings(TimeSpan.FromSeconds(1)));

            // Create kangaroo export handler
            KangarooExporter <Exception, string> exporter = new KangarooExceptionExporter();

            // Add converter
            exporter.Converter = new KangarooConvertExcpetionToString();

            // Add filter
            exporter.Filter = (x) =>
            {
                return(x is ArgumentException);
            };

            // Add exporter
            exporter.Worker = new KangarooExportWorkerStringToConsole();

            // Add exporter to kangaroo store
            kangaroo.AddExporter(exporter);

            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine($">> Add {i + 1}. exception!");
                kangaroo.AddData(new ArgumentException($"This is an exception message! {i}"));
            }

            Task.Delay(1100).Wait();

            Console.WriteLine(">> END DEMO");

            kangaroo.StopTimebasedExport();
        }