public void Exceptions_Do_Not_Fail_Entire_Action()
            {
                const string searchText = "Search Text";
                var repository = new StubRepository
                {
                    SearchCallback = s =>
                    {
                        Assert.AreEqual(searchText, s);
                        return new[] { new WorkItem { Id = 1 } };
                    }
                };

                var secondRepository = new StubRepository
                {
                    SearchCallback = s =>
                    {
                        throw new ArgumentOutOfRangeException("s", "Testing exceptions");
                    }
                };

                var searchHub = new SearchHub(new[] { repository, secondRepository });
                var result = searchHub.Search(searchText);

                Assert.IsTrue(repository.SearchCalled);
                Assert.IsNotNull(result);
                Assert.AreEqual(1, result.Count());
            }
            public void Nulls_Do_Not_End_Up_In_Results()
            {
                const string searchText = "Search Text";
                var repository = new StubRepository
                {
                    SearchCallback = s =>
                    {
                        Assert.AreEqual(searchText, s);
                        return new[] { new WorkItem { Id = 1 } };
                    }
                };

                var secondRepository = new StubRepository
                {
                    SearchCallback = s => new WorkItem[] { null }
                };

                var searchHub = new SearchHub(new[] { repository, secondRepository });
                var result = searchHub.Search(searchText).ToArray();

                Assert.IsTrue(repository.SearchCalled);
                Assert.AreEqual(1, result.Count());
                Assert.IsNotNull(result.First());
            }
            public void Results_Are_Aggregated()
            {
                const string searchText = "Search Text";
                var repository = new StubRepository
                {
                    SearchCallback = s =>
                    {
                        Assert.AreEqual(searchText, s);
                        return new[] { new WorkItem { Id = 1 } };
                    }
                };

                var secondRepository = new StubRepository
                {
                    SearchCallback = s =>
                    {
                        Assert.AreEqual(searchText, s);
                        return new[] { new WorkItem { Id = 2 } };
                    }
                };

                var searchHub = new SearchHub(new[] { repository, secondRepository });
                var result = searchHub.Search(searchText);

                Assert.IsTrue(repository.SearchCalled);
                Assert.IsNotNull(result);
                Assert.AreEqual(2, result.Count());
            }
            public void Search_Should_Be_Called()
            {
                const string searchText = "Search Text";
                var repository = new StubRepository
                    {
                        SearchCallback = s =>
                            {
                                Assert.AreEqual(searchText, s);
                                return new[] { new WorkItem() };
                            }
                    };

                var searchHub = new SearchHub(new[] { repository });
                var result = searchHub.Search(searchText);

                Assert.IsTrue(repository.SearchCalled);
                Assert.IsNotNull(result);
            }