public void violate_validation() { var accountsSettings = new AccountsSettings(); var idIn = new Identity(usLocale); var a1 = new Account("a") { AccountName = "one", IdentityTokens = idIn }; accountsSettings.Add(a1); var a2 = new Account("a") { AccountName = "two", IdentityTokens = idIn }; // violation: validate() Assert.ThrowsException <InvalidOperationException>(() => accountsSettings.Add(a2)); }
public void get_where() { var idUs = new Identity(usLocale); var acct1 = new Account("cng") { IdentityTokens = idUs, AccountName = "foo" }; var idUk = new Identity(ukLocale); var acct2 = new Account("cng") { IdentityTokens = idUk, AccountName = "bar" }; var accountsSettings = new AccountsSettings(); accountsSettings.Add(acct1); accountsSettings.Add(acct2); accountsSettings.GetAccount("cng", "uk").AccountName.Should().Be("bar"); }
public void save_multiple_children() { var accountsSettings = new AccountsSettings(); accountsSettings.Add(new Account("a0") { AccountName = "n0" }); accountsSettings.Add(new Account("a1") { AccountName = "n1" }); // dispose to cease auto-updates using (var p = new AccountsSettingsPersister(accountsSettings, TestFile)) { } var persister = new AccountsSettingsPersister(TestFile); persister.AccountsSettings.Accounts.Count.Should().Be(2); persister.AccountsSettings.Accounts[1].AccountName.Should().Be("n1"); }
public void identity_violate_validation() { var accountsSettings = new AccountsSettings(); var idIn = new Identity(usLocale); var a1 = new Account("a") { AccountName = "one", IdentityTokens = idIn }; accountsSettings.Add(a1); var a2 = new Account("a") { AccountName = "two" }; accountsSettings.Add(a2); // violation: GetAccount.SingleOrDefault Assert.ThrowsException <InvalidOperationException>(() => a2.IdentityTokens = idIn); }
public void save_with_identity() { var id = new Identity(usLocale); var idJson = JsonConvert.SerializeObject(id, Identity.GetJsonSerializerSettings()); var accountsSettings = new AccountsSettings(); accountsSettings.Add(new Account("a0") { AccountName = "n0", IdentityTokens = id }); // dispose to cease auto-updates using (var p = new AccountsSettingsPersister(accountsSettings, TestFile)) { } var persister = new AccountsSettingsPersister(TestFile); var acct = persister.AccountsSettings.Accounts[0]; acct.AccountName.Should().Be("n0"); acct.Locale.CountryCode.Should().Be("us"); }