Пример #1
0
        public void serialize()
        {
            var id               = JsonConvert.SerializeObject(Identity.Empty, Identity.GetJsonSerializerSettings());
            var jsonIn           = $@"
{{
  ""Accounts"": [
	{{
      ""AccountId"": ""cng"",
      ""AccountName"": ""my main login"",
      ""DecryptKey"": ""asdfasdf"",
      ""IdentityTokens"": {id}
    }}
  ]
}}
".Trim();
            var accountsSettings = AccountsSettings.FromJson(jsonIn);

            var jsonOut = accountsSettings.ToJson();

            jsonOut.Should().Be(@"
{
  ""Accounts"": [
    {
      ""AccountId"": ""cng"",
      ""AccountName"": ""my main login"",
      ""LibraryScan"": true,
      ""DecryptKey"": ""asdfasdf"",
      ""IdentityTokens"": {
        ""LocaleName"": ""[empty]"",
        ""ExistingAccessToken"": {
          ""TokenValue"": ""Atna|"",
          ""Expires"": ""0001-01-01T00:00:00""
        },
        ""PrivateKey"": null,
        ""AdpToken"": null,
        ""RefreshToken"": null,
        ""Cookies"": []
      }
    }
  ]
}
".Trim());
        }
Пример #2
0
        public void _1_account_new()
        {
            var json             = @"
{
  ""Accounts"": [
	{
      ""AccountId"": ""cng"",
      ""AccountName"": ""my main login"",
      ""DecryptKey"": ""asdfasdf"",
      ""IdentityTokens"": null
    }
  ]
}
".Trim();
            var accountsSettings = AccountsSettings.FromJson(json);

            accountsSettings.Accounts.Count.Should().Be(1);
            accountsSettings.Accounts[0].AccountId.Should().Be("cng");
            accountsSettings.Accounts[0].IdentityTokens.Should().BeNull();
        }
Пример #3
0
        public void _1_account_populated()
        {
            var id = GetIdentityJson(Future);

            var json             = $@"
{{
  ""Accounts"": [
	{{
      ""AccountId"": ""cng"",
      ""AccountName"": ""my main login"",
      ""DecryptKey"": ""asdfasdf"",
      ""IdentityTokens"": {id}
    }}
  ]
}}
".Trim();
            var accountsSettings = AccountsSettings.FromJson(json);

            accountsSettings.Accounts.Count.Should().Be(1);
            accountsSettings.Accounts[0].AccountId.Should().Be("cng");
            accountsSettings.Accounts[0].IdentityTokens.Should().NotBeNull();
            accountsSettings.Accounts[0].IdentityTokens.ExistingAccessToken.TokenValue.Should().Be(AccessTokenValue);
        }
Пример #4
0
        public void _0_accounts()
        {
            var accountsSettings = AccountsSettings.FromJson(EMPTY_FILE);

            accountsSettings.Accounts.Count.Should().Be(0);
        }