public void TestBasicEnumeration()
        {
            CacheLoggingService       service = GetLogsService();
            Tuple <Foobar, BarredFoo> objects = CreateObjects();

            service.LogMessage("Logging object 1", objects.Item1, LogLevel.Debug, "Foobar log");
            service.LogMessage("Logging object 2", objects.Item2, LogLevel.Debug, "BarredFoo log");
            ILogEnumerable <Foobar> collection = service.GetLogs <Foobar>();

            Assert.NotEmpty(collection);
            foreach (Log <Foobar> log in collection)
            {
                Assert.NotNull(log);
            }
            int collectionCount = collection.Count();

            Assert.Equal(1, collectionCount);

            ILogEnumerable <BarredFoo> collection2 = service.GetLogs <BarredFoo>();

            Assert.NotEmpty(collection);
            foreach (Log <BarredFoo> log in collection2)
            {
                Assert.NotNull(log);
            }
            int collectionCount2 = collection2.Count();

            Assert.Equal(1, collectionCount2);
        }
        public void TestNonGenricEnumerator()
        {
            CacheLoggingService       service = GetLogsService();
            Tuple <Foobar, BarredFoo> objects = CreateObjects();

            service.LogMessage("Logging object 1", objects.Item1, LogLevel.Debug, "Foobar log");
            service.LogMessage("Logging object 2", objects.Item2, LogLevel.Debug, "BarredFoo log");
            ILogEnumerable <Foobar> collection = service.GetLogs <Foobar>();

            Log <Foobar>[] logs  = collection.ToArray();
            int            index = 0;

            foreach (Log <Foobar> log in ((IEnumerable)collection))
            {
                Assert.Equal(log, logs[index]);
                index++;
            }
            int collectionCount = collection.Count();

            Assert.Equal(1, collectionCount);

            index = 0;
            foreach (Log <Foobar> log in ((IEnumerable)collection))
            {
                Assert.Equal(log, logs[index]);
                index++;
            }
        }
        public void TestBasicEnumeration()
        {
            CacheLoggingService       service = TestMemoryCacheProvider.GetLogsService();
            Tuple <Foobar, BarredFoo> objects = CreateObjects();

            service.LogMessage("Logging object 1", objects.Item1, LogLevel.Debug, "Foobar log");
            service.LogMessage("Logging object 2", objects.Item2, LogLevel.Debug, "BarredFoo log");
            ILogBaseEnumerable collection = service.GetLogs();

            Assert.NotEmpty(collection);
            foreach (LogBase log in collection)
            {
                Assert.NotNull(log);
            }
            int collectionCount = collection.Count();

            Assert.Equal(2, collectionCount);
        }
        public void GetLogsTest()
        {
            MemoryCachingService cachingService = new MemoryCachingService(TimeSpan.FromMinutes(5));
            Json serializationService           = new Json();
            CacheLoggingService loggingService  = new CacheLoggingService(cachingService, serializationService, _partSeperator);

            const string title    = "Test Log";
            const string message  = "A test log";
            Foobar       original = new Foobar
            {
                Foo = 4,
                Bar = 6
            };

            InvalidOperationException exception;

            try
            {
                throw new InvalidOperationException(title);
            }
            catch (InvalidOperationException ex)
            {
                exception = ex;
            }

            string       description = "Manual Exception Log - " + message;
            Log <Foobar> originalLog = new Log <Foobar>
            {
                Target      = original,
                TimeStamp   = DateTime.UtcNow,
                Title       = title,
                Message     = message,
                LogLevel    = LogLevel.Info,
                Exception   = new SerializableException(exception),
                Description = description
            };

            loggingService.Log(originalLog);

            ILogEnumerable <Foobar> logs = loggingService.GetLogs <Foobar>();

            Assert.NotNull(logs);
            Assert.NotEmpty(logs);
            Assert.Single(logs);

            Log <Foobar> log = logs.Single();

            Assert.NotNull(log);
            Assert.True(log.TimeStamp >= log.TimeStamp.AddMilliseconds(-.5) && log.TimeStamp <= log.TimeStamp.AddMilliseconds(.5));
            Assert.Equal(originalLog.Title, log.Title);
            Assert.Equal(originalLog.Message, log.Message);
            Assert.Equal(originalLog.LogLevel, log.LogLevel);
            Assert.Equal(originalLog.Description, log.Description);

            Assert.NotNull(log.Target);

            Assert.NotNull(log.Exception);
            Assert.Equal(typeof(SerializableException), log.Exception.GetType());
            Assert.Equal(title, log.Exception.Message);
            Assert.Equal(originalLog.Exception.Message, log.Exception.Message);

            Assert.Equal(log, logs.First());
        }