예제 #1
0
        public void Apply_Returns_The_Intersection_Of_All_Provided_Queries()
        {
            //Arrange
            var organizationId = A <int>();
            var subQuery1      = new QueryByAccessModifier <ItSystem>(AccessModifier.Local);
            var subQuery2      = new QueryByOrganizationId <ItSystem>(organizationId);

            var included  = CreateItSystem(organizationId, AccessModifier.Local);
            var excluded1 = CreateItSystem(organizationId, AccessModifier.Public);
            var excluded2 = CreateItSystem(A <int>(), AccessModifier.Local);

            var input = new[] { included, excluded1, excluded2 }.AsQueryable();

            var sut = new IntersectionQuery <ItSystem>(new List <IDomainQuery <ItSystem> >()
            {
                subQuery1, subQuery2
            });

            //Act
            var result = sut.Apply(input).ToList();

            //Assert
            var itSystem = Assert.Single(result);

            Assert.Same(included, itSystem);
        }
        public void Apply_Includes_Results_With_AccessModifierMatch(AccessModifier includedModifier, AccessModifier excludedModifier)
        {
            //Arrange
            var included1 = CreateSystem(includedModifier);
            var included2 = CreateSystem(includedModifier);
            var excluded = CreateSystem(excludedModifier);
            var input = new[] { included1, excluded, included2 }.AsQueryable();
            var sut = new QueryByAccessModifier <ItSystem>(includedModifier);

            //Act
            var result = sut.Apply(input).ToList();

            //Assert
            Assert.Equal(2, result.Count);
            Assert.Contains(included1, result);
            Assert.Contains(included2, result);
        }