本文整理汇总了C#中InMemoryRepository.Save方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryRepository.Save方法的具体用法?C# InMemoryRepository.Save怎么用?C# InMemoryRepository.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryRepository
的用法示例。
在下文中一共展示了InMemoryRepository.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Repository_adds_to_internal_list_on_save
public void Repository_adds_to_internal_list_on_save()
{
var list = new List<string> { "Apple", "Ball", "Cat", "Dog" };
var repository = new InMemoryRepository<string>(list);
repository.Save("DoDo");
Assert.That(list.Contains("DoDo"));
}
示例2: When_getting_the_searchable_items_then_all_are_obtained
public void When_getting_the_searchable_items_then_all_are_obtained()
{
// Arrange
var repository = new InMemoryRepository();
repository.Save(Builder<SearchableItem>.CreateNew().Build());
repository.Save(Builder<SearchableItem>.CreateNew().Build());
repository.Save(Builder<SearchableItem>.CreateNew().Build());
var command = new GetSearchableItemsCommand(repository);
var request = new Request<string>();
// Act
var response = command.Execute(request);
// Assert
Assert.That(response.Results.Count(),Is.EqualTo(3));
}
示例3: CanSaveAndGetAnEntity
public void CanSaveAndGetAnEntity()
{
IRepository<SomeEntity> repo = new InMemoryRepository<SomeEntity>();
SomeEntity entity = new SomeEntity("a");
var unstoredEntity = repo.Get("a");
Assert.IsNull(unstoredEntity);
repo.Save(entity);
var storedEntity = repo.Get("a");
Assert.IsNotNull(storedEntity);
Assert.AreSame(entity, storedEntity);
}