public void CanAddAndTakeEvent()
        {
            Event evnt = new EventBuilder().Build();

            EventBuffer buffer = new EventBufferBuilder().Build();
            buffer.Add(evnt);

            IEnumerable<Event> events = buffer.Take(1);

            Assert.AreEqual(1, events.Count());
            Assert.AreSame(evnt, events.First());
        }
        public void ShouldRaiseEventEachTimeATempFileIsSavedToCurrentDirectory()
        {
            int eventCount = 0;

            InMemoryFileSystem fileSystem = new InMemoryFileSystem();
            EventBuffer buffer = new EventBufferBuilder().Build();
            EventBuilder eventBuilder = new EventBuilder();

            FakeTimer timer = new FakeTimer();
            FeedWriter feedWriter = new FeedWriter(timer, buffer, fileSystem, new FeedBuilder(SampleLinks.Instance));
            feedWriter.FeedMappingsChanged += ((o, args) => eventCount++);

            //Current will contain 1 - 1st version of 1 will be saved to current
            Repeat.Times(1).Action(() => buffer.Add(eventBuilder.Build()));

            timer.Fire();

            //Current will contain full feed - 2nd version of 1 will be saved to current
            Repeat.Times(RecentEventsFeed.Quota - 1).Action(() => buffer.Add(eventBuilder.Build()));

            timer.Fire();

            //Feed will be archived 3 times - 1st version of 4 will be saved to current
            Repeat.Times((RecentEventsFeed.Quota * 3) - 1).Action(() => buffer.Add(eventBuilder.Build()));

            timer.Fire();

            Assert.AreEqual(3, eventCount);

            Assert.AreEqual(3, fileSystem.FileCount(fileSystem.CurrentDirectory));
            Assert.AreEqual(3, fileSystem.FileCount(fileSystem.ArchiveDirectory));

            Assert.IsTrue(fileSystem.FileExists(fileSystem.ArchiveDirectory, new FileName("1")));
            Assert.IsTrue(fileSystem.FileExists(fileSystem.ArchiveDirectory, new FileName("2")));
            Assert.IsTrue(fileSystem.FileExists(fileSystem.ArchiveDirectory, new FileName("3")));
        }