public void AdultCheckOut_MaxCheckOutLimit() { // arrange Item media = new Item("title", false, "tom cruise", DateTime.Now, DateTime.Now); Adult person = new Adult("tom", "huck", 6); // Act - add one more item to person to checkout Assert.IsFalse(person.checkout(ref media)); }
public void AdultCheckOut_Success_5ItemsTo6Item() { // arrange Item media = new Item("title", false, "tom cruise", DateTime.Now, DateTime.Now); Adult person = new Adult("tom", "huck", 5); person.checkout(ref media); // Act - add 1 item to person without any checked out items Assert.AreEqual(6, person.numberofItems); }
public void AdultCheckIn_Succes() { // arrange Item media = new Item("title", false, "tom cruise", DateTime.Now, DateTime.Now); Adult person = new Adult("tom", "huck", 1); // Act - add 1 item to person without any checked out items person.checkin(ref media); Assert.AreEqual(0, person.numberofItems); }
// Assumed C# will create default constructor and destructor public static void readFile() { string inputstring = null; StreamReader data = null; Stream myStream = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c://"; openFileDialog1.Filter = "bin files(*.bin)|*bin"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { if ((myStream = openFileDialog1.OpenFile()) != null) { data = new StreamReader(myStream); } else throw new Exception("streamReader problem"); } itemsList = new List<Item>(); // populate items list try { string star = data.ReadLine(); if (star != "*") throw new FileLoadException("No Star found"); do { inputstring = data.ReadLine(); if (inputstring != "**") { string title = inputstring; string category = data.ReadLine(); string whoCheckedout = data.ReadLine(); string tempInt = data.ReadLine(); bool checkStatus = (tempInt == "1") ? true : false; // read in checkedout date string time = data.ReadLine(); DateTime checkedOut = DateTime.Parse(time); //read in duedate time = data.ReadLine(); DateTime dueDate = DateTime.Parse(time); // create a items object and push // need items constructor if (category == "AdultBook") { AdultBook temp = new AdultBook(title, checkStatus, whoCheckedout, checkedOut, dueDate); itemsList.Add(temp); } else if (category == "ChildBook") { ChildBook temp = new ChildBook(title, checkStatus, whoCheckedout, checkedOut, dueDate); itemsList.Add(temp); } else if (category == "DVD") { DVD temp = new DVD(title, checkStatus, whoCheckedout, checkedOut, dueDate); itemsList.Add(temp); } else if (category == "VHS") { VHS temp = new VHS(title, checkStatus, whoCheckedout, checkedOut, dueDate); itemsList.Add(temp); } else throw new FileLoadException("invalid file"); } } while (inputstring != "**"); patronsList = new List<Patron>(); do { inputstring = data.ReadLine(); if (inputstring == "***") break; string fname = inputstring; string lname = data.ReadLine(); string category = data.ReadLine(); string numItems = data.ReadLine(); if (category == "Adult") { Adult temp = new Adult(fname, lname, int.Parse(numItems)); patronsList.Add(temp); } else { Child temp = new Child(fname, lname, int.Parse(numItems)); patronsList.Add(temp); } } while (inputstring != "***"); MessageBox.Show("File Loaded!!"); } catch (Exception e) { data.Close(); throw new FileLoadException("Unable to Load"); } finally { myStream.Close(); } }