Exemplo n.º 1
0
        public void atomic_update_at_end()
        {
            var p = new AccountsSettingsPersister(new AccountsSettings(), TestFile);

            p.BeginTransation();

            // upserted account will not persist until CommitTransation
            var acct = p.AccountsSettings.Upsert("cng", "us");

            acct.AccountName = "foo";

            File.ReadAllText(TestFile).Should().Be(EMPTY_FILE);
            p.IsInTransaction.Should().BeTrue();

            p.CommitTransation();
            p.IsInTransaction.Should().BeFalse();
        }
Exemplo n.º 2
0
        public void atomic_update_at_end()
        {
            var p = new AccountsSettingsPersister(new AccountsSettings(), TestFile);

            p.BeginTransation();

            // upserted account will not persist until CommitTransation
            var acct = p.AccountsSettings.Upsert("cng", "us");

            acct.AccountName = "foo";

            File.ReadAllText(TestFile).Should().Be(EMPTY_FILE);
            p.IsInTransaction.Should().BeTrue();

            p.CommitTransation();
            p.IsInTransaction.Should().BeFalse();


            var jsonOut = File.ReadAllText(TestFile);//.Should().Be(EMPTY_FILE);

            jsonOut.Should().Be(@"
{
  ""Accounts"": [
    {
      ""AccountId"": ""cng"",
      ""AccountName"": ""foo"",
      ""LibraryScan"": true,
      ""DecryptKey"": """",
      ""IdentityTokens"": {
        ""LocaleName"": ""us"",
        ""ExistingAccessToken"": {
          ""TokenValue"": ""Atna|"",
          ""Expires"": ""0001-01-01T00:00:00""
        },
        ""PrivateKey"": null,
        ""AdpToken"": null,
        ""RefreshToken"": null,
        ""Cookies"": []
      }
    }
  ]
}
".Trim());
        }