Jwc.Experiment.Xunit.CompositeTestCommandFactory.Create C# (CSharp) Method

Create() public method

Creates test commands.
public Create ( IMethodInfo testMethod, ISpecimenBuilderFactory builderFactory ) : IEnumerable
testMethod IMethodInfo /// Information about a test method. ///
builderFactory ISpecimenBuilderFactory /// A factory of test fixture. ///
return IEnumerable
        public IEnumerable<ITestCommand> Create(IMethodInfo testMethod, ISpecimenBuilderFactory builderFactory)
        {
            foreach (var factory in this.factories)
            {
                int count = 0;
                var testCommands = factory.Create(testMethod, builderFactory);
                foreach (var testCommand in testCommands)
                {
                    count++;
                    yield return testCommand;
                }

                if (count != 0)
                    yield break;
            }
        }

Usage Example

        public void CreateShouldNotCreateAnyCommandsWhenReturningEnumerable()
        {
            var factory1 = Mocked.Of<ITestCommandFactory>();
            var factory2 = Mocked.Of<ITestCommandFactory>();
            var sut = new CompositeTestCommandFactory(factory1, factory2);

            sut.Create(Mocked.Of<IMethodInfo>(), Mocked.Of<ISpecimenBuilderFactory>());

            factory1.ToMock().Verify(
                x => x.Create(It.IsAny<IMethodInfo>(), It.IsAny<ISpecimenBuilderFactory>()), Times.Never());
            factory2.ToMock().Verify(
                x => x.Create(It.IsAny<IMethodInfo>(), It.IsAny<ISpecimenBuilderFactory>()), Times.Never());
        }
All Usage Examples Of Jwc.Experiment.Xunit.CompositeTestCommandFactory::Create
CompositeTestCommandFactory