private void UserAccountOptionsBuilder(IFakeOptions <ei_infrastructure.Data.POCOs.UserAccount> fakeOptions)
 {
     fakeOptions.ConfigureFake(userAccount =>
     {
         userAccount.Username = RandomString(10);
         userAccount.Password = RandomString(6);
     });
 }
        /// <summary>
        /// Makes the fake default to calling base methods, so long as they aren't abstract.
        /// </summary>
        /// <param name="options">Options used to create the fake object.</param>
        /// <returns>An options object.</returns>
        public static IFakeOptions CallsBaseMethods(this IFakeOptions options)
        {
            Guard.AgainstNull(options, nameof(options));

            return(options.ConfigureFake(fake => A.CallTo(fake)
                                         .Where(call => !call.Method.IsAbstract)
                                         .CallsBaseMethod()));
        }
示例#3
0
            public void BuildOptions(Type typeOfFake, IFakeOptions options)
            {
                if (options == null)
                {
                    return;
                }

                options.ConfigureFake(fake => ((TypeWithOptionsBuilders)fake).WasConfigured = true);
            }
示例#4
0
            protected override void BuildOptions(IFakeOptions <SomeClass> options)
            {
                if (options == null)
                {
                    throw new ArgumentNullException(nameof(options));
                }

                options.ConfigureFake(fake => fake.IsConfigured = true);
            }
示例#5
0
            public void BuildOptions(Type typeOfFake, IFakeOptions options)
            {
                if (options == null)
                {
                    return;
                }

                options.ConfigureFake(fake => A.CallTo(() => ((TypeWithDummyFactory)fake).WasConfigured).Returns(true));
            }
        /// <summary>
        /// Makes the fake strict. This means that any call to the fake
        /// that has not been explicitly configured will throw an exception.
        /// </summary>
        /// <param name="options">Options used to create the fake object.</param>
        /// <returns>An options object.</returns>
        public static IFakeOptions Strict(this IFakeOptions options)
        {
            Guard.AgainstNull(options, nameof(options));

            return(options.ConfigureFake(fake =>
            {
                var manager = Fake.GetFakeManager(fake);
                manager.AddRuleFirst(new StrictFakeRule());
            }));
        }
示例#7
0
        /// <summary>
        /// Makes the fake strict. This means that any call to the fake
        /// that has not been explicitly configured will throw an exception,
        /// except calls to the <see cref="object"/> methods specified
        /// in <paramref name="strictOptions"/>.
        /// </summary>
        /// <typeparam name="T">The type of fake object.</typeparam>
        /// <param name="options">Options used to create the fake object.</param>
        /// <param name="strictOptions">Strict fake options.</param>
        /// <returns>An options object.</returns>
        public static IFakeOptions <T> Strict <T>(this IFakeOptions <T> options, StrictFakeOptions strictOptions) where T : class
        {
            Guard.AgainstNull(options, nameof(options));

            return(options.ConfigureFake(fake =>
            {
                var manager = Fake.GetFakeManager(fake);
                manager.AddRuleFirst(new StrictFakeRule(strictOptions));
            }));
        }
        /// <summary>
        /// Makes the fake strict. This means that any call to the fake
        /// that has not been explicitly configured will throw an exception.
        /// </summary>
        /// <param name="options">Options used to create the fake object.</param>
        /// <returns>An options object.</returns>
        public static IFakeOptions Strict(this IFakeOptions options)
        {
            Guard.AgainstNull(options, nameof(options));

            Action <IFakeObjectCall> thrower = call =>
            {
                throw new ExpectationException(ExceptionMessages.CallToUnconfiguredMethodOfStrictFake(call));
            };

            return(options.ConfigureFake(fake => A.CallTo(fake).Invokes(thrower)));
        }
示例#9
0
        /// <summary>
        /// Makes the fake strict. This means that any call to the fake
        /// that has not been explicitly configured will throw an exception.
        /// </summary>
        /// <param name="optionsBuilder">Action that builds options used to create the fake object.</param>
        /// <returns>A configuration object.</returns>
        public static IFakeOptions Strict(this IFakeOptions optionsBuilder)
        {
            Guard.AgainstNull(optionsBuilder, "optionsBuilder");

            Action <IFakeObjectCall> thrower = call =>
            {
                throw new ExpectationException("Call to non configured method \"{0}\" of strict fake.".FormatInvariant(call.Method.Name));
            };

            return(optionsBuilder.ConfigureFake(fake => A.CallTo(fake).Invokes(thrower)));
        }
示例#10
0
        private void ApplyOptions <T>(IFakeOptions <T> options)
        {
            if (this._strict)
            {
                options.Strict();
            }

            if (this._configureFake != null)
            {
                options.ConfigureFake(x => this._configureFake(x));
            }
        }
示例#11
0
        private void ApplyOptions <T>(IFakeOptions <T> options)//IFakeOptionsBuilder<T> [to] IFakeOptions<T>
        {
            if (this._strict)
            {
                options.Strict();
            }

            if (this._onFakeCreated != null)
            {
                options.ConfigureFake(x => this._onFakeCreated(x));//OnFakeCreated(x=>) [to] ConfigureFake(x=>)
            }
        }
示例#12
0
        protected override void BuildOptions(IFakeOptions <RobotRunsAmokEvent> options)
        {
            if (options == null)
            {
                return;
            }

            options.ConfigureFake(fake =>
            {
                var robotRunsAmokEvent = fake;
                A.CallTo(() => robotRunsAmokEvent.CalculateTimestamp())
                .Returns(ConfiguredTimestamp);
                robotRunsAmokEvent.ID = -99;
            });
        }
示例#13
0
        private void ApplyOptions(IFakeOptions options)
        {
            if (this._strict)
            {
                options = options.Strict();
            }

            if (this._configureFake != null)
            {
                options = options.ConfigureFake(x => this._configureFake(x));
            }

            if (this._callsBaseMethods)
            {
                options.CallsBaseMethods();
            }
        }
示例#14
0
        public void BuildOptions(Type typeOfFake, IFakeOptions options)
        {
            if (options == null)
            {
                return;
            }

            options.ConfigureFake(fake =>
            {
                var domainEvent  = (DomainEvent)fake;
                domainEvent.ID   = this.nextID++;
                domainEvent.Name = typeOfFake.Name;
            })
            .WithAttributes(() => new ForTestAttribute())
            .Implements(typeof(IDisposable))
            .Implements <IComparable>();
        }
示例#15
0
        public void BuildOptions(Type typeOfFake, IFakeOptions options)
        {
            if (options == null)
            {
                return;
            }

            options.ConfigureFake(fake =>
            {
                var domainEvent  = (DomainEvent)fake;
                domainEvent.ID   = this.nextID++;
                domainEvent.Name = typeOfFake.Name;
            })
            .WithAdditionalAttributes(new[] { CreateCustomAttributeBuilder() })
            .Implements(typeof(IDisposable))
            .Implements <ICloneable>();
        }
            public void BuildOptions(Type typeOfFake, IFakeOptions options)
            {
                if (options == null)
                {
                    return;
                }

                options.ConfigureFake(fake => ((TypeWithOptionsBuilders)fake).WasConfigured = true);
            }