Пример #1
0
    public void ListenInitialState()
    {
        var container   = new StateContainer(new IndexedDictionary <string, object>());
        var listenCalls = 0;

        container.Listen("players/:id/position/:attribute", (DataChange change) => {
            listenCalls++;
        });

        container.Listen("turn", (DataChange change) => {
            listenCalls++;
        });

        container.Listen("game/turn", (DataChange change) => {
            listenCalls++;
        });

        container.Listen("messages/:number", (DataChange change) => {
            listenCalls++;
        });

        container.Set(GetRawData());

        Assert.AreEqual(9, listenCalls);
    }
Пример #2
0
    public void ListenAddString()
    {
        var newData = GetRawData();

        newData ["some_string"] = "hello!";

        var listenCalls = 0;

        container.Listen("some_string", (DataChange change) => {
            listenCalls++;
            Assert.AreEqual("add", change.operation);
            Assert.AreEqual("hello!", change.value);
        });

        container.Set(newData);
        Assert.AreEqual(1, listenCalls);
    }