本文整理汇总了C#中InMemoryRepository.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryRepository.Delete方法的具体用法?C# InMemoryRepository.Delete怎么用?C# InMemoryRepository.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryRepository
的用法示例。
在下文中一共展示了InMemoryRepository.Delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SharpRepository_Supports_Basic_Crud_Operations
public void SharpRepository_Supports_Basic_Crud_Operations()
{
// Declare your generic InMemory Repository.
// Check out HowToAbstractAwayTheGenericRepository.cs for cleaner ways to new up a repo.
var repo = new InMemoryRepository<Order, int>();
// Create
var create = new Order { Name = "Big sale" };
repo.Add(create);
const int expectedOrderId = 1;
create.OrderId.ShouldEqual(expectedOrderId);
// Read
var read = repo.Get(expectedOrderId);
read.Name.ShouldEqual(create.Name);
// Update
read.Name = "Really big sale";
repo.Update(read);
var update = repo.Get(expectedOrderId);
update.OrderId.ShouldEqual(expectedOrderId);
update.Name.ShouldEqual(read.Name);
// Delete
repo.Delete(update);
var delete = repo.Get(expectedOrderId);
delete.ShouldBeNull();
}
示例2: delete_removes_from_internal_list
public void delete_removes_from_internal_list()
{
var list = new List<string> { "Apple", "Ball", "Cat", "Dog" };
var repository = new InMemoryRepository<string>(list);
repository.Delete("Apple");
Assert.That(list.Contains("Apple"), Is.False);
}
示例3: Logging_Via_Aspects
public void Logging_Via_Aspects()
{
var repository = new InMemoryRepository<Contact, int>();
var contact1 = new Contact() {Name = "Contact 1"};
repository.Add(contact1);
repository.Add(new Contact() { Name = "Contact 2"});
repository.Add(new Contact() { Name = "Contact 3"});
contact1.Name += " EDITED";
repository.Update(contact1);
repository.Delete(2);
repository.FindAll(x => x.ContactId < 50);
}