예제 #1
0
            public void FindsPeopleWithFirstName_StartingWithTerm()
            {
                var query = new FindPeopleWithFirstNameQuery
                {
                    Term = "daniel",
                    TermMatchStrategy = StringMatchStrategy.StartsWith,
                };
                var fakes    = FakePeople();
                var entities = new Mock <IQueryEntities>(MockBehavior.Strict);

                entities.Setup(p => p.Query <Person>()).Returns(fakes);
                entities.Setup(m => m.EagerLoad(fakes,
                                                It.IsAny <Expression <Func <Person, object> > >())).Returns(fakes);
                var handler = new FindPeopleWithFirstNameHandler(entities.Object);

                var results = handler.Handle(query);

                results.ShouldNotBeNull();
                results.Count().ShouldEqual(2);
                results.ToList().ForEach(i => i.FirstName.ShouldStartWith("Daniel"));
            }