本文整理汇总了C#中Book.RemoveSecurity方法的典型用法代码示例。如果您正苦于以下问题:C# Book.RemoveSecurity方法的具体用法?C# Book.RemoveSecurity怎么用?C# Book.RemoveSecurity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book.RemoveSecurity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Replay_WhenSavePointIsNull_ReplaysFromTheBeginning
public void Replay_WhenSavePointIsNull_ReplaysFromTheBeginning()
{
// Create a new, valid book.
var book = new Book();
// Create a new, valid account.
var account = TestUtils.CreateValidAccount();
// Create a new, valid transaction.
var transaction = TestUtils.CreateValidTransaction(account);
// Get two valid securities.
var security1 = TestUtils.TestCurrency;
var security2 = TestUtils.TestStock;
// Create a new, valid price quote based on the above securities.
var priceQuote = TestUtils.CreateValidPriceQuote();
// Add and immediately remove the security, account, and transaction from the book.
book.AddSecurity(security1);
book.AddSecurity(security2);
book.AddAccount(account);
book.AddPriceQuote(priceQuote);
book.RemovePriceQuote(priceQuote);
book.AddTransaction(transaction);
book.RemoveTransaction(transaction);
book.RemoveAccount(account);
book.RemoveSecurity(security2);
book.RemoveSecurity(security1);
// Create a new mock data adapter and replay the book changes into the mock.
var destination = new MockSaver();
book.Replay(destination, null);
// Assert that the mock received the proper additional and removals of each component.
Assert.That(destination.SecurityAdditions.Count, Is.EqualTo(2));
Assert.That(destination.SecurityRemovals.Count, Is.EqualTo(2));
Assert.That(destination.PriceQuoteAdditions.Count, Is.EqualTo(1));
Assert.That(destination.PriceQuoteRemovals.Count, Is.EqualTo(1));
Assert.That(destination.AccountAdditions.Count, Is.EqualTo(1));
Assert.That(destination.AccountRemovals.Count, Is.EqualTo(1));
Assert.That(destination.TransactionAdditions.Count, Is.EqualTo(1));
Assert.That(destination.TransactionRemovals.Count, Is.EqualTo(1));
}
示例2: RemoveSecurity_WhenValid_Succeeds
public void RemoveSecurity_WhenValid_Succeeds()
{
// Create a new, empty book.
var book = new Book();
// Add the test security to the book.
book.AddSecurity(TestUtils.TestCurrency);
// Remove the security from the book.
book.RemoveSecurity(TestUtils.TestCurrency);
// The test passes, because the call to RemoveSecurity() has completed successfully.
Assert.True(true); // Assert.Pass() was not used, to maintain compatibility with ReSharper.
}
示例3: RemoveSecurity_WhenValid_NotifiesOfChange
public void RemoveSecurity_WhenValid_NotifiesOfChange()
{
// Create a new, empty book.
var book = new Book();
// Add the test security to the book.
book.AddSecurity(TestUtils.TestCurrency);
// Wire-up the CollectionChanged event to flag the change.
bool called = false;
book.SecurityRemoved += (sender, e) => { called = true; };
// Remove the security from the book.
book.RemoveSecurity(TestUtils.TestCurrency);
// Assert that the collection notified us of the change.
Assert.That(called, Is.True);
}
示例4: RemoveSecurity_WhenSecurityIsUsedByPriceQuoteAsSecurity_ThrowsException
public void RemoveSecurity_WhenSecurityIsUsedByPriceQuoteAsSecurity_ThrowsException()
{
// Create a new, valid book.
var book = new Book();
// Add a test currency and stock to the book.
book.AddSecurity(TestUtils.TestCurrency);
book.AddSecurity(TestUtils.TestStock);
// Create a new, valid price quote based on the above securities.
var priceQuote = TestUtils.CreateValidPriceQuote();
// Add the price quote to the book.
book.AddPriceQuote(priceQuote);
// Assert that trying to remove the security while the price quote depends on it throws an InvalidOperationException.
Assert.That(() => book.RemoveSecurity(TestUtils.TestStock), Throws.InstanceOf<InvalidOperationException>());
}
示例5: RemoveSecurity_WhenSecurityIsNull_ThrowsException
public void RemoveSecurity_WhenSecurityIsNull_ThrowsException()
{
// Create a new, empty book.
var book = new Book();
// Assert that trying to add a null security throws an ArgumentNullException.
Assert.That(() => book.RemoveSecurity(null), Throws.InstanceOf<ArgumentNullException>());
}
示例6: RemoveSecurity_WhenSecurityHasNotBeenAdded_ThrowsException
public void RemoveSecurity_WhenSecurityHasNotBeenAdded_ThrowsException()
{
// Create a new, empty book.
var book = new Book();
// Assert that trying to remove the security without being added throws an InvalidOperationException.
Assert.That(() => book.RemoveSecurity(TestUtils.TestCurrency), Throws.InstanceOf<InvalidOperationException>());
}
示例7: RemoveSecurity_WhenSecurityHasAlreadyBeenRemoved_ThrowsException
public void RemoveSecurity_WhenSecurityHasAlreadyBeenRemoved_ThrowsException()
{
// Create a new, empty book.
var book = new Book();
// Add and immediately remove the test security from the book.
book.AddSecurity(TestUtils.TestCurrency);
book.RemoveSecurity(TestUtils.TestCurrency);
// Assert that trying to remove the security again throws an InvalidOperationException.
Assert.That(() => book.RemoveSecurity(TestUtils.TestCurrency), Throws.InstanceOf<InvalidOperationException>());
}