Exemple #1
0
 public override void OneTimeSetup()
 {
     _enumGeneratorInstanceType    = typeof(EnumGenerator);
     _enumGeneratorInstanceFixture = this.Create <EnumGenerator>(true);
     _enumGeneratorInstance        = _enumGeneratorInstanceFixture ?? this.Create <EnumGenerator>(false);
     CurrentInstance = _enumGeneratorInstanceFixture;
     ConfigureIgnoringTests(); // Configure ignoring tests.
 }
Exemple #2
0
        public void AUT_EnumGenerator_Instantiated_Without_Parameter_No_Throw_Exception_Test()
        {
            // Arrange
            EnumGenerator instance = null;

            // Act
            var exception = CreateAnalyzer.GetThrownExceptionWhenCreate(out instance);

            // Assert
            instance.ShouldNotBeNull();
            exception.ShouldBeNull();
        }
Exemple #3
0
        /// <summary>
        /// Creates a new enum value based on a request.
        /// </summary>
        /// <param name="request">The request that describes what to create.</param>
        /// <param name="context">
        /// A context that can be used to create other specimens. Not used.
        /// </param>
        /// <returns>
        /// An enum value if appropriate; otherwise a <see cref="NoSpecimen"/> instance.
        /// </returns>
        /// <remarks>
        /// <para>
        /// If <paramref name="request"/> is a <see cref="Type"/> that represents an enum, an
        /// instance of that enum is returned. Differing values are returned, starting with the
        /// first value. When all values of the enum type have been served, the sequence starts
        /// over again.
        /// </para>
        /// </remarks>
        public object Create(object request, ISpecimenContext context)
        {
            var t = request as Type;

            if (!EnumGenerator.IsEnumType(t))
            {
                return(new NoSpecimen());
            }

            lock (this.syncRoot)
            {
                return(this.CreateValue(t));
            }
        }