public void GetUserBySub() { var user = new User() { UserId = 4, Username = "******", Auth0 = "Stuff" }; var result1 = new User(); var result2 = new User(); using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.Add(user); context.SaveChanges(); result2 = context.Users.FirstOrDefault(u => u.Auth0 == user.Auth0); } using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureCreated(); var msr = new KitchenRepository(context); result1 = msr.GetUserDataBySub(user.Auth0); } Assert.Equal(result1.Username, result2.Username); }
public AddRestaurantForm() { InitializeComponent(); _restaurantRepository = new RestaurantRepository(); _kitchenRepository = new KitchenRepository(); KitchenModelComboBox.SelectedIndex = 0; }
public UnitOfWork(MyDatabase context) { this.context = context; Cares = new CareRepository.CareRepository(context); FaceCreams = new FaceCreamRepository(context); Hairs = new HairRepository(context); Lotions = new LotionRepository(context); ShaveBeards = new ShaveBeardRepository(context); FoodHerbs = new FoodHerbRepository(context); Salts = new SaltRepository(context); Spices = new SpiceRepository(context); SproutingSeeds = new SproutingSeedRepository(context); Teas = new TeaRepository(context); Candles = new CandleRepository(context); EssentialOils = new EssentialOilRepository(context); Homes = new HomeRepository.HomeRepository(context); HomeCleanings = new HomeCleaningRepository(context); Kitchens = new KitchenRepository(context); PowerHealths = new PowerHealthRepository(context); SuperFoods = new SuperFoodRepository(context); Supplements = new SupplementRepository.SupplementRepository(context); Orders = new OrderRepository(context); Products = new ProductRepository(context); Users = new UserRepository(context); }
public void GetRecipeByID() { var recipe = new Recipe() { RecipeId = 4, RecipeAuthor = "Anis" }; var result1 = new Recipe(); var result2 = new Recipe(); using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context.Add(recipe); context.SaveChanges(); result2 = context.Recipes.Where(r => r.RecipeId == recipe.RecipeId) .Include(r => r.RecipeIngredients) .ThenInclude(ri => ri.Ingredient) .Include(r => r.RecipeTags) .ThenInclude(rt => rt.Tag) .Include(r => r.Steps) .Include(r => r.Reviews) .FirstOrDefault(); } using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureCreated(); var msr = new KitchenRepository(context); result1 = msr.GetRecipeById(recipe.RecipeId); } Assert.Equal(result1.RecipeAuthor, result2.RecipeAuthor); }
public async Task TestUserLogic() { User user = new User() { Auth0 = "authcode", Firstname = "fname", Lastname = "lname" }; AuthModel model = new AuthModel() { Sub = "authcode", FirstName = "fname", LastName = "lname", Email = "email", ProfileImage = "", Username = "******" }; Dictionary <string, string> userDictionary = new Dictionary <string, string>(); userDictionary["email"] = "email"; userDictionary["picture"] = "picture"; userDictionary["sub"] = "authcode"; bool result; bool isnew = false; using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeletedAsync(); context.Database.EnsureCreatedAsync(); var repo = new KitchenRepository(context); var userlogic = new UserLogic(context, repo); AuthModel outModel = null; isnew = userlogic.CheckIfNewUser(userDictionary, out outModel); userlogic.GetAllUsers(); } Assert.False(isnew); }
public void GetRecipes() { var reviews = new List <Recipe>(); var review1 = new Recipe() { RecipeId = 32, RecipeAuthor = "Anis", RecipeDescription = "Tacos" }; var review2 = new Recipe() { RecipeId = 320, RecipeAuthor = "Anis", RecipeDescription = "Tacos" }; reviews.Add(review1); reviews.Add(review2); var result1 = new List <Recipe>(); var result2 = new List <Recipe>(); using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeletedAsync(); context.Database.EnsureCreatedAsync(); context.Add(review1); context.Add(review2); context.SaveChanges(); result2 = context.Recipes .Include(r => r.RecipeIngredients) .ThenInclude(ri => ri.Ingredient) .Include(r => r.RecipeTags) .ThenInclude(rt => rt.Tag) .Include(r => r.Steps) .ToList(); } using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureCreatedAsync(); var msr = new KitchenRepository(context); result1 = (List <Recipe>)msr.GetAllRecipes(); } Assert.Equal(result1.Count, result2.Count); }
public void SaveUser() { var user = new User() { UserId = 4, Username = "******", Auth0 = "Stuff" }; var result1 = new User(); var result2 = new User(); using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var msr = new KitchenRepository(context); var newUser = msr.SaveNewUser(user, out result1); Assert.True(newUser); } }
public async Task GetReviews() { var reviews = new List <Review>(); var review1 = new Review() { RecipeId = 32, ReviewId = 3, ReviewDescription = "Tacos" }; var review2 = new Review() { RecipeId = 329, ReviewId = 3, ReviewDescription = "TacoBurrito" }; var review3 = new Review() { RecipeId = 320, ReviewId = 3, ReviewDescription = "Tacos" }; var result1 = new List <Review>(); var result2 = new List <Review>(); using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); result2 = await context.Reviews.Where(r => r.RecipeId == 3) .Include(r => r.User) .ToListAsync(); } using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureCreated(); var msr = new KitchenRepository(context); result1 = await msr.GetReviewsByRecipeId(3); } Assert.Equal(result1, result2); }
public Authenticator(IConfiguration _configuration, KitchenRepository _repo, Auth0HttpRequestHandler _handler) { this._configuration = _configuration; this._repo = _repo; this._handler = _handler; }
public UserLogic(InTheKitchenDBContext _context, KitchenRepository _repo) { this._context = _context; this._repo = _repo; // this._handler = _handler; }
public KitchenLogic(InTheKitchenDBContext _context, KitchenRepository _repo) { this._context = _context; this._repo = _repo; }
public KitchenController() { KitchenRepository = new KitchenRepository(); }
public ReviewStepTagLogic(InTheKitchenDBContext _context, KitchenRepository _repo) { this._context = _context; this._repo = _repo; }
public KitchensController(KitchenRepository repo) { _repo = repo; }
public async Task TestRecipeSaving() { // var tag = new Recipe() { TagId = 123, TagName = "Cheese" }; var sentrecipe = new SentRecipe(); var date = DateTime.Now; sentrecipe.DateCreated = date; sentrecipe.DateLastPrepared = date; Tag t = new Tag() { TagName = "tag name 2" }; Ingredient i = new Ingredient() { IngredientName = "ing name 2" }; Step s = new Step() { StepDescription = "new description", RecipeStepNo = 1 }; sentrecipe.ingredients = new List <Ingredient>() { new Ingredient() { IngredientName = "ingredient name" } }; sentrecipe.tags = new List <Tag>() { new Tag() { TagName = "tag name" } }; Step s1 = new Step() { StepDescription = "step description" }; sentrecipe.Steps = new List <Step>() { s1 }; User user = new User() { Auth0 = "authcode", Firstname = "fname", Lastname = "lname", DateCreated = date, Email = "email", ImageUrl = "picture" }; AuthModel model = new AuthModel() { Sub = "authcode", FirstName = "fname", LastName = "lname", Email = "email", ProfileImage = "picture", Username = "******" }; Dictionary <string, string> userDictionary = new Dictionary <string, string>(); userDictionary["email"] = "email"; userDictionary["picture"] = "picture"; userDictionary["sub"] = "authcode"; bool result; Recipe recipe = null; using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeletedAsync(); context.Database.EnsureCreatedAsync(); var repo = new KitchenRepository(context); var msr = new KitchenLogic(context, repo); var reviewlogic = new ReviewStepTagLogic(context, repo); var userlogic = new UserLogic(context, repo); userlogic.UpdateUser(model, userDictionary); userlogic.UpdateUser(model, userDictionary); var sr = await msr.saveRecipe(sentrecipe, model.Sub); sentrecipe.tags.Add(t); sentrecipe.ingredients.Add(i); sentrecipe.Steps.Add(s); sentrecipe.Steps.Remove(s1); sr = await msr.saveRecipe(sentrecipe, model.Sub); recipe = repo.GetRecipeById(sr.RecipeId); repo.UpdateUserAuth0Data(user); var rev = new Review() { Recipe = recipe, ReviewDate = date, ReviewDescription = "review description", RecipeId = recipe.RecipeId, }; reviewlogic.addReview(userDictionary["sub"], rev); HistoryModel hmodel = new HistoryModel() { recipeId = recipe.RecipeId, sub = model.Sub }; msr.SaveRecipePrepare(hmodel); } Assert.Equal(recipe.RecipeTags.ToArray()[0].Tag.TagName, "tag name"); }