Exemplo n.º 1
0
        public void TestNonGenricEnumerator()
        {
            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");
            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++;
            }
        }
Exemplo n.º 2
0
        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");
            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);
        }