本文整理汇总了C#中Account.setType方法的典型用法代码示例。如果您正苦于以下问题:C# Account.setType方法的具体用法?C# Account.setType怎么用?C# Account.setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account.setType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Account_count_returns_the_correct_result
public void Account_count_returns_the_correct_result()
{
Account account1;
Account account2;
account1 = new Account
{
Name = "Bank Account",
IsValid = true,
};
account2 = new Account
{
Name = "Bank Account",
IsValid = true,
};
var accountType = new AccountType
{
Name = "Other",
IsSource = true,
IsDestination = true,
IsValid = true,
};
Assert.AreEqual(accountType.AccountCount(), 0);
account1.setType(accountType);
Assert.AreEqual(accountType.AccountCount(), 1);
account2.setType(accountType);
Assert.AreEqual(accountType.AccountCount(), 2);
var accountType2 = new AccountType
{
Name = "New One",
IsSource = true,
IsDestination = true,
IsValid = true,
};
account1.setType(accountType2);
Assert.AreEqual(accountType.AccountCount(), 1);
Assert.AreEqual(accountType2.AccountCount(), 1);
}
示例2: Can_create_new_Account
public void Can_create_new_Account()
{
var account = new Account
{
Name = "Bank Account",
IsValid = true,
};
account.setType(_accountType1);
account.setCategory(_accountCategory);
Assert.IsNotNull(account);
Assert.AreEqual(account.Id, Guid.Empty);
Assert.AreEqual(account.Category.Id, Guid.Empty);
Assert.AreEqual(account.Category.Colour, "Orange");
Assert.AreEqual(account.Category.IsValid, true);
Assert.AreEqual(account.Category.Name, "Other");
Assert.AreEqual(account.IsValid, true);
Assert.AreEqual(account.Name, "Bank Account");
Assert.AreEqual(account.Type.Id, Guid.Empty);
Assert.AreEqual(account.Type.IsDestination, true);
Assert.AreEqual(account.Type.IsSource, true);
Assert.AreEqual(account.Type.IsValid, true);
Assert.AreEqual(account.Type.Name, "Asset");
}
示例3: Can_add_new_account
public void Can_add_new_account()
{
var account = new Account { Name = "Credit Card", IsValid = true };
account.setType(_accountType1);
account.setCategory(_accountCategory);
IAccountRepository Arepository = new AccountRepository();
Arepository.Add(account);
using (ISession session = SessionFactory.OpenSession())
{
var fromDb = session.Get<Account>(account.Id);
Assert.IsNotNull(fromDb);
Assert.AreNotSame(account, fromDb);
Assert.AreEqual(account.Name, fromDb.Name);
Assert.AreEqual(account.IsValid, fromDb.IsValid);
Assert.AreEqual(account.Type.Name, fromDb.Type.Name);
Assert.AreEqual(account.Category.Name, fromDb.Category.Name);
Assert.IsTrue(IsInCollection(account, account.Category.Accounts));
Assert.IsTrue(IsInCollection(account, account.Type.Accounts));
}
}
示例4: Count_Destination_Items_returns_correct_result
public void Count_Destination_Items_returns_correct_result()
{
var account = new Account
{
Name = "Test Account",
IsValid = true,
};
account.setType(_accountType1);
account.setCategory(_accountCategory);
Assert.AreEqual(account.ItemsDestinationCount(), 0);
_item.SetDestination(account);
Assert.AreEqual(account.ItemsDestinationCount(), 1);
_item.SetDestination(account);
Assert.AreEqual(account.ItemsDestinationCount(), 1);
_item2.SetDestination(account);
Assert.AreEqual(account.ItemsDestinationCount(), 2);
var account2 = new Account
{
Name = "Test Account",
IsValid = true,
};
account2.setType(_accountType1);
account2.setCategory(_accountCategory);
Assert.AreEqual(account2.ItemsDestinationCount(), 0);
_item.SetDestination(account2);
Assert.AreEqual(account.ItemsDestinationCount(), 1);
Assert.AreEqual(account2.ItemsDestinationCount(), 1);
}
示例5: List_of_types_updated_correctly
public void List_of_types_updated_correctly()
{
AccountType accountType1 = new AccountType
{
Name = "Asset",
IsDestination = true,
IsSource = true,
IsValid = true,
};
AccountType accountType2 = new AccountType
{
Name = "Expense",
IsDestination = true,
IsSource = true,
IsValid = true,
};
var account = new Account
{
IsValid = true,
Name = "Test Account",
};
Assert.AreEqual(0, accountType1.AccountCount());
Assert.AreEqual(0, accountType2.AccountCount());
account.setType(accountType1);
Assert.AreEqual(1, accountType1.AccountCount());
Assert.AreEqual(0, accountType2.AccountCount());
account.setType(accountType2);
Assert.AreEqual(0, accountType1.AccountCount());
Assert.AreEqual(1, accountType2.AccountCount());
}
示例6: ImportAccounts
private static void ImportAccounts(OleDbConnection dbConnection,
IDictionary<string, Account> accounts,
IDictionary<string, AccountType> accountTypes,
IDictionary<string, AccountCategory> accountCategories)
{
OleDbDataAdapter dataAdapter;
DataSet dataSet = new DataSet();
dataAdapter = new OleDbDataAdapter("SELECT * FROM [Accounts$]", dbConnection);
dataAdapter.Fill(dataSet);
foreach (DataRow row in dataSet.Tables[0].Rows)
{
Account account = new Account
{
Name = row["Name"].ToString(),
IsValid = bool.Parse(row["IsValid"].ToString()),
};
account.setCategory(accountCategories[row["Category Name"].ToString()]);
account.setType(accountTypes[row["Type Name"].ToString()]);
accounts.Add(account.Name, account);
}
}
示例7: CreateInitialData
private void CreateInitialData()
{
_accountType1 = new AccountType
{
Name = "Asset",
IsDestination = true,
IsSource = true,
IsValid = true,
};
_accountType2 = new AccountType
{
Name = "Expense",
IsDestination = true,
IsSource = true,
IsValid = true,
};
_accountType3 = new AccountType
{
Name = "Income",
IsDestination = false,
IsSource = true,
IsValid = true,
};
_accountType4 = new AccountType
{
Name = "Fail test",
IsDestination = true,
IsSource = false,
IsValid = true,
};
_accountCategory = new AccountCategory
{
Name = "Other",
Colour = "Orange",
IsValid = true,
};
_account1 = new Account
{
Name = "Bank Account",
IsValid = true
};
_account1.setType(_accountType1);
_account1.setCategory(_accountCategory);
_account2 = new Account
{
Name = "Food",
IsValid = true
};
_account2.setType(_accountType2);
_account2.setCategory(_accountCategory);
_account3 = new Account
{
Name = "Pay",
IsValid = true
};
_account3.setType(_accountType3);
_account3.setCategory(_accountCategory);
_account4 = new Account
{
Name = "Test",
IsValid = true,
};
_account4.setType(_accountType4);
_account4.setCategory(_accountCategory);
DateTime tempDate = new DateTime(2009, 2, 5);
_transaction = new Transaction
{
Date = tempDate,
Description = "Some payment",
IsVerified = false,
};
_item1 = new Item
{
Value = 123.0M,
IsVerified = true,
Description = "Payment 1",
};
_item1.SetTransaction(_transaction);
_item1.SetSource(_account1);
_item1.SetDestination(_account2);
_item2 = new Item
{
Value = 456.0M,
IsVerified = true,
Description = "Payment 2",
};
_item2.SetTransaction(_transaction);
_item2.SetSource(_account2);
_item2.SetDestination(_account1);
using (ISession session = SessionFactory.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
//.........这里部分代码省略.........
示例8: CreateInitialData
private void CreateInitialData()
{
_accountCategory = new AccountCategory { Name = "Test", Colour = "Green", IsValid = true };
_accountCategory2 = new AccountCategory { Name = "SomethingElse", Colour = "Green", IsValid = true };
_accountType1 = new AccountType { Name = "Asset", IsDestination = true, IsSource = true, IsValid = true };
_accountType2 = new AccountType { Name = "SourceOnly", IsDestination = false, IsSource = true, IsValid = true };
_accountType3 = new AccountType { Name = "DestinationOnly", IsDestination = true, IsSource = false, IsValid = true };
_account1 = new Account
{
Name = "Bank Account",
IsValid = true,
};
_account1.setType(_accountType1);
_account1.setCategory(_accountCategory);
_account2 = new Account
{
Name = "Savings",
IsValid = true,
};
_account2.setType(_accountType1);
_account2.setCategory(_accountCategory);
_account3 = new Account
{
Name = "SourceOnly",
IsValid = true,
};
_account3.setType(_accountType2);
_account3.setCategory(_accountCategory);
_account4 = new Account
{
Name = "DestinationOnly",
IsValid = true,
};
_account4.setType(_accountType3);
_account4.setCategory(_accountCategory);
using (ISession session = SessionFactory.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(_accountType1);
session.Save(_accountType2);
session.Save(_accountType3);
session.Save(_accountCategory);
session.Save(_accountCategory2);
session.Save(_account1);
session.Save(_account2);
session.Save(_account3);
session.Save(_account4);
transaction.Commit();
}
}
示例9: Change_account_category
public void Change_account_category()
{
var account = new Account { Name = "Credit Card", IsValid = true };
account.setType(_accountType1);
account.setCategory(_accountCategory);
account.setCategory(_accountCategory2);
IAccountRepository Arepository = new AccountRepository();
Arepository.Add(account);
using (ISession session = SessionFactory.OpenSession())
{
var fromDb = session.Get<Account>(account.Id);
Assert.IsTrue(IsInCollection(account, account.Category.Accounts));
Assert.IsFalse(IsInCollection(account, _accountCategory.Accounts));
}
}
示例10: Can_not_update_a_non_existing_account
public void Can_not_update_a_non_existing_account()
{
var account = new Account
{
Name = "Test Account",
IsValid = true,
};
account.setType(_accountType1);
account.setCategory(_accountCategory);
IAccountRepository repository = new AccountRepository();
repository.Update(account);
}
示例11: TestFixtureSetUp
public void TestFixtureSetUp()
{
_accountType1 = new AccountType
{
Name = "Asset",
IsDestination = true,
IsSource = true,
IsValid = true,
};
_accountType2 = new AccountType
{
Name = "Expense",
IsDestination = true,
IsSource = true,
IsValid = true,
};
_accountType3 = new AccountType
{
Name = "NotSource",
IsDestination = true,
IsSource = false,
IsValid = true,
};
_accountType4 = new AccountType
{
Name = "NotDestination",
IsDestination = false,
IsSource = true,
IsValid = true,
};
_accountCategory = new AccountCategory
{
Name = "Other",
Colour = "Orange",
IsValid = true,
};
_account1 = new Account
{
Name = "Bank Account",
IsValid = true,
};
_account1.setType(_accountType1);
_account1.setCategory(_accountCategory);
_account2 = new Account
{
Name = "Food",
IsValid = true,
};
_account2.setType(_accountType2);
_account2.setCategory(_accountCategory);
_account3 = new Account
{
Name = "Not Source",
IsValid = true,
};
_account3.setType(_accountType3);
_account3.setCategory(_accountCategory);
_account4 = new Account
{
Name = "Not Destination",
IsValid = true,
};
_account4.setType(_accountType4);
_account4.setCategory(_accountCategory);
DateTime tempDate = new DateTime(2009, 2, 5);
_transaction1 = new Transaction
{
Date = tempDate,
Description = "Some payment",
IsVerified = false,
};
_transaction2 = new Transaction
{
Date = tempDate,
Description = "Some other payment",
IsVerified = true,
};
_transaction3 = new Transaction
{
Date = tempDate,
Description = "A further payment",
IsVerified = true,
};
}
示例12: SourceUpdatedIfItemMovedLazily
public void SourceUpdatedIfItemMovedLazily()
{
Account account1;
Account account2;
account1 = new Account
{
Name = "Bank Account",
IsValid = true,
};
account1.setType(_accountType1);
account1.setCategory(_accountCategory);
account2 = new Account
{
Name = "Food",
IsValid = true,
};
account2.setType(_accountType2);
account2.setCategory(_accountCategory);
var item = new Item
{
Value = 99.99M,
Description = "Move Test",
IsVerified = true,
};
item.SetSourceLazy(account2);
Assert.AreEqual(item.Source, account2);
Assert.AreNotEqual(item.Source, account1);
item.SetSourceLazy(account1);
Assert.AreEqual(item.Source, account1);
Assert.AreNotEqual(item.Source, account2);
}
示例13: DestinationUpdatedIfItemMovedLazily
public void DestinationUpdatedIfItemMovedLazily()
{
Account account1;
Account account3;
account1 = new Account
{
Name = "Bank Account",
IsValid = true,
};
account1.setType(_accountType1);
account1.setCategory(_accountCategory);
account3 = new Account
{
Name = "Not Source",
IsValid = true,
};
account3.setType(_accountType3);
account3.setCategory(_accountCategory);
var item = new Item
{
Value = 99.99M,
Description = "Move Test",
IsVerified = true,
};
item.SetDestinationLazy(account3);
Assert.AreEqual(item.Destination, account3);
Assert.AreNotEqual(item.Destination, account1);
item.SetDestinationLazy(account1);
Assert.AreEqual(item.Destination, account1);
Assert.AreNotEqual(item.Destination, account3);
}
示例14: Can_create_new_accountType
public void Can_create_new_accountType()
{
Account account;
account = new Account
{
Name = "Bank Account",
IsValid = true,
};
var accountType = new AccountType
{
Name = "Other",
IsSource = true,
IsDestination = true,
IsValid = true,
};
account.setType(accountType);
Assert.AreEqual(accountType.Id, Guid.Empty);
Assert.AreEqual(account.Type, accountType);
}