public IStoreItemAvailability CreateValidFor(IStore store) { var definition = new StoreItemAvailabilityDefinition { StoreId = store.Id, DefaultSectionId = commonFixture.ChooseRandom(store.Sections).Id }; return(Create(definition)); }
public void IsAvailableInStore_WithAvailableInStore_ShouldReturnTrue() { // Arrange IStoreItem storeItem = storeItemFixture.CreateValid(); var availabilityStoreIds = storeItem.Availabilities.Select(av => av.StoreId).ToList(); // Act StoreId chosenStoreId = commonFixture.ChooseRandom(availabilityStoreIds); bool result = storeItem.IsAvailableInStore(chosenStoreId); // Assert using (new AssertionScope()) { result.Should().BeTrue(); } }
public ShoppingListMock CreateValidShoppingListMock(IStoreItem storeItem) { var storeId = CommonFixture.ChooseRandom(storeItem.Availabilities).StoreId; var listDef = new ShoppingListDefinition { StoreId = storeId }; var list = ShoppingListFixture.CreateValid(listDef); return(new ShoppingListMock(list)); }
public object Create(object request, ISpecimenContext context) { if (!(request is TEnum)) { return(new NoSpecimen()); } var values = ((TEnum[])Enum.GetValues(typeof(TEnum))) .ToList(); return(commonFixture.ChooseRandom(values)); }
public IEnumerable <IStoreItemAvailability> CreateAvailabilitiesWithDuplicatedStoreIds() { var availabilities = StoreItemAvailabilityFixture.CreateManyValid().ToList(); var def = new StoreItemAvailabilityDefinition { StoreId = CommonFixture.ChooseRandom(availabilities).StoreId }; availabilities.Add(StoreItemAvailabilityFixture.Create(def)); return(availabilities); }
public IEnumerable <IStoreItem> CreateItems(IStore store) { List <StoreItemDefinition> definitions = new List <StoreItemDefinition>(); for (int i = 0; i < 2; i++) { var availabilityDef = new StoreItemAvailabilityDefinition { StoreId = store.Id, DefaultSectionId = CommonFixture.ChooseRandom(store.Sections).Id }; var availability = StoreItemAvailabilityFixture.Create(availabilityDef); var def = new StoreItemDefinition { Availabilities = availability.ToMonoList() }; definitions.Add(def); } return(StoreItemFixture.CreateMany(definitions)); }
public IShoppingListItem GetRandomItem(CommonFixture commonFixture, Func <IShoppingListItem, bool> condition) { var filteredItems = Object.Items.Where(condition); return(commonFixture.ChooseRandom(filteredItems)); }
public IShoppingListItem GetRandomItem(CommonFixture commonFixture) { return(commonFixture.ChooseRandom(Object.Items)); }
public void AddItem_WithItemIdIsAlreadyOnList_ShouldThrowDomainException() { // Arrange var shoppingList = shoppingListFixture.CreateValid(); int collidingItemId = commonFixture.ChooseRandom(shoppingList.Items).Id.Value; var collidingItem = shoppingListItemFixture.Create(new ItemId(collidingItemId)); SectionId sectionId = new SectionId(commonFixture.NextInt()); // Act Action action = () => shoppingList.AddItem(collidingItem, sectionId); // Assert using (new AssertionScope()) { action.Should().Throw <DomainException>() .Where(e => e.Reason.ErrorCode == ErrorReasonCode.ItemAlreadyOnShoppingList); } }