当前位置: 首页>>代码示例>>C#>>正文


C# MutableObjectState类代码示例

本文整理汇总了C#中MutableObjectState的典型用法代码示例。如果您正苦于以下问题:C# MutableObjectState类的具体用法?C# MutableObjectState怎么用?C# MutableObjectState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MutableObjectState类属于命名空间,在下文中一共展示了MutableObjectState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestBecome

        public Task TestBecome()
        {
            IObjectState state = new MutableObjectState
            {
                ObjectId = "some0neTol4v4",
                ServerData = new Dictionary<string, object>() {
              { "sessionToken", "llaKcolnu" }
            }
            };
            var mockController = new Mock<IAVUserController>();
            mockController.Setup(obj => obj.GetUserAsync("llaKcolnu",
                It.IsAny<CancellationToken>())).Returns(Task.FromResult(state));
            AVPlugins.Instance = new AVPlugins
            {
                UserController = mockController.Object
            };
            AVObject.RegisterSubclass<AVUser>();
            AVObject.RegisterSubclass<AVSession>();

            return AVUser.BecomeAsync("llaKcolnu").ContinueWith(t =>
            {
                Assert.False(t.IsFaulted);
                Assert.False(t.IsCanceled);
                mockController.Verify(obj => obj.GetUserAsync("llaKcolnu",
                  It.IsAny<CancellationToken>()), Times.Exactly(1));

                var user = t.Result;
                Assert.AreEqual("some0neTol4v4", user.ObjectId);
                Assert.AreEqual("llaKcolnu", user.SessionToken);
            });
        }
开发者ID:wujun4code,项目名称:Parse-SDK-dotNET,代码行数:31,代码来源:UserTests.cs

示例2: TestApplyState

        public void TestApplyState()
        {
            var now = new DateTime();
              IObjectState state = new MutableObjectState {
            ClassName = "Corgi",
            ObjectId = "abcd",
            ServerData = new Dictionary<string, object>() {
              { "exist", 2 },
              { "change", "teletubies" }
            }
              };

              IObjectState appliedState = new MutableObjectState {
            ClassName = "AnotherCorgi",
            ObjectId = "1234",
            CreatedAt = now,
            ServerData = new Dictionary<string, object>() {
              { "exist", 9 },
              { "missing", "marasy" }
            }
              };

              state = state.MutatedClone(mutableClone => {
            mutableClone.Apply(appliedState);
              });

              Assert.AreEqual("Corgi", state.ClassName);
              Assert.AreEqual("1234", state.ObjectId);
              Assert.IsNotNull(state.CreatedAt);
              Assert.IsNull(state.UpdatedAt);
              Assert.AreEqual(3, state.Count());
              Assert.AreEqual(9, state["exist"]);
              Assert.AreEqual("teletubies", state["change"]);
              Assert.AreEqual("marasy", state["missing"]);
        }
开发者ID:wujun4code,项目名称:Parse-SDK-dotNET,代码行数:35,代码来源:ObjectStateTests.cs

示例3: TestCurrentSessionToken

        public Task TestCurrentSessionToken()
        {
            var storageController = new Mock<IStorageController>();
              var mockedStorage = new Mock<IStorageDictionary<string, object>>();
              var controller = new AVCurrentUserController(storageController.Object);

              storageController.Setup(c => c.LoadAsync()).Returns(Task.FromResult(mockedStorage.Object));

              return controller.GetCurrentSessionTokenAsync(CancellationToken.None).OnSuccess(t => {
            Assert.IsNull(t.Result);

            // We should probably mock this.
            var userState = new MutableObjectState {
              ServerData = new Dictionary<string, object>() {
            { "sessionToken", "randomString" }
              }
            };
            var user = AVObject.CreateWithoutData<AVUser>(null);
            user.HandleFetchResult(userState);

            return controller.SetAsync(user, CancellationToken.None);
              }).Unwrap()
              .OnSuccess(_ => controller.GetCurrentSessionTokenAsync(CancellationToken.None)).Unwrap()
              .OnSuccess(t => {
            Assert.AreEqual("randomString", t.Result);
              });
        }
开发者ID:wujun4code,项目名称:Parse-SDK-dotNET,代码行数:27,代码来源:CurrentUserControllerTests.cs

