private void ListView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e) { var item = _instrumentRepository.Get().ElementAt(e.Position); if (item.Count > 0) { item.Count--; e.View.FindViewById <TextView>(Resource.Id.txtCount).Text = item.Count.ToString(); _instrumentRepository.Update(item); } Refresh(); }
public void UpdateInstrument_Successful() { //Arrange var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); IInstrumentRepository instrumentRepository = new InstrumentRepository(context); var instru = new InstrumentTO { Name = "Saxophone" }; var instru2 = new InstrumentTO { Name = "Trumpet" }; var instru3 = new InstrumentTO { Name = "Flute" }; var AddedInstru = instrumentRepository.Add(instru); var AddedInstru2 = instrumentRepository.Add(instru2); var AddedInstru3 = instrumentRepository.Add(instru3); context.SaveChanges(); //Act AddedInstru.Name = "PouetPouet"; var test = instrumentRepository.Update(AddedInstru); context.SaveChanges(); //Assert Assert.AreEqual(3, instrumentRepository.GetAll().Count()); Assert.AreEqual("PouetPouet", test.Name); }
private void GenerateFakeRates() { Random rand = new Random(); foreach (var instrument in m_instrumentRepository.GetInstruments()) { double d = Math.Round(rand.NextDouble() * (instrument.Max - instrument.Min) + instrument.Min, 4); instrument.Update(d); m_instrumentRepository.Update(instrument); } }
public void UpdateInstrument_ProvidingNonExistingCategory_ThrowException() { var options = new DbContextOptionsBuilder <LibraryContext>() .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name) .Options; using var context = new LibraryContext(options); IInstrumentRepository instrumentRepository = new InstrumentRepository(context); var instru = new InstrumentTO { Name = "Saxophone" }; //Act & Assert Assert.ThrowsException <ArgumentException>(() => instrumentRepository.Update(instru)); }