Exemplo n.º 1
0
        private static List <Pool> GivenTestPools(IFixture fixture)
        {
            var pools = new List <Pool>();

            fixture.RepeatCount = 2;
            fixture.AddManyTo(pools);
            return(pools);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds many anonymously created objects to a list.
        /// </summary>
        /// <typeparam name="T">The type of object that is contained in the list.</typeparam>
        /// <param name="fixture">The fixture.</param>
        /// <param name="collection">
        /// The list to which the anonymously created objects will be added.
        /// </param>
        /// <remarks>
        /// <para>
        /// The number of objects created and added is determined by
        /// <see cref="IFixture.RepeatCount"/>.
        /// </para>
        /// </remarks>
        /// <seealso cref="AddManyTo{T}(IFixture, ICollection{T}, int)"/>
        /// <seealso cref="AddManyTo{T}(IFixture, ICollection{T}, Func{T})"/>
        public static void AddManyTo <T>(this IFixture fixture, ICollection <T> collection)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException(nameof(fixture));
            }

            fixture.AddManyTo(collection, fixture.Create <T>);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds many anonymously created objects to a list.
        /// </summary>
        /// <typeparam name="T">The type of object that is contained in the list.</typeparam>
        /// <param name="fixture">The fixture.</param>
        /// <param name="collection">
        /// The list to which the anonymously created objects will be added.
        /// </param>
        /// <remarks>
        /// <para>
        /// The number of objects created and added is determined by
        /// <see cref="IFixture.RepeatCount"/>.
        /// </para>
        /// </remarks>
        /// <seealso cref="AddManyTo{T}(IFixture, ICollection{T}, int)"/>
        /// <seealso cref="AddManyTo{T}(IFixture, ICollection{T}, Func{T})"/>
        public static void AddManyTo <T>(this IFixture fixture, ICollection <T> collection)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }

            fixture.AddManyTo(collection, () => fixture.CreateAnonymous <T>());
        }
Exemplo n.º 4
0
        public void Customize(IFixture fixture)
        {
            Things = new List <Thing>();

            fixture.Register <IMyInterface>(() =>
            {
                var fake = new FakeMyInterface();
                Things
                .ToList()
                .ForEach(fake.AddThing);
                return(fake);
            });

            fixture.AddManyTo(Things);
        }
Exemplo n.º 5
0
        public async Task GetCars_Should_ReturnCars()
        {
            //arrange
            ICollection <RentalCar> ls = new List <RentalCar>();

            _fixture.RepeatCount = 10;
            _fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
            _fixture.Behaviors.Add(new OmitOnRecursionBehavior());
            _fixture.AddManyTo <RentalCar>(ls);

            _repoMock.Setup(x => x.GetCars(It.IsAny <Int32>(), It.IsAny <Int32>())).ReturnsAsync(ls);

            //act
            var cars = await _testService.GetCars(1, 20);

            var ls2 = _mapper.Map <IEnumerable <ReadRentalCarDto> >(ls);

            //assert
            cars.Should().BeEquivalentTo(ls2);
        }