/**
  		 * Tests setting and getting the name using Notification class accessor methods.
  		 */
  		public void TestNameAccessors()
        {
			// Create a new Notification and use accessors to set the note name 
   			INotification note = new Notification("TestNote");
   			
   			// test assertions
			Assert.True(note.Name == "TestNote", "Expecting note.Name == 'TestNote'");
   		}
        /**
  		 * Tests setting and getting the body using Notification class accessor methods.
  		 */
  		public void TestBodyAccessors()
        {
			// Create a new Notification and use accessors to set the body
   			INotification note = new Notification(null);
   			note.Body = 5;
   			
   			// test assertions
			Assert.True((int) note.Body == 5, "Expecting (int) note.Body == 5");
   		}
        /**
  		 * Tests setting the name and body using the Notification class Constructor.
  		 */
  		public void TestConstructor()
        {
			// Create a new Notification using the Constructor to set the note name and body
   			INotification note = new Notification("TestNote", 5, "TestNoteType");
   			
   			// test assertions
			Assert.True(note.Name == "TestNote", "Expecting note.Name == 'TestNote'");
			Assert.True((int) note.Body == 5, "Expecting (int) note.Body == 5");
   			Assert.True(note.Type == "TestNoteType", "Expecting note.Type == 'TestNoteType'");
   		}
        public void SimpleCommandExecute()
        {
            // Create the VO
              			var vo = new SimpleCommandTestVO(5);

            // Create the Notification (notification)
              			INotification note = new Notification("SimpleCommandTestNote", vo);

            // Create the SimpleCommand
            ICommand command = new SimpleCommandTestCommand();

               			// Execute the SimpleCommand
               			command.Execute(note);

               			// test assertions
            Assert.IsTrue(vo.result == 10, "Expecting vo.result == 10");
        }
		public void ObserverAccessors()
        {
   			// Create observer with null args, then
   			// use accessors to set notification method and context
			IObserver observer = new Observer(null, null);
    		observer.NotifyContext = this;
   			observer.NotifyMethod = "observerTestMethod";
  			
   			// create a test event, setting a payload value and notify 
   			// the observer with it. since the observer is this class 
   			// and the notification method is observerTestMethod,
   			// successful notification will result in our local 
   			// observerTestVar being set to the value we pass in 
   			// on the note body.
   			INotification note = new Notification("ObserverTestNote", 10);
			observer.NotifyObserver(note);

			// test assertions  			
   			Assert.IsTrue(observerTestVar == 10, "Expecting observerTestVar = 10");
   		}
  		/**
  		 * Tests the toString method of the notification
  		 */
  		public void TestToString() {

			// Create a new Notification and use accessors to set the note name 
   			INotification note = new Notification("TestNote", "1,3,5", "TestType");
   			string ts = "Notification Name: TestNote\nBody:1,3,5\nType:TestType";
   			
   			// test assertions
			Assert.True(note.ToString() == ts, "Expecting note.testToString() == '" + ts + "'");
   		}
		public void ObserverConstructor()
        {
   			// Create observer passing in notification method and context
			IObserver observer = new Observer("observerTestMethod", this);
  			
   			// create a test note, setting a body value and notify 
   			// the observer with it. since the observer is this class 
   			// and the notification method is observerTestMethod,
   			// successful notification will result in our local 
   			// observerTestVar being set to the value we pass in 
   			// on the note body.
   			INotification note = new Notification("ObserverTestNote", 5);
			observer.NotifyObserver(note);

			// test assertions  			
   			Assert.IsTrue(observerTestVar == 5, "Expecting observerTestVar = 5");
   		}
		public void RegisterAndExecuteCommand() 
        {
   			// Create the controller, register the ControllerTestCommand to handle 'ControllerTest' notes
   			IController controller = Controller.Instance;
			string name = "ControllerTest" + Thread.CurrentThread.Name;
   			controller.RegisterCommand(name, typeof(ControllerTestCommand));
   			
   			// Create a 'ControllerTest' note
            ControllerTestVO vo = new ControllerTestVO(12);
   			INotification note = new Notification(name, vo);

			// Tell the controller to execute the Command associated with the note
			// the ControllerTestCommand invoked will multiply the vo.input value
			// by 2 and set the result on vo.result
   			controller.ExecuteCommand(note);
   			
   			// test assertions 
            Assert.IsTrue(vo.result == 24, "Expecting vo.result == 24");
   		}
		public void ReregisterAndExecuteCommand()
		{
  			 
   			// Fetch the controller, register the ControllerTestCommand2 to handle 'ControllerTest2' notes
   			IController controller = Controller.Instance;
			string name = "ControllerTest2" + Thread.CurrentThread.Name;
			controller.RegisterCommand(name, typeof(ControllerTestCommand2));
   			
   			// Remove the Command from the Controller
			controller.RemoveCommand(name);
			
   			// Re-register the Command with the Controller
			controller.RegisterCommand(name, typeof(ControllerTestCommand2));

   			// Create a 'ControllerTest2' note
			ControllerTestVO vo = new ControllerTestVO(12);
			Notification note = new Notification(name, vo);

			// retrieve a reference to the View.
   			IView view = View.Instance;
   			
			// send the Notification
   			view.NotifyObservers(note);
   			
   			// test assertions 
			// if the command is executed once the value will be 24
			Assert.IsTrue(vo.result == 24, "Expecting vo.result == 24");

   			// Prove that accumulation works in the VO by sending the notification again
   			view.NotifyObservers(note);
   			
			// if the command is executed twice the value will be 48
			Assert.IsTrue(vo.result == 48, "Expecting vo.result == 48");
   		}
        /**
  		 * Tests Command registration and removal.
  		 * 
  		 * <P>
  		 * Tests that once a Command is registered and verified
  		 * working, it can be removed from the Controller.</P>
  		 */
  		public void TestRegisterAndRemoveCommand()
        {
  			
   			// Create the controller, register the ControllerTestCommand to handle 'ControllerTest' notes
   			IController controller = Controller.Instance;
			string name = "ControllerRemoveTest" + Thread.CurrentThread.Name;
			controller.RegisterCommand(name, typeof(ControllerTestCommand));
   			
   			// Create a 'ControllerTest' note
            ControllerTestVO vo = new ControllerTestVO(12);
   			INotification note = new Notification(name, vo);

			// Tell the controller to execute the Command associated with the note
			// the ControllerTestCommand invoked will multiply the vo.input value
			// by 2 and set the result on vo.result
   			controller.ExecuteCommand(note);
   			
   			// test assertions 
   			Assert.True(vo.result == 24, "Expecting vo.result == 24");
   			
   			// Reset result
   			vo.result = 0;
   			
   			// Remove the Command from the Controller
   			controller.RemoveCommand(name);
			
			// Tell the controller to execute the Command associated with the
			// note. This time, it should not be registered, and our vo result
			// will not change   			
   			controller.ExecuteCommand(note);
   			
   			// test assertions 
            Assert.True(vo.result == 0, "Expecting vo.result == 0");
   			
   		}
		public void MacroCommandExecute()
        {
  			// Create the VO
  			MacroCommandTestVO vo = new MacroCommandTestVO(5);
  			
  			// Create the Notification (note)
  			INotification note = new Notification("MacroCommandTest", vo);

			// Create the SimpleCommand  			
			ICommand command = new MacroCommandTestCommand();
   			
   			// Execute the SimpleCommand
   			command.Execute(note);
   			
   			// test assertions
   			Assert.IsTrue(vo.result1 == 10, "Expecting vo.result1 == 10");
            Assert.IsTrue(vo.result2 == 25, "Expecting vo.result2 == 25");
   		}