示例4: TestGetCurrentSession

    public Task TestGetCurrentSession() {
      IObjectState sessionState = new MutableObjectState {
        ServerData = new Dictionary<string, object>() {
          { "sessionToken", "newllaKcolnu" }
        }
      };
      var mockController = new Mock<IParseSessionController>();
      mockController.Setup(obj => obj.GetSessionAsync(It.IsAny<string>(),
          It.IsAny<CancellationToken>())).Returns(Task.FromResult(sessionState));

      IObjectState userState = new MutableObjectState {
        ServerData = new Dictionary<string, object>() {
          { "sessionToken", "llaKcolnu" }
        }
      };
      ParseUser user = ParseObject.FromState<ParseUser>(userState, "_User");
      var mockCurrentUserController = new Mock<IParseCurrentUserController>();
      mockCurrentUserController.Setup(obj => obj.GetAsync(It.IsAny<CancellationToken>()))
          .Returns(Task.FromResult(user));

      ParseCorePlugins.Instance.SessionController = mockController.Object;
      ParseCorePlugins.Instance.CurrentUserController = mockCurrentUserController.Object;

      return ParseSession.GetCurrentSessionAsync().ContinueWith(t => {
        Assert.False(t.IsFaulted);
        Assert.False(t.IsCanceled);
        mockController.Verify(obj => obj.GetSessionAsync(It.Is<string>(sessionToken => sessionToken == "llaKcolnu"),
            It.IsAny<CancellationToken>()), Times.Exactly(1));

        var session = t.Result;
        Assert.AreEqual("newllaKcolnu", session.SessionToken);
      });
    }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:33,代码来源:SessionTests.cs

示例5: TestApplyOperation

        public void TestApplyOperation()
        {
            IAVFieldOperation op1 = new AVIncrementOperation(7);
              IAVFieldOperation op2 = new AVSetOperation("legendia");
              IAVFieldOperation op3 = new AVSetOperation("vesperia");
              var operations = new Dictionary<string, IAVFieldOperation>() {
            { "exist", op1 },
            { "missing", op2 },
            { "change", op3 }
              };

              IObjectState state = new MutableObjectState {
            ServerData = new Dictionary<string, object>() {
              { "exist", 2 },
              { "change", "teletubies" }
            }
              };

              Assert.AreEqual(2, state["exist"]);
              Assert.AreEqual("teletubies", state["change"]);

              state = state.MutatedClone(mutableClone => {
            mutableClone.Apply(operations);
              });

              Assert.AreEqual(3, state.Count());
              Assert.AreEqual(9, state["exist"]);
              Assert.AreEqual("legendia", state["missing"]);
              Assert.AreEqual("vesperia", state["change"]);
        }
开发者ID:wujun4code,项目名称:Parse-SDK-dotNET,代码行数:30,代码来源:ObjectStateTests.cs

示例6: TestGetSessionToken

 public void TestGetSessionToken() {
   IObjectState state = new MutableObjectState {
     ServerData = new Dictionary<string, object>() {
       { "sessionToken", "llaKcolnu" }
     }
   };
   ParseSession session = ParseObject.FromState<ParseSession>(state, "_Session");
   Assert.NotNull(session);
   Assert.AreEqual("llaKcolnu", session.SessionToken);
 }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:10,代码来源:SessionTests.cs

示例7: TestSessionTokenGetter

 public void TestSessionTokenGetter() {
   IObjectState state = new MutableObjectState {
     ServerData = new Dictionary<string, object>() {
       { "username", "kevin" },
       { "sessionToken", "se551onT0k3n" }
     }
   };
   ParseUser user = ParseObject.FromState<ParseUser>(state, "_User");
   Assert.AreEqual("se551onT0k3n", user.SessionToken);
 }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:10,代码来源:UserTests.cs

示例8: TestUsernameGetterSetter

 public void TestUsernameGetterSetter() {
   IObjectState state = new MutableObjectState {
     ServerData = new Dictionary<string, object>() {
       { "username", "kevin" },
     }
   };
   ParseUser user = ParseObject.FromState<ParseUser>(state, "_User");
   Assert.AreEqual("kevin", user.Username);
   user.Username = "ilya";
   Assert.AreEqual("ilya", user.Username);
 }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:11,代码来源:UserTests.cs

示例9: TestRemoveFields

 public void TestRemoveFields() {
   IObjectState state = new MutableObjectState {
     ServerData = new Dictionary<string, object>() {
       { "username", "kevin" },
       { "name", "andrew" }
     }
   };
   ParseUser user = ParseObject.FromState<ParseUser>(state, "_User");
   Assert.Throws<ArgumentException>(() => user.Remove("username"));
   Assert.DoesNotThrow(() => user.Remove("name"));
   Assert.False(user.ContainsKey("name"));
 }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:12,代码来源:UserTests.cs

