本文整理汇总了C#中System.Item.SetDestination方法的典型用法代码示例。如果您正苦于以下问题:C# Item.SetDestination方法的具体用法?C# Item.SetDestination怎么用?C# Item.SetDestination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.SetDestination方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_add_new_item
public void Can_add_new_item()
{
var item = new Item
{
Value = 0.01M,
Description = "Add Test",
IsVerified = true,
};
item.SetTransaction(_transaction);
item.SetSource(_account1);
item.SetDestination(_account2);
IItemRepository repository = new ItemRepository();
repository.Add(item);
using (ISession session = SessionFactory.OpenSession())
{
var fromDb = session.Get<Item>(item.Id);
Assert.IsNotNull(fromDb);
Assert.AreNotSame(item, fromDb);
Assert.AreEqual(item.Value, fromDb.Value);
Assert.AreEqual(item.Description, fromDb.Description);
Assert.AreEqual(item.Destination.Id, fromDb.Destination.Id);
Assert.AreEqual(item.Source.Id, fromDb.Source.Id);
Assert.AreEqual(item.IsVerified, fromDb.IsVerified);
Assert.AreEqual(item.TransactionId.Id, fromDb.TransactionId.Id);
Assert.IsTrue(IsInCollection(item, item.TransactionId.Items));
Assert.IsTrue(IsInCollection(item, item.Source.ItemsSource));
Assert.IsTrue(IsInCollection(item, item.Destination.ItemsDestination));
}
}
示例2: Cannot_move_money_from_destination_only_account
public void Cannot_move_money_from_destination_only_account()
{
var item = new Item
{
Value = 99.01M,
Description = "Add Test",
IsVerified = true,
};
item.SetTransaction(_transaction1);
item.SetSource(_account3);
item.SetDestination(_account1);
}
示例3: ImportItems
private static void ImportItems(OleDbConnection dbConnection,
Iesi.Collections.Generic.ISet<Item> items,
IDictionary<string, Account> accounts,
IDictionary<int, Transaction> transactions)
{
OleDbDataAdapter dataAdapter;
DataSet dataSet = new DataSet();
dataAdapter = new OleDbDataAdapter("SELECT * FROM [Items$]", dbConnection);
dataAdapter.Fill(dataSet);
foreach (DataRow row in dataSet.Tables[0].Rows)
{
Account source = accounts[row["Source"].ToString()];
Account destination = accounts[row["Destination"].ToString()];
int tranKey = Int32.Parse(row["TransactionKey"].ToString());
Decimal value = Decimal.Parse(row["Value"].ToString());
Transaction transaction = transactions[tranKey];
Item item = new Item
{
Description = row["Description"].ToString(),
Value = value,
IsVerified = bool.Parse(row["IsVerified"].ToString()),
};
item.SetTransaction(transaction);
item.SetSource(source);
item.SetDestination(destination);
items.Add(item);
}
}
示例4: 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())
{
//.........这里部分代码省略.........
示例5: TransactionUpdatedIfItemMoved
public void TransactionUpdatedIfItemMoved()
{
var item = new Item
{
Value = 99.99M,
Description = "Move Test",
IsVerified = true,
};
item.SetTransaction(_transaction3);
item.SetDestination(_account1);
item.SetSource(_account2);
Assert.AreEqual(item.TransactionId, _transaction3);
Assert.AreNotEqual(item.TransactionId, _transaction2);
Assert.AreEqual(1, _transaction3.ItemCount());
Assert.AreEqual(0, _transaction2.ItemCount());
item.SetTransaction(_transaction2);
Assert.AreEqual(item.TransactionId, _transaction2);
Assert.AreNotEqual(item.TransactionId, _transaction3);
Assert.AreEqual(0, _transaction3.ItemCount());
Assert.AreEqual(1, _transaction2.ItemCount());
}
示例6: Item_DestinationName
public void Item_DestinationName()
{
var item = new Item
{
Value = 99.99M,
Description = "Move Test",
IsVerified = true,
};
item.SetDestination(_account1);
Assert.AreEqual(item.DestinationName, "Bank Account");
}
示例7: DestinationUpdatedIfItemMoved
public void DestinationUpdatedIfItemMoved()
{
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.SetDestination(account3);
Assert.AreEqual(item.Destination, account3);
Assert.AreNotEqual(item.Destination, account1);
Assert.AreEqual(1, account3.ItemsDestinationCount());
Assert.AreEqual(0, account1.ItemsDestinationCount());
item.SetDestination(account1);
Assert.AreEqual(item.Destination, account1);
Assert.AreNotEqual(item.Destination, account3);
Assert.AreEqual(1, account1.ItemsDestinationCount());
Assert.AreEqual(0, account3.ItemsDestinationCount());
}
示例8: Can_create_new_item
public void Can_create_new_item()
{
var item = new Item
{
Value = 0.01M,
Description = "Add Test",
IsVerified = true,
};
item.SetTransaction(_transaction1);
item.SetSource(_account1);
item.SetDestination(_account2);
Assert.IsNotNull(item);
Assert.AreEqual(item.Id, Guid.Empty);
Assert.AreEqual(item.Source.Id, Guid.Empty);
Assert.AreEqual(item.Source.Category.Id, Guid.Empty);
Assert.AreEqual(item.Source.Type.Id, Guid.Empty);
Assert.AreEqual(item.Destination.Id, Guid.Empty);
Assert.AreEqual(item.Destination.Category.Id, Guid.Empty);
Assert.AreEqual(item.Destination.Type.Id, Guid.Empty);
Assert.AreEqual(item.TransactionId.Id, Guid.Empty);
Assert.AreEqual(item.Description, "Add Test");
Assert.AreEqual(item.Destination, _account2);
Assert.AreEqual(item.IsVerified, true);
Assert.AreEqual(item.Source, _account1);
Assert.AreEqual(item.TransactionId, _transaction1);
Assert.AreEqual(item.Value, 0.01M);
Assert.AreEqual(item.Destination.Category, _account2.Category);
Assert.AreEqual(item.Destination.Category.Colour, _account2.Category.Colour);
Assert.AreEqual(item.Destination.Category.IsValid, _account2.Category.IsValid);
Assert.AreEqual(item.Destination.Category.Name, _account2.Category.Name);
Assert.AreEqual(item.Destination.IsValid, _account2.IsValid);
Assert.AreEqual(item.Destination.Name, _account2.Name);
Assert.AreEqual(item.Destination.Type, _account2.Type);
Assert.AreEqual(item.Destination.Type.IsDestination, _account2.Type.IsDestination);
Assert.AreEqual(item.Destination.Type.IsSource, _account2.Type.IsSource);
Assert.AreEqual(item.Destination.Type.IsValid, _account2.Type.IsValid);
Assert.AreEqual(item.Destination.Type.Name, _account2.Type.Name);
Assert.AreEqual(item.Source.Category, _account1.Category);
Assert.AreEqual(item.Source.Category.Colour, _account1.Category.Colour);
Assert.AreEqual(item.Source.Category.IsValid, _account1.IsValid);
Assert.AreEqual(item.Source.Category.Name, _account1.Category.Name);
Assert.AreEqual(item.Source.IsValid, _account1.IsValid);
Assert.AreEqual(item.Source.Name, _account1.Name);
Assert.AreEqual(item.Source.Type, _account1.Type);
Assert.AreEqual(item.Source.Type.IsDestination, _account1.Type.IsDestination);
Assert.AreEqual(item.Source.Type.IsSource, _account1.Type.IsSource);
Assert.AreEqual(item.Source.Type.IsValid, _account1.Type.IsValid);
Assert.AreEqual(item.Source.Type.Name, _account1.Type.Name);
}
示例9: Cannot_move_money_within_the_same_account2
public void Cannot_move_money_within_the_same_account2()
{
var item = new Item
{
Value = 567.78M,
Description = "Add Test",
IsVerified = true,
};
item.SetTransaction(_transaction1);
item.SetDestination(_account1);
item.SetSource(_account1);
}