Exemplo n.º 1
0
        public void Service_Database_Test()
        {
            ServiceDatabase sBase    = new ServiceDatabase();
            UserDatabase    uBase    = new UserDatabase();;
            User            testUser = new User("Tester", "Password", "*****@*****.**", "123 Test St.", null, "Tacoma", "WA", "98422");

            uBase.addUser(testUser);
            uBase.deleteUser(testUser.getEmail());
            Service toy     = new Service("Tester", "*****@*****.**");
            Service clothes = new Service("Tester", "*****@*****.**");
            Service faid    = new Service("Tester", "*****@*****.**");
            Service hygiene = new Service("Tester", "*****@*****.**");
            Service tech    = new Service("Tester", "*****@*****.**");
            Service food    = new Service("Tester", "*****@*****.**");
            Service other   = new Service("Tester", "*****@*****.**");

            Service drive = new Service("Tester", "*****@*****.**");

            Service math  = new Service("Tester", "*****@*****.**");
            Service read  = new Service("Tester", "*****@*****.**");
            Service write = new Service("Tester", "*****@*****.**");

            Service request = new Service("Tester", "*****@*****.**");

            sBase.createService(ServiceTypes.Donate, DonationTypes.Toys, testUser, toy);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Clothes, testUser, clothes);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Tech, testUser, tech);
            sBase.createService(ServiceTypes.Donate, DonationTypes.FirstAid, testUser, faid);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Food, testUser, food);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Hygene, testUser, hygiene);
            sBase.createService(ServiceTypes.Donate, DonationTypes.Other, testUser, other);

            sBase.createService(ServiceTypes.Drive, DonationTypes.Goods, testUser, drive);

            sBase.createService(ServiceTypes.Educate, DonationTypes.Math, testUser, math);
            sBase.createService(ServiceTypes.Educate, DonationTypes.Reading, testUser, read);
            sBase.createService(ServiceTypes.Educate, DonationTypes.Writing, testUser, write);

            sBase.createService(ServiceTypes.Request, DonationTypes.Tools, testUser, request);

            Assert.AreEqual("1110000\n1210000\n1310000\n1410000\n1610000\n1510000\n1810000\n", sBase.printServices(ServiceTypes.Donate));
            Assert.AreEqual("2110000\n", sBase.printServices(ServiceTypes.Drive));
            System.Console.WriteLine(sBase.retrieveService("3210000"));
            Assert.AreEqual("3110000\n3210000\n3310000\n", sBase.printServices(ServiceTypes.Educate));
            Assert.AreEqual("4110000\n", sBase.printServices(ServiceTypes.Request));

            Assert.AreEqual("1110000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Toys));
            Assert.AreEqual("1210000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Clothes));
            Assert.AreEqual("1310000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Tech));
            Assert.AreEqual("1410000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.FirstAid));
            Assert.AreEqual("1510000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Hygene));
            Assert.AreEqual("1610000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Food));
            Assert.AreEqual("1810000\n", sBase.printServices(ServiceTypes.Donate, DonationTypes.Other));

            Assert.AreEqual("2110000\n", sBase.printServices(ServiceTypes.Drive, DonationTypes.Goods));

            Assert.AreEqual("3110000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Math));
            Assert.AreEqual("3210000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Reading));
            Assert.AreEqual("3310000\n", sBase.printServices(ServiceTypes.Educate, DonationTypes.Writing));

            Assert.AreEqual("4110000\n", sBase.printServices(ServiceTypes.Request, DonationTypes.Donation));

            Assert.AreEqual(toy, sBase.retrieveService("1110000"));
            Assert.AreEqual(clothes, sBase.retrieveService("1210000"));
            Assert.AreEqual(tech, sBase.retrieveService("1310000"));
            Assert.AreEqual(faid, sBase.retrieveService("1410000"));
            Assert.AreEqual(hygiene, sBase.retrieveService("1510000"));
            Assert.AreEqual(food, sBase.retrieveService("1610000"));
            Assert.AreEqual(other, sBase.retrieveService("1810000"));

            Assert.AreEqual(drive, sBase.retrieveService("2110000"));

            Assert.AreEqual(math, sBase.retrieveService("3110000"));
            Assert.AreEqual(read, sBase.retrieveService("3210000"));
            Assert.AreEqual(write, sBase.retrieveService("3310000"));

            Assert.AreEqual(request, sBase.retrieveService("4110000"));
        }
Exemplo n.º 2
0
        public void User_Setter_Getter_Test()
        {
            User            test  = new User(name, password, email, street, apartment, city, state, zipcode);
            UserDatabase    uBase = new UserDatabase();
            ServiceDatabase sBase = new ServiceDatabase();

            uBase.addUser(test);

            test.setName("tester");
            Assert.AreEqual("tester", test.getName());
            test.setPassword("pass");
            Assert.IsTrue(uBase.verifyUser("*****@*****.**", "pass"));
            test.setEmail("*****@*****.**");
            Assert.AreEqual("*****@*****.**", test.getEmail());
            test.setAddress("321 Test St", "#201", "Portland", "OR", "97501");
            Assert.AreEqual("321 Test St, #201, Portland, OR, 97501", test.getAddress());
            test.setVehicleType("Sedan");
            Assert.AreEqual("Sedan", test.getVehicleType());
            test.setCapacity("30");
            Assert.AreEqual("30", test.getCapacity());
            test.setTimeStart("1400");
            Assert.AreEqual("1400", test.getTimeStart());
            test.setTimeStop("2000");
            Assert.AreEqual("2000", test.getTimeStop());
            test.setLicenseFilePath("testing.jpeg");
            Assert.AreEqual("testing.jpeg", test.getLicenseFilePath());
            test.setAdmin(true);
            Assert.IsTrue(test.isAdmin());

            Service toy = new Service("tester", "*****@*****.**");

            sBase.createService(ServiceTypes.Donate, DonationTypes.Toys, test, toy);
            myServices = new List <Service>();
            myServices.Add(toy);
            test.addService(toy);
            Assert.AreEqual(myServices[0], test.getServices()[0]);

            Assert.IsTrue(test.checkPassword("pass"));
            Assert.IsFalse(test.checkPassword("Password"));

            test.addDrive(vehichle, capacity, start, stop, license);
            Assert.AreEqual(vehichle, test.getVehicleType());
            Assert.AreEqual(capacity, test.getCapacity());
            Assert.AreEqual(start, test.getTimeStart());
            Assert.AreEqual(stop, test.getTimeStop());
            Assert.AreEqual(license, test.getLicenseFilePath());

            string path = @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow";

            File.Delete(Path.Combine(path, "Toy_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Clothes_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Tech_Dictionary.txt"));
            File.Delete(Path.Combine(path, "First_Aid_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Hygene_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Food_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Other_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Goods_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Math_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Reading_Dictionary.txt"));
            File.Delete(Path.Combine(path, "Writing_Dictionary.txt"));

            File.Delete(Path.Combine(path, "Request_Dictionary.txt"));

            File.Delete(Path.Combine(path, "serial_list.txt"));
            File.Delete(Path.Combine(path, "userlist.txt"));
        }