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>()); }
public IStoreItem CreateValid(StoreItemDefinition baseDefinition) { baseDefinition.IsTemporary ??= false; baseDefinition.IsDeleted ??= false; baseDefinition.Availabilities ??= storeItemAvailabilityFixture.CreateManyValid(); return(Create(baseDefinition)); }
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)); } }
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)); }
public StoreItemMock Create(StoreItemDefinition definition) { return(CreateMany(definition.ToMonoList()).First()); }