Esempio n. 1
0
    public void QueueEntityComponentCorrectly()
    {
        const string entityId       = "1";
        const string componentId    = "component-1";
        const int    componentClass = 1;

        EntryPoint_World.SetEntityId(entityId);
        EntryPoint_World.CreateEntity();
        EntryPoint_World.EntityComponentCreateOrUpdate(componentClass, componentId);
        EntryPoint_World.EntityComponentDestroy(componentId);

        Assert.AreEqual(3, queueHandler.messagesList.Count);

        string json1base = @"{""method"":""CreateEntity"",""payload"":{""entityId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";
        string json2base = @"{""method"":""UpdateEntityComponent"",""payload"":{""entityId"":""1"",""classId"":1,""json"":""component-1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";
        string json3base = @"{""method"":""ComponentRemoved"",""payload"":{""entityId"":""1"",""name"":""component-1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        string json1 = JsonConvert.SerializeObject(queueHandler.messagesList[0]);
        string json2 = JsonConvert.SerializeObject(queueHandler.messagesList[1]);
        string json3 = JsonConvert.SerializeObject(queueHandler.messagesList[2]);

        Assert.AreEqual(json1base, json1);
        Assert.AreEqual(json2base, json2);
        Assert.AreEqual(json3base, json3);
    }
Esempio n. 2
0
    public void QueueEntityMessagesCorrectly()
    {
        const string entityId_1 = "1";
        const string entityId_2 = "2";

        EntryPoint_World.SetEntityId(entityId_1);
        EntryPoint_World.CreateEntity();
        EntryPoint_World.SetEntityId(entityId_2);
        EntryPoint_World.CreateEntity();
        EntryPoint_World.SetEntityParent(entityId_1);

        EntryPoint_World.SetEntityId(entityId_1);
        EntryPoint_World.RemoveEntity();
        EntryPoint_World.SetEntityId(entityId_2);
        EntryPoint_World.RemoveEntity();

        string json1     = JsonConvert.SerializeObject(queueHandler.messagesList[0]);
        string json1base = @"{""method"":""CreateEntity"",""payload"":{""entityId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json1base, json1);

        string json2     = JsonConvert.SerializeObject(queueHandler.messagesList[1]);
        string json2base = @"{""method"":""CreateEntity"",""payload"":{""entityId"":""2""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json2base, json2);

        string json3     = JsonConvert.SerializeObject(queueHandler.messagesList[2]);
        string json3base = @"{""method"":""SetEntityParent"",""payload"":{""entityId"":""2"",""parentId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json3base, json3);

        string json4     = JsonConvert.SerializeObject(queueHandler.messagesList[3]);
        string json4base = @"{""method"":""RemoveEntity"",""payload"":{""entityId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json4base, json4);

        string json5     = JsonConvert.SerializeObject(queueHandler.messagesList[4]);
        string json5base = @"{""method"":""RemoveEntity"",""payload"":{""entityId"":""2""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json5base, json5);
    }
Esempio n. 3
0
    public void QueueSharedComponentMessagesCorrectly()
    {
        const string entityId       = "1";
        const string componentId    = "component-1";
        const int    componentClass = 1;

        EntryPoint_World.SetEntityId(entityId);
        EntryPoint_World.CreateEntity();
        EntryPoint_World.SharedComponentCreate(componentClass, componentId);
        EntryPoint_World.SharedComponentAttach(componentId, null);
        EntryPoint_World.SharedComponentUpdate(componentId, "{}");
        EntryPoint_World.SharedComponentDispose(componentId);

        string json1     = JsonConvert.SerializeObject(queueHandler.messagesList[0]);
        string json1base = @"{""method"":""CreateEntity"",""payload"":{""entityId"":""1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json1base, json1);

        string json2     = JsonConvert.SerializeObject(queueHandler.messagesList[1]);
        string json2base = @"{""method"":""ComponentCreated"",""payload"":{""id"":""component-1"",""classId"":1,""name"":null},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json2base, json2);

        string json3     = JsonConvert.SerializeObject(queueHandler.messagesList[2]);
        string json3base = @"{""method"":""AttachEntityComponent"",""payload"":{""entityId"":""1"",""id"":""component-1"",""name"":null},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json3base, json3);

        string json4     = JsonConvert.SerializeObject(queueHandler.messagesList[3]);
        string json4base = @"{""method"":""ComponentUpdated"",""payload"":{""componentId"":""component-1"",""json"":""{}""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json4base, json4);

        string json5     = JsonConvert.SerializeObject(queueHandler.messagesList[4]);
        string json5base = @"{""method"":""ComponentDisposed"",""payload"":{""id"":""component-1""},""tag"":""test-tag"",""type"":1,""sceneId"":""test-scene-id"",""message"":null,""isUnreliable"":false,""unreliableMessageKey"":null}";

        Assert.AreEqual(json5base, json5);
    }