public void create_projections()
        {
            var projection = new SimpleEventStore.Query.AnagraficaArticolo();
            // Arrange
            var dispatcher = new Action<object>((evt) =>
            {
                var dispatchedEvent = evt as AnagraficaArticoloCensita;
                if(evt!=null)
                {
                    projection.Code = dispatchedEvent.Code;
                    projection.Description = dispatchedEvent.Description;
                }
            });

            var repository = new Repository(eventsDispatcher: dispatcher);

            var code = "001";
            var description = "SSD Crucial M4 256GB";
            var item = new AnagraficaArticolo();
            item.Censisci(TestConfig.Id, code, description, "NR", 100);

            // Act
            repository.Save(item);

            // Assert
            Assert.AreEqual(code, projection.Code);
            Assert.AreEqual(description, projection.Description);
        }
        public void censisci_AnagraficaArticolo()
        {
            var item = new AnagraficaArticolo();
            item.Censisci(TestConfig.Id, "001", "SSD Crucial M4 256GB", "NR", 50);

            Assert.AreEqual(1, item.Events.Count);
        }
        public void save_item_to_eventStream()
        {
            var item = new AnagraficaArticolo();
            item.Censisci(TestConfig.Id, "001", "SSD Crucial M4 256GB", "NR", 100);
            var stream = new EventStream();
            item.Save(stream);

            Assert.AreEqual(1, item.Version);
            Assert.AreEqual(1, stream.Events.Count);
        }
        public void save_to_repository()
        {
            // Arrange
            object dispatchedEvent = null;
            var dispatcher = new Action<object>((evt) =>
                {
                    dispatchedEvent = evt;
                });

            var repository = new Repository(eventsDispatcher: dispatcher);

            string fname = repository.MakeAggregateStreamFileName(TestConfig.Id);
            if (File.Exists(fname))
                File.Delete(fname);

            var item = new AnagraficaArticolo();
            item.Censisci(TestConfig.Id, "001", "SSD Crucial M4 256GB", "NR", 100);

            // Act
            repository.Save(item);

            // Assert
            Assert.IsTrue(File.Exists(fname));
            Assert.IsNotNull(dispatchedEvent);
            Assert.IsTrue(dispatchedEvent is AnagraficaArticoloCensita);
        }