public void GivenVisitorEventsExistInStream_WhenRebuildingDenormalizedView_ThenVisitorProjectionsSholdExistInStorage()
		{
			// Arrange
			using (var store = new EmbeddableDocumentStore { RunInMemory = true })
			{
				store.Initialize();

				// const int nrOfVisitors = 1000;
				const int nrOfVisitors = 10;

				var eventStorage = new Mock<IEventStorage>();
				eventStorage
					.Setup(e => e.GetAll())
					.Returns(() => GetFakeHistory(nrOfVisitors));

				var visitorDenormalizer = new VisitorDenormalizer(store);
				var handlerInvoker = new HandlerInvoker(new object[] { visitorDenormalizer });

				var projectionsRebuilder = new ProjectionsRebuilder(eventStorage.Object, handlerInvoker);

				// Act
				var timer = new Stopwatch();
				timer.Start();
				projectionsRebuilder.Rebuild();
				timer.Stop();

				// Assert
				int visitorCount;
				using (var session = store.OpenSession())
				{
					visitorCount = session
									.Query<Visitor>()
									.Customize(q => q.WaitForNonStaleResultsAsOfLastWrite())
									.Count();
				}

				Console.WriteLine("Denormalized view was rebuilt, nr of visitors: '" + visitorCount + "', time: " + timer.Elapsed);
				Assert.AreEqual(nrOfVisitors, visitorCount);
			}
		}
		public ProjectionsRebuilder(IEventStorage eventStore, HandlerInvoker handlerInvoker)
		{
			_eventStore = eventStore;
			_handlerInvoker = handlerInvoker;
		}