Beispiel #1
0
        public async Task Validate_InvalidPlayerDuringUpdate()
        {
            string _sessionID = "Validate_InvalidPlayerDuringUpdate";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 32, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            // The Orleans silo / client test environment is already set up at this point.
            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var pos1 = new Vec3(0.0f, 4.0f, 0.0f);
            await player.Initialize(_worldClient, "me", watcher, pos1);

            Thread.Sleep(240);
            Assert.Equal(1, watcher.mUpdates.Count);
            Assert.Equal(1, watcher.mUpdates[0].nPlayers);
            Assert.Equal(pos1.x, watcher.mUpdates[0].Players[0].mPosition.x);
            Assert.Equal(pos1.y, watcher.mUpdates[0].Players[0].mPosition.y);
            Assert.Equal(pos1.z, watcher.mUpdates[0].Players[0].mPosition.z);

            var pos2 = new Vec3(0.0f, 4.0f, 0.0f);

            player.TESTONLYCALL_CHANGEPLAYERNAME("not me");

            var feedback = await player.Update(pos2);

            Assert.Equal(FeedbackMessage.Responces.Error, feedback.mType);



            //Assert.Equal($"You said: '{greeting}', I say: Hello!", reply);
        }
Beispiel #2
0
        async Task SiloAddBlock_ValidateSlowPath()
        {
            string _sessionID = "SiloAddBlock_ValidateSlowPath";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);



            BlockInfo blockInfo = new BlockInfo();

            blockInfo.mID           = "Grass";
            blockInfo.mPosition     = new IntVec3(0, 1, 0);
            blockInfo.mData         = 128;
            blockInfo.mDataExtended = 256;

            await _worldClient.UpdateBlock("me", blockInfo);


            var blocks = await _worldClient.InspectBlocks(new IntVec3(0, 0, 0));


            Assert.Equal(1, blocks.Length);
            Assert.Equal(blockInfo.mPosition.x, blocks[0].mPosition.x);
            Assert.Equal(blockInfo.mPosition.y, blocks[0].mPosition.y);
            Assert.Equal(blockInfo.mPosition.z, blocks[0].mPosition.z);
        }
Beispiel #3
0
        async Task SiloAddOnePlayer_Resheduled()
        {
            string _sessionID = "SiloAddOnePlayer_Resheduled";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            Thread.Sleep(500);

            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var spawnPoint = new Vec3(0.0f, 4.0f, 0.0f);
            await player.Initialize(_worldClient, "me", watcher, spawnPoint);

            player.TESTONLYCALL_SETRESPONSETIME(1);

            var updatePath = new Vec3(10.0f, 10.0f, 10.0f);
            var feedback   = await player.Update(updatePath);

            Thread.Sleep(260);
            feedback = await player.Update(updatePath);

            Thread.Sleep(260);
            if (watcher.mUpdates.Count > 1)
            {
                Assert.Equal(1, watcher.mUpdates[1].nPlayers);
                Assert.Equal(updatePath.x, watcher.mUpdates[1].Players[0].mPosition.x);
                Assert.Equal(updatePath.y, watcher.mUpdates[1].Players[0].mPosition.y);
                Assert.Equal(updatePath.z, watcher.mUpdates[1].Players[0].mPosition.z);
            }
        }
Beispiel #4
0
        [Fact] async Task SiloAddOnePlayer()
        {
            string _sessionID = "SiloAddOnePlayer";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            Thread.Sleep(500);

            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var spawnPoint = new Vec3(0.0f, 4.0f, 0.0f);
            await player.Initialize(_worldClient, "me", watcher, spawnPoint);

            Thread.Sleep(120);
            if (watcher.mUpdates.Count >= 1)
            {
                Assert.Equal(1, watcher.mUpdates[0].nPlayers);
                Assert.Equal(spawnPoint.x, watcher.mUpdates[0].Players[0].mPosition.x);
                Assert.Equal(spawnPoint.y, watcher.mUpdates[0].Players[0].mPosition.y);
                Assert.Equal(spawnPoint.z, watcher.mUpdates[0].Players[0].mPosition.z);
            }
        }
