Exemplo n.º 1
0
        private void OnRealmChanged(CurrentRealmModel current, CurrentRealmModel prev)
        {
            if (current == null)
            {
                return;
            }

            SetColor(current.Equals(realmServer, realmLayer) ? markerObject.sameRealmColor : markerObject.otherRealmColor);
        }
    public void TriggerCurrentRealmOnChangeCorrectly()
    {
        const string SERVER_NAME = "temptation";
        const string LAYER       = "red";

        var handler = new RealmsInfoHandler();

        var testModel = new RealmsInfoModel()
        {
            current = new CurrentRealmModel()
            {
                serverName = SERVER_NAME,
                layer      = LAYER
            }
        };

        bool onChangeTriggered = false;
        CurrentRealmModel onChangeCurrentValue = null;

        handler.playerRealm.OnChange += (current, prev) =>
        {
            onChangeTriggered    = true;
            onChangeCurrentValue = current;
        };

        handler.Set(testModel);
        Assert.IsTrue(onChangeTriggered, "OnChange not triggered");
        Assert.IsTrue(testModel.current.Equals(onChangeCurrentValue), "Values are not the same");
        Assert.IsTrue(testModel.current.serverName == SERVER_NAME, "Values are not the same");
        Assert.IsTrue(testModel.current.layer == LAYER, "Values are not the same");

        onChangeTriggered = false;
        handler.Set(JsonUtility.ToJson(testModel));
        Assert.IsFalse(onChangeTriggered, "OnChange shouldn't be triggered");

        const string NEW_LAYER = "blue";

        testModel.current.layer = NEW_LAYER;

        handler.Set(JsonUtility.ToJson(testModel));
        Assert.IsTrue(testModel.current.Equals(onChangeCurrentValue), "Values are not the same");
        Assert.IsTrue(testModel.current.serverName == SERVER_NAME, "Values are not the same");
        Assert.IsTrue(testModel.current.layer == NEW_LAYER, "Values are not the same");

        onChangeTriggered = false;
        handler.Set(testModel);
        Assert.IsFalse(onChangeTriggered, "OnChange shouldn't be triggered");
    }
Exemplo n.º 3
0
 private void PlayerRealmOnOnChange(CurrentRealmModel current, CurrentRealmModel previous)
 {
     realmDomain           = current.domain;
     realmContentServerUrl = current.contentServerUrl;
 }