public void Construct_ForTypeLazyClass_Instance( )
        {
            _generator.CreateArgument(_typeClass)
            .Returns(_instance);

            var actual = CreateSut( ).Construct(_generator,
                                                _typeClass);

            using (new AssertionScope( ))
            {
                actual.Should( )
                .NotBeNull( );

                var lazy = actual as Lazy <Something>;

                lazy.Should( )
                .NotBeNull( );

                lazy?.IsValueCreated
                .Should( )
                .BeFalse( );

                var lazyValue = lazy?.Value;

                lazyValue?.Should( )
                .Be(_instance);
            }
        }
        public void Construct_ForTypeClass_Instance( )
        {
            _generator.CreateArgument(_typeClass)
            .Returns(_instance);

            CreateSut( ).Construct(_generator,
                                   _typeClass).Should( )
            .Be(_instance);
        }
        private object CreateInstance(IArgumentsGenerator generator,
                                      Type type)
        {
            try
            {
                return(generator.CreateArgument(type));
            }
            catch (Exception e)
            {
                if (!_finder.TryFindArgumentNullException(e, out var nullException))
                {
                    throw;
                }

                throw nullException;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Create the SUT using the pre-registered parameters of the
 ///     <see cref="AutoDataTestMethodAttribute" /> method and create all
 ///     the missing additional parameters using AutoFixture.
 /// </summary>
 /// <param name="generator">
 ///     The generator is used to create the SUT.
 /// </param>
 /// <param name="type">
 ///     The type of the service under test to be created.
 /// </param>
 /// <returns></returns>
 private static object CreateSut(IArgumentsGenerator generator,
                                 Type type)
 {
     return(generator.CreateArgument(type));
 }