public TestAggregateRoot(Guid id, string name, IList<TestEntity> entities, TestEntity mainEntity)
        {
            base.Id = id;
            base.Version = 1;

            this.name = name;
            this.entities = entities;
            this.mainEntity = mainEntity;
        }
        public void CreateComplexAggregate()
        {
            var id = Guid.NewGuid();

            var optimusPrime = new TestEntity("OptimusPrime", 5, new List<TestItem>());
            var bumbleBee = new TestEntity("BumBleBee", null, new List<TestItem>() { new TestItem("sub1", false), new TestItem("sub2", true) });
            var hotRod = new TestEntity("HotRod", 5, new List<TestItem> { new TestItem("hr1", true), new TestItem("hr2", false) });

            var aggregate = new TestAggregateRoot(id, "Transformers", new List<TestEntity> { bumbleBee, hotRod }, optimusPrime);

            //ACT
            var result = sut.Create(aggregate);

            //ASSERT
            Assert.That(result.Version, Is.EqualTo(1));

            var json = JsonConvert.DeserializeObject<IDictionary<string, object>>(result.JsonSerialization);
            Assert.That(json.ContainsKey("ActualNumberOfPlayers"));
            Assert.That(json.ContainsKey("MinimumNumberOfPlayers"));
            Assert.That(json.ContainsKey("MaximumNumberOfPlayers"));
            Assert.That(json.ContainsKey("StartDate"));

            Assert.That(json.ContainsKey("name"));
            Assert.That(json.ContainsKey("entities"));
            Assert.That(json.ContainsKey("mainEntity"));

            Assert.That(json["ActualNumberOfPlayers"], Is.EqualTo(0));
            Assert.That(json["MinimumNumberOfPlayers"], Is.EqualTo(0));
            Assert.That(json["MaximumNumberOfPlayers"], Is.EqualTo(0));

            Assert.That(json["name"], Is.EqualTo("Transformers"));

            Console.WriteLine("Json keys and values");
            foreach (var key in json.Keys)
            {
                Console.WriteLine(key + " : " + json[key]);
            }

            // Contains 4 backingField
            Assert.That(json.Keys.Count, Is.EqualTo(13));
        }
        public void RecreateComplexAggregateFromSnapshot()
        {
            var id = Guid.NewGuid();

            var optimusPrime = new TestEntity("OptimusPrime", 5, new List<TestItem>());
            var bumbleBee = new TestEntity("BumBleBee", null, new List<TestItem>() {new TestItem("sub1", false), new TestItem("sub2", true)});
            var hotRod = new TestEntity("HotRod", 5, new List<TestItem> {new TestItem("hr1", true), new TestItem("hr2", false)});

            var aggregate = new TestAggregateRoot(id, "Transformers", new List<TestEntity>{bumbleBee, hotRod}, optimusPrime );

            var snapshot = sut.Create(aggregate);

            var rebuiltAggregate = sut.Get<TestAggregateRoot>(snapshot);

            //ACT
            var result = sut.Create(rebuiltAggregate);

            //ASSERT
            Assert.That(result.Version, Is.EqualTo(1));

            Assert.That(rebuiltAggregate.GetName(), Is.EqualTo("Transformers"));
            Assert.That(rebuiltAggregate.GetEntitiesList().Count, Is.EqualTo(2));
        }