public void TestDeleteBerlet() { BERLET b = this.Passes.Single(x => x.BERLET_ID == 1); int expected = this.Workers.Count - 1; this.LogicTester.DeleteBerlet(b); Assert.That(this.LogicTester.ReadBerlet().Count, Is.EqualTo(expected)); Assert.That(this.LogicTester.ReadBerlet().Where(x => x.BERLET_ID == 1).Count, Is.EqualTo(0)); this.BerletMoq.Verify(x => x.Read(), Times.Exactly(3)); this.BerletMoq.Verify(x => x.Delete(It.IsAny <BERLET>()), Times.Once); }
public void TestAddBerlet() { BERLET berlet = new BERLET { BERLET_ID = 4, MEGNEVEZES = "proba4", AR = 1000, KEDVEZMENY_TIPUS = "nincs", ERVENYESSEG_IDO = 15, BERLET_FORMATUM = "papír" }; int expected = this.Passes.Count + 1; this.LogicTester.CreateBerlet(berlet); Assert.That(this.LogicTester.ReadBerlet().Count, Is.EqualTo(expected)); Assert.That(this.LogicTester.ReadBerlet().Single(x => x.BERLET_ID == 4), Is.EqualTo(berlet)); this.BerletMoq.Verify(x => x.Add(It.IsAny <BERLET>()), Times.Once); }
public void TestModifyBerlet() { BERLET b = this.Passes.Single(x => x.BERLET_ID == 1); this.LogicTester.UpdateBerlet(b); b.BERLET_ID = 1; b.MEGNEVEZES = "Ujproba1"; b.AR = 500; b.KEDVEZMENY_TIPUS = "nincs"; b.ERVENYESSEG_IDO = 1; b.BERLET_FORMATUM = "elektronikus"; Assert.That(this.LogicTester.ReadBerlet().Single(x => x.BERLET_ID == 1).MEGNEVEZES, Is.EqualTo("Ujproba1")); this.BerletMoq.Verify(x => x.Read(), Times.Once); this.BerletMoq.Verify(x => x.Modify(1, b), Times.Once); }
/// <summary> /// Represents a list of the CRUD methods of the Passes. /// </summary> public static void BerletCRUDs() { Console.Clear(); Console.WriteLine("0) Back"); Console.WriteLine("1) Listázás"); Console.WriteLine("2) Hozzáadás"); Console.WriteLine("3) Módosítás"); Console.WriteLine("4) Törlés"); BERLET berlet = new BERLET(); ConsoleKeyInfo cki; cki = Console.ReadKey(true); switch (cki.KeyChar.ToString()) { case "1": foreach (var item in l.ReadBerlet()) { Console.WriteLine(item.BERLET_ID + "\t" + item.MEGNEVEZES + "\t" + item.AR + "\t" + item.ERVENYESSEG_IDO + "\t" + item.KEDVEZMENY_TIPUS + "\t" + item.BERLET_FORMATUM); } Console.WriteLine("Hit an 'ENTER' to go back to main menu."); Console.ReadLine(); break; case "2": bool jo = true; while (jo) { try { Console.Write("Bérlet ID: "); berlet.BERLET_ID = int.Parse(Console.ReadLine()); Console.Write("Megnevezés: "); berlet.MEGNEVEZES = Console.ReadLine(); Console.Write("Ár: "); berlet.AR = int.Parse(Console.ReadLine()); Console.Write("Érvényességi idő: "); berlet.ERVENYESSEG_IDO = int.Parse(Console.ReadLine()); Console.Write("Kedvezmény típus: "); berlet.KEDVEZMENY_TIPUS = Console.ReadLine(); Console.Write("Bérlet formátum: "); berlet.BERLET_FORMATUM = Console.ReadLine(); l.CreateBerlet(berlet); jo = false; } catch (FormatException) { Console.WriteLine("Rossz formátumban adta meg az adatokat. ÚjraPróbálkozik? [y / n]:"); if (Console.ReadLine() == "y") { jo = true; } else { jo = false; } } } Console.WriteLine("Hit an 'ENTER' to go back to main menu."); Console.ReadLine(); break; case "3": foreach (var item in l.ReadBerlet()) { Console.WriteLine(item.BERLET_ID + "\t" + item.MEGNEVEZES + "\t" + item.AR + "\t" + item.ERVENYESSEG_IDO + "\t" + item.KEDVEZMENY_TIPUS + "\t" + item.BERLET_FORMATUM); } bool ok = true; while (ok) { try { Console.WriteLine("Adja meg a módosítani kívánt tétel 'ID'-jét:"); int id = int.Parse(Console.ReadLine()); ok = false; bool van = false; foreach (var item in l.ReadBerlet()) { if (item.BERLET_ID == id) { Console.WriteLine(item.BERLET_ID + "\t" + item.MEGNEVEZES + "\t" + item.AR + "\t" + item.ERVENYESSEG_IDO + "\t" + item.KEDVEZMENY_TIPUS + "\t" + item.BERLET_FORMATUM); van = true; } } if (van) { Console.Write("Bérlet ID: "); berlet.BERLET_ID = int.Parse(Console.ReadLine()); Console.Write("Bérlet megnevezése: "); berlet.MEGNEVEZES = Console.ReadLine(); Console.Write("Bérlet ára: "); berlet.AR = int.Parse(Console.ReadLine()); Console.Write("Érvényességi ideje: "); berlet.ERVENYESSEG_IDO = int.Parse(Console.ReadLine()); Console.Write("Kedvezmény típusa: "); berlet.KEDVEZMENY_TIPUS = Console.ReadLine(); Console.Write("Bérlet formátuma: "); berlet.BERLET_FORMATUM = Console.ReadLine(); l.UpdateBerlet(berlet); ok = false; } } catch (FormatException) { Console.WriteLine("Rossz formátumban adta meg az adatokat. ÚjraPróbálkozik? [y / n]:"); if (Console.ReadLine() == "y") { ok = true; } else { ok = false; } } } Console.WriteLine("Hit an 'ENTER' to go back to main menu."); Console.ReadLine(); break; case "4": bool ex = true; while (ex) { try { Console.WriteLine("Törlendő ID-je: "); berlet.BERLET_ID = int.Parse(Console.ReadLine()); l.DeleteBerlet(berlet); ex = false; } catch (FormatException) { Console.WriteLine("Rossz formátumban adta meg az adatokat. ÚjraPróbálkozik? [y / n]:"); if (Console.ReadLine() == "y") { ex = true; } else { ex = false; } } } Console.WriteLine("Hit an 'ENTER' to go back to main menu."); Console.ReadLine(); break; case "0": Console.Clear(); break; } }
/// <inheritdoc/> public void CreateBerlet(BERLET b) { this.berlet.Add(b); }
/// <inheritdoc/> public void UpdateBerlet(BERLET berlet) { this.berlet.Modify(berlet.BERLET_ID, berlet); }
/// <inheritdoc/> public void DeleteBerlet(BERLET b) { b = this.berlet.Read().FirstOrDefault(u => u.BERLET_ID == b.BERLET_ID); this.berlet.Delete(b); }