示例10: TestPasswordGetterSetter

 public void TestPasswordGetterSetter() {
   IObjectState state = new MutableObjectState {
     ServerData = new Dictionary<string, object>() {
       { "username", "kevin" },
       { "password", "hurrah" },
     }
   };
   ParseUser user = ParseObject.FromState<ParseUser>(state, "_User");
   Assert.AreEqual("hurrah", user.State["password"]);
   user.Password = "david";
   Assert.NotNull(user.CurrentOperations["password"]);
 }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:12,代码来源:UserTests.cs

示例11: TestEmailGetterSetter

 public void TestEmailGetterSetter() {
   IObjectState state = new MutableObjectState {
     ServerData = new Dictionary<string, object>() {
       { "email", "[email protected]" },
       { "name", "andrew" },
       { "sessionToken", "se551onT0k3n" }
     }
   };
   ParseUser user = ParseObjectExtensions.FromState<ParseUser>(state, "_User");
   Assert.AreEqual("[email protected]", user.Email);
   user.Email = "[email protected]";
   Assert.AreEqual("[email protected]", user.Email);
 }
开发者ID:dragouf,项目名称:Parse-SDK-dotNET,代码行数:13,代码来源:UserTests.cs

示例12: TestDefault

    public void TestDefault() {
      IObjectState state = new MutableObjectState();
      Assert.IsNull(state.ClassName);
      Assert.IsNull(state.ObjectId);
      Assert.IsNull(state.CreatedAt);
      Assert.IsNull(state.UpdatedAt);

      Assert.DoesNotThrow(() => {
        foreach (var pair in state) {
          Assert.IsNotNull(pair);
        }
      });
    }
开发者ID:mehul9595,项目名称:Parse-SDK-dotNET,代码行数:13,代码来源:ObjectStateTests.cs

示例13: TestAppVersionGetterSetter

    public void TestAppVersionGetterSetter() {
      IObjectState state = new MutableObjectState {
        ServerData = new Dictionary<string, object>() {
          { "appVersion", "1.2.3" }
        }
      };
      ParseInstallation installation = ParseObjectExtensions.FromState<ParseInstallation>(state, "_Installation");
      Assert.NotNull(installation);
      Assert.AreEqual("1.2.3", installation.AppVersion);

      Assert.Throws<InvalidOperationException>(() => installation["appVersion"] = "1.2.4");
      installation.SetIfDifferent("appVersion", "1.2.4");
      Assert.AreEqual("1.2.4", installation.AppVersion);
    }
开发者ID:dragouf,项目名称:Parse-SDK-dotNET,代码行数:14,代码来源:InstallationTests.cs

示例14: TestDeviceTypeGetterSetter

    public void TestDeviceTypeGetterSetter() {
      IObjectState state = new MutableObjectState {
        ServerData = new Dictionary<string, object>() {
          { "deviceType", "parseOS" }
        }
      };
      ParseInstallation installation = ParseObjectExtensions.FromState<ParseInstallation>(state, "_Installation");
      Assert.NotNull(installation);
      Assert.AreEqual("parseOS", installation.DeviceType);

      Assert.Throws<InvalidOperationException>(() => installation["deviceType"] = "gogoOS");
      installation.SetIfDifferent("deviceType", "gogoOS");
      Assert.AreEqual("gogoOS", installation.DeviceType);
    }
开发者ID:dragouf,项目名称:Parse-SDK-dotNET,代码行数:14,代码来源:InstallationTests.cs

示例15: TestAppNameGetterSetter

    public void TestAppNameGetterSetter() {
      IObjectState state = new MutableObjectState {
        ServerData = new Dictionary<string, object>() {
          { "appName", "parseApp" }
        }
      };
      ParseInstallation installation = ParseObject.FromState<ParseInstallation>(state, "_Installation");
      Assert.NotNull(installation);
      Assert.AreEqual("parseApp", installation.AppName);

      Assert.Throws<InvalidOperationException>(() => installation.AppName = "gogoApp");
      installation.SetIfDifferent("appName", "gogoApp");
      Assert.AreEqual("gogoApp", installation.AppName);
    }
开发者ID:taecg,项目名称:Parse-SDK-dotNET,代码行数:14,代码来源:InstallationTests.cs


注:本文中的MutableObjectState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。