public void Impose_ReturnsSelf()
        {
            // Set up
            CollectionSequenceSelectionContext <SimpleUser, List <SimpleUser> > context =
                new CollectionSequenceSelectionContext <SimpleUser, List <SimpleUser> >(
                    mParentContextMock.Object,
                    new List <IObjectGenerator <SimpleUser> >(),
                    0);

            // Call
            Expression <Func <SimpleUser, string> > expr = x => x.LastName;
            var returnContext = context.Impose(expr, "Test");

            // Verify
            Assert.AreEqual(context, returnContext);
        }
        public void Impose_ImposesMemberOnAllCurrentItems()
        {
            // Add 20 mocks to a list
            List <Mock <IObjectGenerator <SimpleUser> > > mocks = new List <Mock <IObjectGenerator <SimpleUser> > >();

            for (int x = 0; x < 20; x++)
            {
                mocks.Add(new Mock <IObjectGenerator <SimpleUser> >());
            }

            // Set up
            CollectionSequenceSelectionContext <SimpleUser, List <SimpleUser> > context =
                new CollectionSequenceSelectionContext <SimpleUser, List <SimpleUser> >(
                    mParentContextMock.Object,
                    mocks.Select(x => (IObjectGenerator <SimpleUser>)x.Object),
                    10);

            // Call
            Expression <Func <SimpleUser, string> > expr = x => x.LastName;

            context.Impose(expr, "Test");

            // Verify the first 10 in the sequence were called
            for (int x = 0; x < 10; x++)
            {
                var mock = mocks[x];
                mock.Verify(m => m.Impose(It.Is <Expression <Func <SimpleUser, string> > >(y => y == expr), It.Is <String>(y => y == "Test")), Times.Once());
            }

            // Verify the last 10 in the sequence were not called
            for (int x = 10; x < 20; x++)
            {
                var mock = mocks[x];
                mock.Verify(m => m.Impose(It.Is <Expression <Func <SimpleUser, string> > >(y => y == expr), It.Is <String>(y => y == "Test")), Times.Never());
            }
        }
コード例 #3
0
        public void Impose_ImposesMemberOnAllCurrentItems()
        {
            // Add 20 mocks to a list
            List<Mock<IObjectGenerator<SimpleUser>>> mocks = new List<Mock<IObjectGenerator<SimpleUser>>>();
            for (int x = 0; x < 20; x++)
            {
                mocks.Add(new Mock<IObjectGenerator<SimpleUser>>());
            }

            // Set up
            CollectionSequenceSelectionContext<SimpleUser, List<SimpleUser>> context =
                new CollectionSequenceSelectionContext<SimpleUser, List<SimpleUser>>(
                    mParentContextMock.Object,
                    mocks.Select(x => (IObjectGenerator<SimpleUser>)x.Object),
                    10);

            // Call
            Expression<Func<SimpleUser, string>> expr = x => x.LastName;
            context.Impose(expr, "Test");

            // Verify the first 10 in the sequence were called
            for(int x =0 ; x < 10 ; x++)
            {
                var mock = mocks[x];
                mock.Verify(m => m.Impose(It.Is<Expression<Func<SimpleUser, string>>>(y => y == expr), It.Is<String>(y => y == "Test")), Times.Once());
            }

            // Verify the last 10 in the sequence were not called
            for (int x = 10; x < 20; x++)
            {
                var mock = mocks[x];
                mock.Verify(m => m.Impose(It.Is<Expression<Func<SimpleUser, string>>>(y => y == expr), It.Is<String>(y => y == "Test")), Times.Never());
            }
        }
コード例 #4
0
        public void Impose_ReturnsSelf()
        {
            // Set up
            CollectionSequenceSelectionContext<SimpleUser, List<SimpleUser>> context =
                new CollectionSequenceSelectionContext<SimpleUser, List<SimpleUser>>(
                    mParentContextMock.Object,
                        new List<IObjectGenerator<SimpleUser>>(),
                        0);

            // Call
            Expression<Func<SimpleUser, string>> expr = x => x.LastName;
            var returnContext = context.Impose(expr, "Test");

            // Verify
            Assert.AreEqual(context, returnContext);
        }