示例#1
0
        public void FindIntersectingDescriptors__AllIntersectingDescriptors()
        {
            var providedDescriptor          = new Mock <IDescriptor>().Object;
            var disjunctDescriptorMocks     = ArraysHelper.CreateWithContent(new Mock <IDescriptor>(), new Mock <IDescriptor>());
            var intersectingDescriptorMocks = ArraysHelper.CreateWithContent(new Mock <IDescriptor>(), new Mock <IDescriptor>());
            var allDescriptorMocks          = intersectingDescriptorMocks.ShuffledMerge(disjunctDescriptorMocks);

            var intersectingDescriptors = intersectingDescriptorMocks.Select(_ => _.Object);
            var allDescriptors          = allDescriptorMocks.Select(_ => _.Object);

            disjunctDescriptorMocks.ForEach(_ => _.Setup(__ => __.Intersects(providedDescriptor)).Returns(false));
            intersectingDescriptorMocks.ForEach(_ => _.Setup(__ => __.Intersects(providedDescriptor)).Returns(true));

            TestInstanceMockProtected
            .Setup <IEnumerable <IDescriptor> >("RetrieveAllDescriptors")
            .Returns(allDescriptors)
            .Verifiable();

            var result = TestInstance.FindIntersectingDescriptors(providedDescriptor);

            TestInstanceMock.Verify();
            allDescriptorMocks.ForEach(_ => _.VerifyAll());
            Assert.IsTrue(intersectingDescriptors.Equivalent(result));
        }