public void SubDomainModel_FindEntities_Specification_TemplateMethodIsCalled() { TestSubDomainModel testSubject = new TestSubDomainModel(); ISpecification <TestDummy> spec = Specification.Lambda <TestDummy>(td => td.RecordId > 1); IList <TestDummy> result = testSubject.FindEntities(spec); Assert.IsTrue(testSubject.FindEntitiesCoreWasCalled); Assert.AreSame(spec, testSubject.FindEntitiesCoreParameter); }
public void SubDomainModel_FindEntities_Expression_TemplateMethodIsCalled() { TestSubDomainModel testSubject = new TestSubDomainModel(); Repository <TestDummy> mockedRepository = MockRepository.GeneratePartialMock <Repository <TestDummy> >(); IList <TestDummy> result = testSubject.FindEntities(td => td.RecordId > 1); Assert.IsTrue(testSubject.FindEntitiesCoreWasCalled); Expression <Func <TestDummy, bool> > expressionResult = testSubject.FindEntitiesCoreParameter.Visit(mockedRepository); Assert.AreEqual(ExpressionType.Lambda, expressionResult.NodeType); Assert.AreEqual(typeof(bool), expressionResult.ReturnType); }
public void SubDomainModel_FindEntities_NoSpecificationNoIncludePaths_TemplateMethodIsCalled() { TestSubDomainModel testSubject = new TestSubDomainModel(); Repository <TestDummy> mockedRepository = MockRepository.GeneratePartialMock <Repository <TestDummy> >(); IList <TestDummy> result = testSubject.FindEntities(); ISpecification <TestDummy> specificationResult = testSubject.FindEntitiesCoreParameter; Expression <Func <TestDummy, bool> > expressionResult = specificationResult.Visit(mockedRepository); Assert.IsTrue(testSubject.FindEntitiesCoreWasCalled); Assert.AreEqual(ExpressionType.Lambda, expressionResult.NodeType); Assert.AreEqual(typeof(bool), expressionResult.ReturnType); bool constantValue = (bool)((ConstantExpression)expressionResult.Body).Value; Assert.AreEqual(true, constantValue); }