Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }