示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            
            PrinterDatabase db = new PrinterDatabase();

            if (string.IsNullOrEmpty(textBox1.Text))
            {
                MessageBox.Show("Der Hostname darf nicht leer sein. Bitte geben Sie mindestens ein Zeichen ein.", "Prinfo.NET Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    Printer = db.CreatePrinter(textBox1.Text);
                    this.DialogResult = DialogResult.OK;

                    this.Close();
                }
                catch (Exception ae)
                {
                    MessageBox.Show("Unerwarteter Fehler. Details: " + ae.Message, "Prinfo.NET Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.Log(ae.Message, LogType.Error);
                }
            }
        }
示例#2
0
        public void Add_And_GetPrinterFromDatabase_IntegrityTest()
        {
            var printerDatabase = new PrinterDatabase();
            var printer = printerDatabase.CreatePrinter("localhost");

            // fill with random values
            printer.Pingable = true;
            printer.Manufacturer = "Kyocera";

            printer.PageCount = 2000;

            printer.Supplies.Add(
                new Supply() { Description = "Black Toner", Value = 89, NotifyWhenLow = true, NotificationValue = 30 });

            printerDatabase.UpdatePrinter(printer);

            var retrievedPrinter = printerDatabase.GetPrinterById(printer.Id);

            // check if the retrieved values equal the saved ones

            Assert.AreEqual(printer.Manufacturer, retrievedPrinter.Manufacturer);
            Assert.AreEqual(printer.PageCount, retrievedPrinter.PageCount);
            Assert.AreEqual(printer.Supplies[0].Value, retrievedPrinter.Supplies[0].Value);
            Assert.AreEqual(printer.Supplies[0].NotifyWhenLow, retrievedPrinter.Supplies[0].NotifyWhenLow);
            Assert.AreEqual(printer.Supplies[0].NotificationValue, retrievedPrinter.Supplies[0].NotificationValue);

        }
示例#3
0
        public void ArchivDb_2Day_Test()
        {
            var printerDatabase = new PrinterDatabase();
            var archivDatabase = new ArchivDatabase();

            var printer = printerDatabase.CreatePrinter("localhost");
            printer.LastCheck = DateTime.Now.ToString();


            archivDatabase.Initialize();
            archivDatabase.AddEntry(printer);
            // modifizieren des datums um einen tag damit ein weiterer archiveintrag erzeugt wird
            printer.LastCheck = DateTime.Now.AddDays(1).ToString();
            archivDatabase.AddEntry(printer);

            Assert.AreEqual(archivDatabase.GetEntriesById(printer.Id).Count, 2);



        }
示例#4
0
        public void DeletePrinter_Test()
        {
            var printerDatabase = new PrinterDatabase();
            printerDatabase.Initialize();
            var printer = printerDatabase.CreatePrinter("localhost");


            printerDatabase.DeletePrinterByID(printer.Id);
            Assert.AreEqual(printerDatabase.GetPrinterList().Count, 0);

        }
示例#5
0
        public void ArchivDb_SingleDay_Test()
        {
            var printerDatabase = new PrinterDatabase();
            var archivDatabase = new ArchivDatabase();

            var printer = printerDatabase.CreatePrinter("localhost");
            printer.LastCheck = DateTime.Now.ToString();


            archivDatabase.Initialize();
            archivDatabase.AddEntry(printer);
            archivDatabase.AddEntry(printer);

            Assert.AreEqual(archivDatabase.GetEntriesById(printer.Id).Count, 1);



        }