Beispiel #1
0
        public void TestDeleteCeg()
        {
            CEG c        = this.Companies.Single(x => x.CEG_ID == 11);
            int expected = this.Workers.Count - 1;

            this.LogicTester.DeleteCeg(c);
            Assert.That(this.LogicTester.ReadCeg().Count, Is.EqualTo(expected));
            Assert.That(this.LogicTester.ReadCeg().Where(x => x.CEG_ID == 11).Count, Is.EqualTo(0));
            this.CegMoq.Verify(x => x.Read(), Times.Exactly(3));
            this.CegMoq.Verify(x => x.Delete(It.IsAny <CEG>()), Times.Once);
        }
Beispiel #2
0
        public void TestAddCeg()
        {
            CEG ceg = new CEG {
                CEG_ID = 14, ADOSZAM = 444444, CEGNEV = "Negyedik Ceg", ALAPITAS_DATUMA = DateTime.Parse("1941.03.01."), JEGYZETT_TOKE = 600000, SZEKHELY = "Budapest"
            };
            int expected = this.Companies.Count + 1;

            this.LogicTester.CreateCeg(ceg);
            Assert.That(this.LogicTester.ReadCeg().Count, Is.EqualTo(expected));
            Assert.That(this.LogicTester.ReadCeg().Single(x => x.CEG_ID == 14), Is.EqualTo(ceg));
            this.CegMoq.Verify(x => x.Add(It.IsAny <CEG>()), Times.Once);
        }
Beispiel #3
0
        public void TestModifyCeg()
        {
            CEG c = this.Companies.Single(x => x.CEG_ID == 11);

            this.LogicTester.UpdateCeg(c);
            c.CEG_ID          = 11;
            c.ADOSZAM         = 111111;
            c.CEGNEV          = "ELso UJ Ceg";
            c.ALAPITAS_DATUMA = DateTime.Parse("1991.08.24.");
            c.JEGYZETT_TOKE   = 500000;
            c.SZEKHELY        = "Budapest";
            Assert.That(this.LogicTester.ReadCeg().Single(x => x.CEG_ID == 11).JEGYZETT_TOKE, Is.EqualTo(500000));
            this.CegMoq.Verify(x => x.Read(), Times.Once);
            this.CegMoq.Verify(x => x.Modify(11, c), Times.Once);
        }
Beispiel #4
0
        /// <summary>
        /// Represents a list of the CRUD methods of the Companies.
        /// </summary>
        public static void CegCRUDs()
        {
            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");

            ConsoleKeyInfo cki;
            CEG            ceg = new CEG();

            cki = Console.ReadKey(true);
            switch (cki.KeyChar.ToString())
            {
            case "1":
                foreach (var item in l.ReadCeg())
                {
                    Console.WriteLine(item.CEG_ID + "\t" + item.CEGNEV + "\t" + item.SZEKHELY + "\t" +
                                      item.ADOSZAM + "\t" + item.ALAPITAS_DATUMA + "\t" + item.JEGYZETT_TOKE);
                }

                Console.WriteLine("Hit an 'ENTER' to go back to main menu.");
                Console.ReadLine();
                break;

            case "2":
                bool jo = true;
                while (jo)
                {
                    try
                    {
                        Console.Write("Cég_ID: ");
                        ceg.CEG_ID = int.Parse(Console.ReadLine());
                        Console.Write("Cégnév: ");
                        ceg.CEGNEV = Console.ReadLine();
                        Console.Write("Székhely: ");
                        ceg.SZEKHELY = Console.ReadLine();
                        Console.Write("Adószám: ");
                        ceg.ADOSZAM = int.Parse(Console.ReadLine());
                        Console.Write("Alapítás dátuma [yyyy.mm.dd.]");
                        ceg.ALAPITAS_DATUMA = DateTime.Parse(Console.ReadLine());
                        Console.Write("Jegyzett tőke: ");
                        ceg.JEGYZETT_TOKE = int.Parse(Console.ReadLine());
                        l.CreateCeg(ceg);
                        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":
                bool ok = true;
                while (ok)
                {
                    try
                    {
                        foreach (var item in l.ReadCeg())
                        {
                            Console.WriteLine(item.CEG_ID + "\t" + item.CEGNEV + "\t" + item.SZEKHELY + "\t" +
                                              item.ADOSZAM + "\t" + item.ALAPITAS_DATUMA + "\t" + item.JEGYZETT_TOKE);
                        }

                        bool van = false;
                        Console.WriteLine("Adja meg a módosítani kívánt tétel 'ID'-jét:");
                        int id = int.Parse(Console.ReadLine());
                        ok = false;
                        foreach (var item in l.ReadCeg())
                        {
                            if (item.CEG_ID == id)
                            {
                                Console.WriteLine(item.CEG_ID + "\t" + item.CEGNEV + "\t" + item.SZEKHELY + "\t" +
                                                  item.ADOSZAM + "\t" + item.ALAPITAS_DATUMA + "\t" + item.JEGYZETT_TOKE);
                                van = true;
                            }
                        }

                        if (van)
                        {
                            Console.Write("Cég ID: ");
                            ceg.CEG_ID = int.Parse(Console.ReadLine());
                            Console.Write("Cégnév: ");
                            ceg.CEGNEV = Console.ReadLine();
                            Console.Write("Székhely: ");
                            ceg.SZEKHELY = Console.ReadLine();
                            Console.Write("Adószám: ");
                            ceg.ADOSZAM = int.Parse(Console.ReadLine());
                            Console.Write("Alapítás Dátuma: ");
                            ceg.ALAPITAS_DATUMA = DateTime.Parse(Console.ReadLine());
                            Console.Write("Jegyzett tőke: ");
                            ceg.JEGYZETT_TOKE = int.Parse(Console.ReadLine());
                            l.UpdateCeg(ceg);
                            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: ");
                        ceg.CEG_ID = int.Parse(Console.ReadLine());
                        l.DeleteCeg(ceg);

                        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;
            }
        }
Beispiel #5
0
 /// <inheritdoc/>
 public void UpdateCeg(CEG ceg)
 {
     this.ceg.Modify(ceg.CEG_ID, ceg);
 }
Beispiel #6
0
 /// <inheritdoc/>
 public void DeleteCeg(CEG c)
 {
     c = this.ceg.Read().FirstOrDefault(u => u.CEG_ID == c.CEG_ID);
     this.ceg.Delete(c);
 }
Beispiel #7
0
 /// <inheritdoc/>
 public void CreateCeg(CEG c)
 {
     this.ceg.Add(c);
 }