public void testConveyorBeltSplitterConstructor() { int dequeueDeltaMiliSeconds = 1000; int id = 0; List<IProblem> problems = new List<IProblem>(); ConveyorBeltSplitter cbs = new ConveyorBeltSplitter(dequeueDeltaMiliSeconds, problems, id); Assert.AreEqual(cbs.name, "Splitter number: " + id.ToString()); Assert.AreEqual(cbs.stuck, false); IComponent destination = cbs; LuggageBag lb = new LuggageBag(destination); Assert.AreEqual(cbs.getSinks().Count, 0); // Check count() and enqueluggage with problem and without problem List<Personnel> plist = new List<Personnel>(); List<IRole> roles = new List<IRole>(); roles.Add(new StuckLuggageRole()); Personnel p1 = new Personnel(1, roles); plist.Add(p1); PersonnelController pc = new PersonnelController(plist); Stuck s = new Stuck(0, pc); problems.Add(s); cbs.EnqueueLuggage(lb); bool fail1 = true; try { cbs.getSinks(); } catch (Exception e) { if (e.GetType().FullName == "System.Diagnostics.Contracts.__ContractsRuntime+ContractException") fail1 = false; } Assert.IsTrue(fail1); /** Assert.AreEqual(1,cbs.Count()); s = new Stuck(100, pc); problems.Add(s); cbs.EnqueueLuggage(lb); Assert.AreEqual(2,cbs.Count()); try { cbs.addNextComponent(cbs); } catch (NotImplementedException) { Assert.IsTrue(true); } Assert.AreEqual(cbs.getSinks().Count, 1);**/ }
public void testAirplaneConstructor() { List<IProblem> problems = new List<IProblem>(); int id= 0; Airplane ap = new Airplane(problems, id); // Constructor() Assert.AreEqual(ap.name, "Airplane number: "+id.ToString()); Assert.AreEqual(ap.initialized, true); Assert.AreEqual(ap.stuck, false); IComponent destination = ap; LuggageBag lb = new LuggageBag(destination); // Check count() and enqueluggage with problem and without problem List<Personnel> plist = new List<Personnel>(); List<IRole> roles = new List<IRole>(); roles.Add(new StuckLuggageRole()); Personnel p1 = new Personnel(1, roles); plist.Add(p1); PersonnelController pc = new PersonnelController(plist); Stuck s = new Stuck(0, pc); problems.Add(s); ap.EnqueueLuggage(lb); Thread.Sleep(1000); Assert.AreEqual(0, ap.Count()); s = new Stuck(100, pc); problems.Add(s); ap.EnqueueLuggage(lb); Assert.AreEqual(1, ap.Count()); //DequeLuggage() //ap.DequeueLuggage(); //Assert.AreEqual(ap.Count(), 0); //AddNextComponent() try { ap.addNextComponent(ap); } catch (NotImplementedException) { Assert.IsTrue(true); } //InAndOutCounters() Assert.AreEqual(ap.InAndOutCounters().Item1, 2); //GetSinks() //Assert.AreEqual(ap.getSinks(), ); Assert.AreEqual(ap.getSinks().Count, 1); //Assert.AreEqual(ap.getSinks().ToString(), "Airplane number: 0"); }
public void StuckTest1() { List<Personnel> plist = new List<Personnel>(); List<IRole> roles = new List<IRole>(); roles.Add(new StuckLuggageRole()); Personnel p1 = new Personnel(1, roles); plist.Add(p1); PersonnelController pc = new PersonnelController(plist); Stuck s = new Stuck(0,pc); bool fail1 = s.Fail(); s = new Stuck(100, pc); bool fail2 = s.Fail(); bool fail3 = false; try { s = new Stuck(-1, pc); s.Fail(); } catch (Exception e) { if (e.GetType().FullName == "System.Diagnostics.Contracts.__ContractsRuntime+ContractException") fail3 = true; } bool fail4 = false; try { s = new Stuck(101, pc); s.Fail(); } catch (Exception e) { if (e.GetType().FullName == "System.Diagnostics.Contracts.__ContractsRuntime+ContractException") fail4 = true; } //s.HandleProblem(); Assert.IsFalse(fail1); Assert.IsTrue(fail2); Assert.IsTrue(fail3); Assert.IsTrue(fail4); }