Beispiel #5
0
        async Task AddTwoBlocks_PushPath()
        {
            string _sessionID = "SiloAddTwoBlocks_PushPath";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 115, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);



            BlockInfo blockInfo = new BlockInfo();

            blockInfo.mID           = "Grass";
            blockInfo.mPosition     = new IntVec3(0, 1, 0);
            blockInfo.mData         = 128;
            blockInfo.mDataExtended = 256;

            await _worldClient.UpdateBlock("me", blockInfo);

            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var spawnPoint = new Vec3(0.0f, 4.0f, 0.0f);
            await player.Initialize(_worldClient, "me", watcher, spawnPoint);

            Thread.Sleep(250);
            Assert.Equal(1, watcher.mUpdates.Count);
            var update = watcher.mUpdates[0];

            Assert.Equal(1, update.nPlayers);
            Assert.Equal(spawnPoint.x, update.Players[0].mPosition.x);
            Assert.Equal(spawnPoint.y, update.Players[0].mPosition.y);
            Assert.Equal(spawnPoint.z, update.Players[0].mPosition.z);

            Assert.Equal(1, update.nBlocks);
            Assert.Equal(blockInfo.mPosition.x, update.Blocks[0].mPosition.x);
            Assert.Equal(blockInfo.mPosition.y, update.Blocks[0].mPosition.y);
            Assert.Equal(blockInfo.mPosition.z, update.Blocks[0].mPosition.z);

            blockInfo.mPosition = new IntVec3(1, 1, 1);
            blockInfo.mData     = 0x80;
            await _worldClient.UpdateBlock("me", blockInfo);

            Thread.Sleep(120);

            Assert.Equal(2, watcher.mUpdates.Count);
            update = watcher.mUpdates[1];
            Assert.Equal(blockInfo.mPosition.x, update.Blocks[0].mPosition.x);
            Assert.Equal(blockInfo.mPosition.y, update.Blocks[0].mPosition.y);
            Assert.Equal(blockInfo.mPosition.z, update.Blocks[0].mPosition.z);
            Assert.Equal(blockInfo.mData, update.Blocks[0].mData);
        }
Beispiel #6
0
        async Task ValidateError_BlockBadInfo()
        {
            string _sessionID = "ValidateError_BlockBadInfo";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            var feedback = await _worldClient.UpdateBlock("me", null);

            Assert.Equal(FeedbackMessage.Responces.Error, feedback.mType);
        }
Beispiel #7
0
        public async Task SiloCreateWorld_64By64()
        {
            string _sessionID = "SiloCreateWorld_64By64";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(63, 63, 63), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            int chunks = await _worldClient.GetNumberOffChunks();

            Assert.Equal(64, chunks);
        }
Beispiel #8
0
        public async Task SiloCreateWorldAndOneChunk()
        {
            string _sessionID = "SiloCreateWorldAndOneChunk";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 15, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            var result = await _worldClient.Initialize(_sessionID);

            int chunks = await _worldClient.GetNumberOffChunks();

            Assert.Equal(1, chunks);
        }
Beispiel #9
0
        async Task ValidateError_LeaveBeforStarting_ClientCheck()
        {
            string _sessionID = "ValidateError_LeaveBeforStarting_ClientCheck";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var feedback = await player.Leave();

            Assert.Equal(FeedbackMessage.Responces.Error, feedback.mType);
        }
Beispiel #10
0
        public async Task SiloHelloPlayer()
        {
            string _sessionID = "SiloHelloPlayer";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            // The Orleans silo / client test environment is already set up at this point.
            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var pos1 = new Vec3(0.0f, 4.0f, 0.0f);
            await player.Initialize(_worldClient, "me", watcher, pos1);

            Thread.Sleep(60);
            Assert.Equal(1, watcher.mUpdates.Count);
            Assert.Equal(1, watcher.mUpdates[0].nPlayers);
            Assert.Equal(pos1.x, watcher.mUpdates[0].Players[0].mPosition.x);
            Assert.Equal(pos1.y, watcher.mUpdates[0].Players[0].mPosition.y);
            Assert.Equal(pos1.z, watcher.mUpdates[0].Players[0].mPosition.z);

            var pos2 = new Vec3(0.0f, 5.0f, 0.0f);
            await player.Update(pos2);

            Thread.Sleep(60);
            Assert.Equal(2, watcher.mUpdates.Count);
            Assert.Equal(1, watcher.mUpdates[0].nPlayers);
            Assert.Equal(pos2.x, watcher.mUpdates[1].Players[0].mPosition.x);
            Assert.Equal(pos2.y, watcher.mUpdates[1].Players[0].mPosition.y);
            Assert.Equal(pos2.z, watcher.mUpdates[1].Players[0].mPosition.z);

            var pos3 = new Vec3(0.0f, 6.0f, 0.0f);
            await player.Update(pos3);

            Thread.Sleep(60);
            Assert.Equal(3, watcher.mUpdates.Count);
            Assert.Equal(1, watcher.mUpdates[0].nPlayers);
            Assert.Equal(pos3.x, watcher.mUpdates[2].Players[0].mPosition.x);
            Assert.Equal(pos3.y, watcher.mUpdates[2].Players[0].mPosition.y);
            Assert.Equal(pos3.z, watcher.mUpdates[2].Players[0].mPosition.z);

            player.Leave();
            //Assert.Equal($"You said: '{greeting}', I say: Hello!", reply);
        }
