public static string WithRecipe(this TestCompositionRoot root, string name, string ingredients = null, string directions = null, int?servings = null, string source = null, int?rating = null, string category = null, string id = null) { var context = root.Get <RecipeBookDbContext>(); var entity = new entityframework.Models.Recipe { Id = id ?? Guid.NewGuid().ToString(), Name = name, Ingredients = ingredients, Directions = directions, Servings = servings, Source = source, Rating = rating, Category = category }; context.Recipes.Add(entity); context.SaveChanges(); return(entity.Id); }
public static void WithCategory(this TestCompositionRoot root, string name) { var context = root.Get <RecipeBookDbContext>(); var category = new entityframework.Models.Category { Id = Guid.NewGuid().ToString(), Name = name }; context.Categories.Add(category); context.SaveChanges(); }
public static entityframework.Person WithPerson(this TestCompositionRoot root, string firstName = "my-first-name", string lastName = "my-last-name", string alias = null, DateTime?birthDate = null) { var context = root.Get <MyServiceContext>(); var person = new Person { FirstName = firstName, LastName = lastName, Alias = alias ?? $"{firstName.Substring(0,1)}{lastName}".ToLower(), BirthDate = birthDate ?? DateTime.Now.AddYears(-25) }; context.Person.Add(person); context.SaveChanges(); return(person); }