public void RemoveLink()
		{
			TestEngineLC  sourceModel = new TestEngineLC();
			TestEngineLC  targetModel = new TestEngineLC();

			sourceModel.Initialize(new Argument[0]);
			targetModel.Initialize(new Argument[0]);
	
			Link link = new Link();
			link.ID = "SourceToTargetLink";
			link.SourceComponent  = sourceModel;
			link.SourceElementSet = sourceModel.GetOutputExchangeItem(0).ElementSet; //last branch in the river
			link.SourceQuantity   = sourceModel.GetOutputExchangeItem(0).Quantity;
			link.TargetComponent  = targetModel;
			link.TargetElementSet = targetModel.GetInputExchangeItem(0).ElementSet;  //first node in the river
			link.TargetQuantity   = targetModel.GetInputExchangeItem(0).Quantity;

			Assert.AreEqual(0,sourceModel.SmartOutputLinks.Count);
			Assert.AreEqual(0,sourceModel.SmartOutputLinks.Count);
			Assert.AreEqual(0,targetModel.SmartOutputLinks.Count);
			Assert.AreEqual(0,targetModel.SmartOutputLinks.Count);
			
			sourceModel.AddLink(link);
			targetModel.AddLink(link);

			Assert.AreEqual(1,sourceModel.SmartOutputLinks.Count);
			Assert.AreEqual(0,sourceModel.SmartInputLinks.Count);
			Assert.AreEqual(0,targetModel.SmartOutputLinks.Count);
			Assert.AreEqual(1,targetModel.SmartInputLinks.Count);

			sourceModel.RemoveLink(link.ID);
			targetModel.RemoveLink(link.ID);

			Assert.AreEqual(0,sourceModel.SmartOutputLinks.Count);
			Assert.AreEqual(0,sourceModel.SmartOutputLinks.Count);
			Assert.AreEqual(0,targetModel.SmartOutputLinks.Count);
			Assert.AreEqual(0,targetModel.SmartOutputLinks.Count);
		
		}
		public void XEvent()
		{
			// Event Test
			// Testing : 1) That all events are actually thrown during calculations
			
			TestEngineLC  sourceModel = new TestEngineLC();
			TestEngineLC  targetModel = new TestEngineLC();
			Trigger trigger           = new Trigger();

			sourceModel.Initialize(new Argument[0]);
			targetModel.Initialize(new Argument[0]);
			trigger.Initialize(new Argument[0]);

			Link link = new Link();
			link.ID = "SourceToTargetLink";
			link.SourceComponent  = sourceModel;
			link.SourceElementSet = sourceModel.GetOutputExchangeItem(0).ElementSet; //last branch in the river
			link.SourceQuantity   = sourceModel.GetOutputExchangeItem(0).Quantity;
			link.TargetComponent  = targetModel;
			link.TargetElementSet = targetModel.GetInputExchangeItem(0).ElementSet;  //first node in the river
			link.TargetQuantity   = targetModel.GetInputExchangeItem(0).Quantity;

			Link triggerLink = new Link();
			triggerLink.ID = "TargetToTriggerLink";
			triggerLink.SourceComponent  = targetModel;
			triggerLink.SourceElementSet = targetModel.GetOutputExchangeItem(0).ElementSet; //last branch in the river
			triggerLink.SourceQuantity   = targetModel.GetOutputExchangeItem(0).Quantity;
			triggerLink.TargetComponent  = trigger;
			triggerLink.TargetElementSet = trigger.GetInputExchangeItem(0).ElementSet;  
			triggerLink.TargetQuantity   = trigger.GetInputExchangeItem(0).Quantity;

			sourceModel.AddLink(link);
			targetModel.AddLink(link);

			targetModel.AddLink(triggerLink);
			trigger.AddLink(triggerLink);

			EventListener eventListener = new EventListener();
			eventListener._isSilent = true;

			for (int i = 0; i < eventListener.GetAcceptedEventTypeCount(); i++)
			{
				for (int n = 0; n < sourceModel.GetPublishedEventTypeCount(); n++)
				{
					if (eventListener.GetAcceptedEventType(i) == sourceModel.GetPublishedEventType(n))
					{
						sourceModel.Subscribe(eventListener, eventListener.GetAcceptedEventType(i));
					}
				}

				for (int n = 0; n < targetModel.GetPublishedEventTypeCount(); n++)
				{
					if (eventListener.GetAcceptedEventType(i) == targetModel.GetPublishedEventType(n))
					{
						targetModel.Subscribe(eventListener, eventListener.GetAcceptedEventType(i));
					}
				}
			}

			sourceModel.Prepare();
			targetModel.Prepare();
			trigger.Prepare();

			trigger.Run(new TimeStamp(sourceModel.TimeHorizon.Start.ModifiedJulianDay + 10));

			Assert.AreEqual(true , eventListener._dataChanged);   
			Assert.AreEqual(false, eventListener._globalProgress);
//			Assert.AreEqual(true , eventListener._informative);   //TODO This test was out commented, because it fails, further investigation needed
			Assert.AreEqual(false, eventListener._other);
			Assert.AreEqual(true, eventListener._sourceAfterGetValuesCall);
			Assert.AreEqual(true, eventListener._sourceBeforeGetValuesReturn);
			Assert.AreEqual(true, eventListener._targetAfterGetValuesReturn);
			Assert.AreEqual(true, eventListener._targetBeforeGetValuesCall);
			Assert.AreEqual(false, eventListener._timeStepProgres);
			Assert.AreEqual(false, eventListener._valueOutOfRange);
			Assert.AreEqual(false, eventListener._warning);
		}
		public void XUnitConvertion()
		{
			// Unit conversion. Converting Fahrenheit to Celcius
			
			double x;
			double y;
			
			TestEngineLC  sourceModel = new TestEngineLC();
			TestEngineLC  targetModel = new TestEngineLC();

			sourceModel.Initialize(new Argument[0]);
			targetModel.Initialize(new Argument[0]);

			Link link = new Link();
			link.ID = "SourcToTargetLink";
			link.SourceComponent  = sourceModel;
			link.SourceElementSet = sourceModel.GetOutputExchangeItem(0).ElementSet; //last branch in the river
			link.SourceQuantity   = new Quantity(new Unit("Deg. Fahrenheit",5.0/9.0, 273.16 - 32.0 * (5.0/9.0) ,"Fahrenheit"),"temperature","Temperature",global::OpenMI.Standard.ValueType.Scalar,new Dimension());
			link.TargetComponent  = targetModel;
			link.TargetElementSet = targetModel.GetInputExchangeItem(0).ElementSet;  //first node in the river
			link.TargetQuantity   = new Quantity(new Unit("Deg. Celcius",1.0, 273.16,"Celcius"),"temperature","Temperature",global::OpenMI.Standard.ValueType.Scalar,new Dimension());

			sourceModel.AddLink(link);
			targetModel.AddLink(link);

			sourceModel.Prepare();
			targetModel.Prepare();

			for (int i = 0; i < ((ScalarSet)sourceModel.GetValues(new TimeStamp(sourceModel.TimeHorizon.Start.ModifiedJulianDay + 10),"SourcToTargetLink")).Count; i++)
			{
				x = ((ScalarSet)sourceModel.GetValues(new TimeStamp(sourceModel.TimeHorizon.Start.ModifiedJulianDay + 10),"SourcToTargetLink")).GetScalar(i);
				y = (100.0 - 32.0) * (5.0/9.0); // = 37.7778  (100 deg. F = 37.7778 deg.C)
				Assert.AreEqual(y,x,0.0000000001);  //internal value is 80 deg Fahrenheit
			}
		}
		public void EarliestInputTime()
		{
			TestEngineLC testEngineLC = new TestEngineLC();
			Trigger trigger = new Trigger();

			testEngineLC.Initialize(new Argument[0]);

			Link triggerLink = new Link();
			triggerLink.ID = "TargetToTriggerLink";
			triggerLink.SourceComponent  = testEngineLC;
			triggerLink.SourceElementSet = testEngineLC.GetOutputExchangeItem(0).ElementSet; //last branch in the river
			triggerLink.SourceQuantity   = testEngineLC.GetOutputExchangeItem(0).Quantity;
			triggerLink.TargetComponent  = trigger;
			triggerLink.TargetElementSet = trigger.GetInputExchangeItem(0).ElementSet;  
			triggerLink.TargetQuantity   = trigger.GetInputExchangeItem(0).Quantity;

			testEngineLC.AddLink(triggerLink);
			testEngineLC.Prepare();
			Assert.AreEqual(testEngineLC.TimeHorizon.Start,testEngineLC.EarliestInputTime);

		}