Beispiel #11
0
        async Task ValidateError_UpdateBeforeInit()
        {
            string _sessionID = "ValidateError_UpdateBeforeInit";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var spawnPoint = new Vec3(40.0f, 40.0f, 40.0f);
            var feedback   = await player.Update(spawnPoint);

            Assert.Equal(FeedbackMessage.Responces.Error, feedback.mType);
        }
Beispiel #12
0
        async Task ValidateError_BlockNotInitialized()
        {
            string _sessionID = "ValidateError_BlockNotInitialized";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();

            BlockInfo blockInfo = new BlockInfo();

            blockInfo.mID           = "Grass";
            blockInfo.mPosition     = new IntVec3(0, 64, 0);
            blockInfo.mData         = 128;
            blockInfo.mDataExtended = 256;

            var feedback = await _worldClient.UpdateBlock("me", blockInfo);

            Assert.Equal(FeedbackMessage.Responces.Error, feedback.mType);
        }
Beispiel #13
0
        async Task ValidateError_LeaveBeforStarting_ServerCheck()
        {
            string _sessionID = "ValidateError_LeaveBeforStarting_ServerCheck";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var spawnPoint = new Vec3(0.0f, 0.0f, 0.0f);
            var feedback   = await player.Initialize(_worldClient, "me", watcher, spawnPoint);

            player.TESTONLYCALL_CHANGEPLAYERNAME("CHANGED");
            feedback = await player.Leave();

            Assert.Equal(FeedbackMessage.Responces.Error, feedback.mType);
        }
Beispiel #14
0
        async Task ValidateError_DuplicatePlayerAdds()
        {
            string _sessionID = "ValidateError_DuplicatePlayerAdds";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            Thread.Sleep(500);

            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var spawnPoint = new Vec3(0.0f, 4.0f, 0.0f);
            var feedback   = await player.Initialize(_worldClient, "me", watcher, spawnPoint);

            Assert.Equal(FeedbackMessage.Responces.None, feedback.mType);

            feedback = await player.Initialize(_worldClient, "me", watcher, spawnPoint);

            Assert.Equal(FeedbackMessage.Responces.Error, feedback.mType);
        }
Beispiel #15
0
        async Task SiloAddThreePlayers()
        {
            string _sessionID = "SiloAddThreePlayers";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 15, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);

            Thread.Sleep(500);

            var            player1  = new MinecraftOrleansPlayerClient();
            var            player2  = new MinecraftOrleansPlayerClient();
            var            player3  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher1 = new PlayerObserver();
            PlayerObserver watcher2 = new PlayerObserver();
            PlayerObserver watcher3 = new PlayerObserver();

            var spawnPoint1 = new Vec3(0.0f, 4.0f, 0.0f);
            var spawnPoint2 = new Vec3(0.0f, 0.0f, 4.0f);
            var spawnPoint3 = new Vec3(4.0f, 0.0f, 0.0f);
            await player1.Initialize(_worldClient, "one", watcher1, spawnPoint1);

            await player2.Initialize(_worldClient, "two", watcher2, spawnPoint2);

            await player3.Initialize(_worldClient, "three", watcher3, spawnPoint3);

            Thread.Sleep(180);
            int nPlayer = 0;

            foreach (var update in watcher1.mUpdates)
            {
                nPlayer += update.nPlayers;
            }

            Assert.Equal(3, nPlayer);
        }
Beispiel #16
0
        async Task SiloAddPlayer_ValidateSlowPath()
        {
            string _sessionID = "SiloAddPlayer_ValidateSlowPath";

            await CreateWorld(_sessionID, new IntVec3(0, 0, 0), new IntVec3(0, 16, 0), new IntVec3(16, 16, 16), new IntVec3(16, 16, 16));

            _worldClient = new MinecraftOrleansWorldClient();
            await _worldClient.Initialize(_sessionID);


            var            player  = new MinecraftOrleansPlayerClient();
            PlayerObserver watcher = new PlayerObserver();

            var spawnPoint = new Vec3(0.0f, 4.0f, 0.0f);
            await player.Initialize(_worldClient, "me", watcher, spawnPoint);

            var players = await _worldClient.InspectPlayers(new IntVec3(0, 0, 0));


            Assert.Equal(1, players.Length);
            Assert.Equal(spawnPoint.x, players[0].mPosition.x);
            Assert.Equal(spawnPoint.y, players[0].mPosition.y);
            Assert.Equal(spawnPoint.z, players[0].mPosition.z);
        }