예제 #1
0
        public IStoreItem Create(StoreItemDefinition definition)
        {
            var fixture = commonFixture.GetNewFixture();

            if (definition.Id != null)
            {
                fixture.ConstructorArgumentFor <StoreItem, ItemId>("id", definition.Id);
            }
            if (definition.IsDeleted.HasValue)
            {
                fixture.ConstructorArgumentFor <StoreItem, bool>("isDeleted", definition.IsDeleted.Value);
            }
            if (definition.IsTemporary.HasValue)
            {
                fixture.ConstructorArgumentFor <StoreItem, bool>("isTemporary", definition.IsTemporary.Value);
            }
            if (definition.UseItemCategoryId)
            {
                fixture.ConstructorArgumentFor <StoreItem, ItemCategoryId>("itemCategoryId", definition.ItemCategoryId);
            }
            if (definition.UseManufacturerId)
            {
                fixture.ConstructorArgumentFor <StoreItem, ManufacturerId>("manufacturerId", definition.ManufacturerId);
            }
            if (definition.Availabilities != null)
            {
                fixture.ConstructorArgumentFor <StoreItem, IEnumerable <IStoreItemAvailability> >(
                    "availabilities", definition.Availabilities);
            }

            return(fixture.Create <StoreItem>());
        }
예제 #2
0
        public IStoreItem CreateValid(StoreItemDefinition baseDefinition)
        {
            baseDefinition.IsTemporary ??= false;
            baseDefinition.IsDeleted ??= false;
            baseDefinition.Availabilities ??= storeItemAvailabilityFixture.CreateManyValid();

            return(Create(baseDefinition));
        }
예제 #3
0
        public IEnumerable <StoreItemMock> CreateMany(int amount)
        {
            var uniqueIds = commonFixture.NextUniqueInts(amount);

            foreach (var id in uniqueIds)
            {
                var baseDefinition = StoreItemDefinition.FromId(new ItemId(id));
                var storeItem      = storeItemFixture.CreateValid(baseDefinition);
                yield return(new StoreItemMock(storeItem));
            }
        }
예제 #4
0
        public IStoreItem CreateValidFor(IShoppingList shoppingList)
        {
            var storeDefinition = StoreDefinition.FromId(shoppingList.StoreId);
            var store           = storeFixture.Create(storeDefinition);

            var availabilities = storeItemAvailabilityFixture.CreateManyValidWith(store, 4);
            var definition     = new StoreItemDefinition
            {
                Availabilities = availabilities
            };

            return(CreateValid(definition));
        }
예제 #5
0
 public StoreItemMock Create(StoreItemDefinition definition)
 {
     return(CreateMany(definition.ToMonoList()).First());
 }