public void SynchronizeChangesAddedItemTest()
        {
            var sourceGameWorld = new TestGameWorld();

            sourceGameWorld.RandomIntProperty = 5;

            var syncSourceRoot = new SyncSourceRoot(sourceGameWorld, _sourceSettings);

            var syncTargetRoot =
                new SyncTargetRoot <TestGameWorld>(syncSourceRoot.WriteFullAndDispose(), _targetSettings);

            sourceGameWorld.Players.Add("player1", new TestPlayer {
                Health = 100, Level = 30
            });
            sourceGameWorld.Players.Add("player2", new TestPlayer {
                Health = 44, Level = 1337
            });


            syncTargetRoot.Read(syncSourceRoot.WriteChangesAndDispose().SetTick(0));

            TestGameWorld targetGameWorld = syncTargetRoot.Root;

            AssertExtension.AssertCloneEqual(sourceGameWorld, targetGameWorld);
        }
Пример #2
0
        public void WriteChangesShouldCreateNewReferenceTest()
        {
            var sourceGameWorld = new TestGameWorld {
                RandomIntProperty = 5
            };
            var syncSourceRoot = new SyncSourceRoot(sourceGameWorld, _sourceSettings);

            var           syncTargetRoot = new SyncTargetRoot <TestGameWorld>(syncSourceRoot.WriteFullAndDispose(), _targetSettings);
            TestGameWorld previousTargetTestGameWorld = syncTargetRoot.Root;

            syncTargetRoot.Read(syncSourceRoot.WriteChangesAndDispose().SetTick(0));

            Assert.Equal(previousTargetTestGameWorld, syncTargetRoot.Root);
        }
Пример #3
0
        public void RemovingAChangedReferenceShouldAlsoRemoveItFromDirtyListTest()
        {
            var world  = new TestGameWorld();
            var player = new TestPlayer();

            world.Players.Add("player", player);
            var syncSourceRoot = new SyncSourceRoot(world, _sourceSettings);

            var syncTargetRoot = new SyncTargetRoot(syncSourceRoot.WriteFullAndDispose(), _targetSettings);

            player.Health = 3;

            world.Players.Remove("player");

            // Changes are removed after write
            syncSourceRoot.WriteChangesAndDispose().SetTick(0);

            Assert.DoesNotContain(player, syncSourceRoot.DirtyReferences);
        }