Ejemplo n.º 1
0
 public void SetUp()
 {
     Snapshot = new TestSnapshot { EventSourceId = Guid.NewGuid(), EventSourceVersion = 1, Name = "TestName"};
     _foldername = Snapshot.EventSourceId.ToString().Substring(0, 2);
     _filename = Snapshot.EventSourceId.ToString().Substring(2) + ".ss";
     SnapshotStore.SaveShapshot(Snapshot);
 }
        public static NeoSystem InitializeMockNeoSystem()
        {
            if (TheNeoSystem == null)
            {
                var mockSnapshot = new TestSnapshot();

                _Store = new Mock <Store>();

                _Store.Setup(p => p.GetBlocks()).Returns(mockSnapshot.Blocks);
                _Store.Setup(p => p.GetTransactions()).Returns(mockSnapshot.Transactions);
                _Store.Setup(p => p.GetContracts()).Returns(mockSnapshot.Contracts);
                _Store.Setup(p => p.GetStorages()).Returns(mockSnapshot.Storages);
                _Store.Setup(p => p.GetHeaderHashList()).Returns(mockSnapshot.HeaderHashList);
                _Store.Setup(p => p.GetBlockHashIndex()).Returns(mockSnapshot.BlockHashIndex);
                _Store.Setup(p => p.GetHeaderHashIndex()).Returns(mockSnapshot.HeaderHashIndex);
                _Store.Setup(p => p.GetSnapshot()).Returns(mockSnapshot.Clone());

                TheNeoSystem = new NeoSystem(_Store.Object);

                // Ensure that blockchain is loaded

                var blockchain = Blockchain.Singleton;
            }

            return(TheNeoSystem);
        }
Ejemplo n.º 3
0
        public void Should_set_aggregate_version_on_load()
        {
            //Arrange
            var sut      = new TestSnapshotAggregateRoot(Guid.NewGuid());
            var snapshot = new TestSnapshot {
                Prop = "EEE"
            };
            var snapshotVersion = 5;

            //Act
            ((ISnapshotableEntity)sut).ApplySnapshot(snapshot, snapshotVersion);

            //Assert
            sut.Version.Should().Be(snapshotVersion);
        }
Ejemplo n.º 4
0
        public void Should_support_serialization()
        {
            //Arrange
            var sut      = new TestSnapshotAggregateRoot(Guid.NewGuid());
            var snapshot = new TestSnapshot();

            ((ISnapshotableEntity)sut).ApplySnapshot(snapshot, 5);

            //Act
            var serializedObject   = JsonConvert.SerializeObject(sut);
            var deserializedObject = JsonConvert.DeserializeObject <TestSnapshotAggregateRoot>(serializedObject);

            //Assert
            deserializedObject.Should().Be(sut);
        }