//Method used to write all details of the given customer list and set
        //of unique ID generators to a file to be read on next startup.
        public static void writeToFiles(CustomerListFacade writeList, String writeGenerators)
        {
            if (File.Exists(mainFileName))
            {
                File.Delete(mainFileName);
            }

            if (File.Exists(generatorsFileName))
            {
                File.Delete(generatorsFileName);
            }

            FileStream      stream    = File.Create(mainFileName);
            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(stream, writeList);
            stream.Close();

            var genFile = File.Create(generatorsFileName);

            genFile.Close();
            File.WriteAllText(generatorsFileName, writeGenerators);

            return;
        }
Exemple #2
0
        public void getBookings_test()
        {
            //Set up the class list to be searched and adds the data to be found.
            CustomerListFacade TestCustomers = new CustomerListFacade();

            TestCustomers.addCustomer(TestCustomer);
            TestCustomers.addBooking(1, TestBooking);
            Booking TestBooking2 = new Booking()
            {
                BookingRef = 2, ChaletID = 3, ArrivalDate = DateTime.Parse("21/02/2019"), DepartureDate = DateTime.Parse("28/02/2019")
            };

            TestCustomers.addBooking(1, TestBooking2);

            var     TestBookings = TestCustomers.GetBookings(1);
            Boolean result       = false;

            //If the all test bookings are added to list TestBookings then the
            //result to true, otherwise leave it as false.
            if (TestBookings.Count == 2)
            {
                result = true;
            }

            //If result is true, pass the test, otherwise fail it.
            Assert.IsTrue(result);
        }
        //Method used to read in all details of the Main save file.
        public static CustomerListFacade readFromMainFile()
        {
            CustomerListFacade readList = new CustomerListFacade();

            if (File.Exists(mainFileName) && new FileInfo(mainFileName).Length != 0)
            {
                FileStream      stream    = File.OpenRead(mainFileName);
                BinaryFormatter formatter = new BinaryFormatter();
                readList = (CustomerListFacade)formatter.Deserialize(stream);
                stream.Close();
            }
            return(readList);
        }
Exemple #4
0
        public void deleteBooking_test()
        {
            //Set up the class list to be searched and adds the data to be found.
            CustomerListFacade TestCustomers = new CustomerListFacade();

            TestCustomers.addCustomer(TestCustomer);
            TestCustomers.addBooking(1, TestBooking);

            TestCustomers.deleteBooking(1, 1);
            Boolean result = false;

            //If the test booking added to the class list is deleted, set result
            //to true, otherwise leave it as false.
            if (TestCustomer.Bookings.Count == 0)
            {
                result = true;
            }

            //If result is true, pass the test, otherwise fail it.
            Assert.IsTrue(result);
        }
Exemple #5
0
        public void findBooking_test()
        {
            //Set up the class list to be searched and adds the data to be found.
            CustomerListFacade TestCustomers = new CustomerListFacade();

            TestCustomers.addCustomer(TestCustomer);
            TestCustomers.addBooking(1, TestBooking);

            Booking outputBooking = TestCustomers.findBooking(1, 1);
            Boolean result        = false;

            //If test booking is successfully found then outputBooking.ChaletID
            //should = 1, if so, set result to true, otherwise leave it as false.
            if (outputBooking.ChaletID == 1)
            {
                result = true;
            }

            //If result is true, pass the test, otherwise fail it.
            Assert.IsTrue(result);
        }
Exemple #6
0
        public void addBooking_test()
        {
            //Set up the class list to have the test added to.
            CustomerListFacade TestCustomers = new CustomerListFacade();

            TestCustomers.addCustomer(TestCustomer);

            //Create the test booking and attempts to add it to the class list.
            TestCustomers.addBooking(1, TestBooking);
            Boolean result = false;

            //If test booking is successfully added to the class list then set
            //result to true true, otherwise leave it as false.
            if (TestCustomer.Bookings.Count > 0)
            {
                result = true;
            }

            //If result is true, pass the test, otherwise fail it.
            Assert.IsTrue(result);
        }