public void ShouldAddTenAdvicesToIngredientAndThenRemoveFive() { var ingredient = IngredientBuilder.BuildIngredient(); _ingredientRepository.Add(ingredient); _ingredientRepository.Persist(); for (int i = 0; i < 10; i++) { var newAdvice = AdviceBuilder.BuildAdvice <IngredientAdvice>("Advice_" + i); ingredient.AddAdvice(newAdvice); _ingredientRepository.Persist(); } var advices = _ingredientRepository.FindOne(i => i != null).IngredientAdvices; for (int i = 0; i < 5; i++) { var indexCopy = i; var adviceToDelete = _ingredientAdviceRepository.FindOne(a => a == advices[indexCopy]); _ingredientAdviceRepository.Delete(adviceToDelete); _ingredientAdviceRepository.Persist(); } _ingredientRepository.Refresh(ingredient); _ingredientRepository.FindOne(i => i != null).IngredientAdvices.Count.ShouldEqual(5); using (var dataContext = GetNewDataContext()) { var result = dataContext.GetTableForType(typeof(IngredientAdvice)).OfType <IngredientAdvice>().ToList(); result.Count.ShouldEqual(5); } }
protected override void Before_all_specs() { SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly); IConfiguration configuration = new BasicConfiguration(); var container = configuration.Container; _ingredientRepository = new IngredientRepository(GetNewDataContext()); _semaphoreRepository = new Repository <Semaphore>(GetNewDataContext()); _mentorRepository = new Repository <Mentor>(GetNewDataContext()); _ingredientAdviceRepository = new Repository <IngredientAdvice>(GetNewDataContext()); _ingredientAdviceDomainService = new IngredientAdviceDomainService(_ingredientRepository, _ingredientAdviceRepository, GetNewDataContext()); _mentor = MentorBuilder.BuildMentor(); _mentorRepository.Add(_mentor); _mentorRepository.Persist(); _redSemaphore = SemaphoreBuilder.BuildRedSemaphore(); _semaphoreRepository.Add(_redSemaphore); _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore(); _semaphoreRepository.Add(_greenSemaphore); _semaphoreRepository.Persist(); _ingredient = IngredientBuilder.BuildIngredient(); _ingredientRepository.Add(_ingredient); _ingredientRepository.Persist(); base.Before_each_spec(); }
public void ShouldAddIngredient() { var ingredient = IngredientBuilder.BuildIngredient(); _ingredientRepository.Add(ingredient); _ingredientRepository.Persist(); _ingredientRepository.FindOne(i => i != null).IngredientName.ShouldEqual(ingredient.IngredientName); using (var dataContext = GetNewDataContext()) { var result = dataContext.GetTable <Ingredient>().Single(i => i != null); result.IngredientName.ShouldEqual(ingredient.IngredientName); } }
private void _bindIngredients <TTarget>(IngredientBuilder <TTarget> builder, ShopProduct product, ShopIngredient ingredient) where TTarget : class { var ingredientBuilder = builder .Cost(ingredient.Price) .Tweakable(ingredient.Tweakable) .DisplayName(ingredient.Name) .DefaultAmount(ingredient.Amount) .Id(product.Guid + "_" + ingredient.Name); foreach (var effect in ingredient.Effects) { ingredientBuilder.Effect(ProductShopUtility.ConvertEffectType(effect.Type), effect.Amount); } }
public void ShouldDeleteIngredient() { var ingredient = IngredientBuilder.BuildIngredient(); _ingredientRepository.Add(ingredient); _ingredientRepository.Persist(); _ingredientRepository.Delete(ingredient); _ingredientRepository.Persist(); _ingredientRepository.Find(i => i != null).Count().ShouldEqual(0); using (var dataContext = GetNewDataContext()) { var result = dataContext.GetTable <Ingredient>().ToList(); result.Count.ShouldEqual(0); } }
public MainWindow() { InitializeComponent(); Recipe recipe1 = RecipeBuilder.Builder() .withName("Test1") .withCategories(Category.BREAKFAST, Category.DRINK) .withIngredients(IngredientBuilder.Builder() .WithName("JAJCA") .WithQuantity(2) .WithUnit(Unit.PIECE) .Build(), IngredientBuilder.Builder() .WithName("Mleko") .WithQuantity(2) .WithUnit(Unit.GLASS) .Build()) .withPortions(2) .build(); Recipe recipe2 = RecipeBuilder.Builder() .withName("Test2") .withCategories(Category.LUNCH, Category.VEGETARIAN) .withIngredients(IngredientBuilder.Builder() .WithName("JAJCA") .WithQuantity(2) .WithUnit(Unit.PIECE) .Build(), IngredientBuilder.Builder() .WithName("Mleko") .WithQuantity(2) .WithUnit(Unit.GLASS) .Build()) .withPortions(2) .build(); RecipeManager = new RecipeManager(this); RecipeManager.Recipes.Add(recipe1); RecipeManager.Recipes.Add(recipe2); this.Categories.ItemsSource = Enum.GetValues(typeof(Category)).Cast <Category>(); }
public void ShouldAddTenAdvicesToIngredient() { var ingredient = IngredientBuilder.BuildIngredient(); _ingredientRepository.Add(ingredient); _ingredientRepository.Persist(); for (int i = 0; i < 10; i++) { var newAdvice = AdviceBuilder.BuildAdvice <IngredientAdvice>("Advice_" + i); ingredient.AddAdvice(newAdvice); _ingredientRepository.Persist(); } _ingredientRepository.FindOne(i => i != null).IngredientAdvices.Count.ShouldEqual(10); using (var dataContext = GetNewDataContext()) { var result = dataContext.GetTableForType(typeof(IngredientAdvice)).OfType <IngredientAdvice>().ToList(); result.Count.ShouldEqual(10); } }
protected override void Before_all_specs() { SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly); _productRepository = new ProductRepository(GetNewDataContext()); _productApplicationService = new ProductApplicationService(null, null, null, null, null); _brand = BrandBuilder.BuildBrand(); using (var brandRepository = new Repository <Brand>(GetNewDataContext())) { brandRepository.Add(_brand); brandRepository.Persist(); } _country = CountryBuilder.BuildCountry(); using (var countryRepository = new Repository <Country>(GetNewDataContext())) { countryRepository.Add(_country); countryRepository.Persist(); } _mentor = MentorBuilder.BuildMentor(); _certificationMark = CertificationMarkBuilder.BuildCertificationMark(_mentor); using (var certificationMarkRepository = new Repository <CertificationMark>(GetNewDataContext())) { certificationMarkRepository.Add(_certificationMark); certificationMarkRepository.Persist(); } _ingredient = IngredientBuilder.BuildIngredient(); using (var ingredientRepository = new Repository <Ingredient>(GetNewDataContext())) { ingredientRepository.Add(_ingredient); ingredientRepository.Persist(); } }
public void JsonRepository_Create_With_Ingredients_Succeeds() { var ingredient = new IngredientBuilder() .With(1) .With("Test Ingredient") .Build(); var recipe = new RecipeBuilder() .With("Test with ingredients", "Has Ingredients", 1.5) .Has(ingredient, 1, "ml") .Build(); var repo = new JsonRepository(); repo .Create(recipe) .SaveChanges(); repo = new JsonRepository(); var added = repo.Recipes.Single(r => r.Id == recipe.Id); Assert.AreEqual(1, added.Ingredients.Count); Assert.AreEqual(1, added.Ingredients.Single().Quantity); }