Exemplo n.º 1
0
        public void Can_load_from_type()
        {
            var model = (ImmutableModel) _store.LoadModel(typeof (ImmutableModel));
            var engine = new Engine<ImmutableModel>(model, _store, _config);
            engine.Execute(new AppendNumberCommand(53));
            engine.Execute(new AppendNumberCommand(42));
            engine.Close();
            _store = new InMemoryStore(_config);
            _store.Init();
            model = (ImmutableModel) _store.LoadModel(typeof (ImmutableModel));

            //make sure state is valid after restore
            Assert.AreEqual(53 + 42, model.Numbers().Sum());

            var ids = _store.GetJournalEntries().Select(je => (int) je.Id).ToArray();
            Assert.AreEqual(Enumerable.Range(1,2),ids);
        }