public void Update_WithNonExistingMemoryOption_ShouldThrowError() { SetUp(); var mo = new MemoryOption(); Assert.ThrowsAny <Exception>(() => _memoryOptionService.Update(mo)); }
public void InsertMemoryOption_WithValidModel_ShouldBeInserted() { SetUp(); var memoryOption = new MemoryOption(); _memoryOptionService.InsertMemoryOption(memoryOption); Assert.Equal(memoryOption, _context.MemoryOptions.First()); }
private List <MemoryOption> GetMemoryOptions() { MemoryOption testMemoryOptionOne = new MemoryOption() { Model = "model1" }; MemoryOption testMemoryOptionTwo = new MemoryOption() { Model = "model2" }; return(new List <MemoryOption> { testMemoryOptionOne, testMemoryOptionTwo }); }
public IActionResult Create([Bind("RamId,Model,Manufacturer,MemoryType,MemoryCapacity,MemoryFrequency,Price")] MemoryOption memoryOption) { if (ModelState.IsValid) { var image = Request.Form.Files.GetFile("image"); if (image != null) { memoryOption.ImgUrl = _driveService.UploadFile(image); } else { memoryOption.ImgUrl = Constants.DEFAULT_MEMORY_IMG; } _service.InsertMemoryOption(memoryOption); return(RedirectToAction(nameof(Index))); } return(View(memoryOption)); }
public IActionResult Edit(int id, [Bind("RamId,Model,Manufacturer,MemoryType,MemoryCapacity,MemoryFrequency,Price")] MemoryOption memoryOption) { if (id != memoryOption.MemoryOptionId) { return(NotFound()); } if (ModelState.IsValid) { var image = Request.Form.Files.GetFile("image"); if (image != null) { _driveService.DeleteFile(Request.Form["ImgUrl"]); memoryOption.ImgUrl = _driveService.UploadFile(image); } _service.Update(memoryOption); return(RedirectToAction(nameof(Index))); } return(View(memoryOption)); }
async void GridView_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { var parentView = (FrameLayout)e.View; MemoryOption memoryCard = memoryCards[e.Position]; var cardBack = parentView.FindViewById <ImageView>(Resource.Id.ivCardBack); var cardPictureFront = parentView.FindViewById <ImageView>(Resource.Id.ivCardPictureFront); var cardTextFront = parentView.FindViewById <TextView>(Resource.Id.tvCardTextFront); if (cardBack.Visibility == ViewStates.Visible) { if (memoryCardsRevealed.Count < 2) { cardBack.Visibility = ViewStates.Gone; if (memoryCard.Media != null) { cardPictureFront.Visibility = ViewStates.Visible; SoundPlayer.PlaySound(Activity.BaseContext, memoryCard.Media.SoundPath); } else { cardTextFront.Visibility = ViewStates.Visible; } if (memoryCardsRevealed.Count == 1 && memoryCardsRevealed.ContainsKey(memoryCard.Name)) { var firstParentView = memoryCardsRevealed.Single().Value; memoryCardsRevealed.Clear(); parentView.Background = GetDrawable(Resource.Drawable.rectangle_green); firstParentView.Background = GetDrawable(Resource.Drawable.rectangle_green); await Task.Delay(1500); parentView.Visibility = ViewStates.Gone; firstParentView.Visibility = ViewStates.Gone; countOfPairsMatched++; CheckSolution(); } else { memoryCardsRevealed.Add(memoryCard.Name, parentView); } } else { foreach (var memoryCardRevealed in memoryCardsRevealed) { memoryCardRevealed.Value.Background = GetDrawable(Resource.Drawable.rectangle_red); memoryCardsMarked.Add(memoryCardRevealed.Value); } await Task.Delay(1000); foreach (var memoryCardMarked in memoryCardsMarked) { memoryCardMarked.Background = null; } memoryCardsMarked.Clear(); } } else { cardPictureFront.Visibility = ViewStates.Gone; cardTextFront.Visibility = ViewStates.Gone; cardBack.Visibility = ViewStates.Visible; memoryCardsRevealed.Remove(memoryCard.Name); } }
public void Update(MemoryOption memoryOption) { unitOfWork.MemoryOptionsRepository.Update(memoryOption); unitOfWork.Save(); }
public void InsertMemoryOption(MemoryOption memoryOption) { unitOfWork.MemoryOptionsRepository.Insert(memoryOption); unitOfWork.Save(); }