Пример #1
0
        protected override ITestFixture Create(ITestMethodContext context)
        {
            var customization = new CompositeCustomization(
                new AutoMoqCustomization(),
                new TestParametersCustomization(context.ActualMethod.GetParameters()));

            return new TestFixture(new Fixture().Customize(customization));
        }
Пример #2
0
        /// <summary>
        /// Gets test arguments.
        /// </summary>
        /// <param name="context">
        /// Information of the test method.
        /// </param>
        /// <returns>
        /// The test arguments.
        /// </returns>
        public IEnumerable<object> GetArguments(ITestMethodContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            var parameters = context.ActualMethod.GetParameters();
            var explicitArguments = this.arguments.ToArray();

            if (explicitArguments.Length > parameters.Length)
                throw new InvalidOperationException(string.Format(
                    CultureInfo.CurrentCulture,
                    "Expected {0} parameters, got {1} parameters",
                    parameters.Length,
                    explicitArguments.Length));

            if (explicitArguments.Length == parameters.Length)
                return explicitArguments;

            var fixture = this.factory.Create(context);
            var autoArguments = parameters.Skip(explicitArguments.Length)
                .Select(p => fixture.CreateAnonymous(p));

            return explicitArguments.Concat(autoArguments);
        }
 public ISpecimenBuilder Create(ITestMethodContext context)
 {
     return new Fixture();
 }
Пример #4
0
        /// <summary>
        /// Executes a test method.
        /// </summary>
        /// <param name="testMethodContext">The test method to execute.</param>
        /// <returns>An array of TestResult objects that represent the outcome(s) of the test.</returns>
        /// <remarks>Extensions can override this method to customize running a TestMethod.</remarks>
        public virtual IEnumerable <TestResult> Execute(ITestMethodContext testMethodContext)
        {
            ThrowUtilities.NullArgument(testMethodContext, nameof(testMethodContext));

            return(testMethodContext.Invoke());
        }
Пример #5
0
 protected override ITestFixture Create(ITestMethodContext context)
 {
     return this.factory.Create(context);
 }
Пример #6
0
 protected override ISpecimenBuilder Create(ITestMethodContext context)
 {
     return new Fixture();
 }
Пример #7
0
 /// <summary>
 /// Creates a specimen builder.
 /// </summary>
 /// <param name="context">
 /// The test information about a test method.
 /// </param>
 /// <returns>
 /// The specimen builder.
 /// </returns>
 protected abstract ISpecimenBuilder Create(ITestMethodContext context);
Пример #8
0
 ISpecimenBuilder ISpecimenBuilderFactory.Create(ITestMethodContext context)
 {
     return this.Create(context);
 }
Пример #9
0
 protected override ISpecimenBuilder Create(ITestMethodContext context)
 {
     var fixture = new Fixture();
     fixture.Inject("custom string");
     fixture.Inject(5678);
     return fixture;
 }