public void ShouldLoadASubsetOfCategories() { // Arrange var ids = new[] { "id" }; var category = new Category { Name = "Important" }; var expectedCategories = new[] { category }; // Depedent-On Component var session = Substitute.For<IDocumentSession>(); // Indirect Input session.Load<Category>(ids).Returns(expectedCategories); // System under Test var repository = new RavenDbRepository(session); // Act IEnumerable<Category> categories = repository.GetAllCategories(ids); // Assert Assert.That(categories, Is.EquivalentTo(expectedCategories)); Assert.That(categories.First().Name, Is.EqualTo(category.Name)); }
public void ShouldLoadAllCateogoriesIfNoIdsWereProvided() { // Arrange var category = new Category { Name = "Important" }; var expectedCategories = new List<Category> { category }; // Depedent-On Component var session = Substitute.For<IDocumentSession>(); var query = Substitute.For<IRavenQueryable<Category>>(); // Indirect Input session.Query<Category>().Returns(query); query.GetEnumerator().Returns(expectedCategories.GetEnumerator()); // System under Test var repository = new RavenDbRepository(session); // Act IEnumerable<Category> categories = repository.GetAllCategories(null); // Assert Assert.That(categories, Is.EquivalentTo(expectedCategories)); Assert.That(categories.First().Name, Is.EqualTo(category.Name)); }