Example #1
0
 public void TestGivenReferenceInSeperateElement()
 {
     Scenario testScenario = new Scenario("X Times Y");
     testScenario.InstallMarkup("Far()\r\n{\r\nX\r\n}\r\nBasic()\r\n{\r\nY\r\nPROD(\"whose result is found by\")\r\n{\r\nPROD = Far.X * Y\r\n}\r\n}");
     testScenario.AssociateGivensFromXML("<Givens><Far.X>5</Far.X><Basic.Y>5</Basic.Y></Givens>");
     Assert.AreEqual(25, testScenario.CalculateDerivative("Basic.PROD"));
 }
Example #2
0
 public void AssociateXML()
 {
     Scenario scn = new Scenario("Test");
     scn.InstallMarkup("Basic()\r\n{\r\nX\r\nY\r\nPROD(\"Result\")\r\n{\r\nPROD = X * Y\r\n}\r\n}");
     scn.AssociateGivensFromXML("<Givens><Basic.X>5</Basic.X><Basic.Y>5</Basic.Y></Givens>");
     Assert.AreEqual(5, scn.Givens.Find(t => t.Key == "Basic.X").Value);
     Assert.AreEqual(5, scn.Givens.Find(t => t.Key == "Basic.Y").Value);
 }
Example #3
0
 public void AssociateJSON()
 {
     Scenario scn = new Scenario("Test");
     scn.InstallMarkup("Basic()\r\n{\r\nX\r\nY\r\nPROD(\"Result\")\r\n{\r\nPROD = X * Y\r\n}\r\n}");
     scn.AssociateGivensFromJSON("{\r\n  \"Givens\": [{ \r\n \"ID\": \"Basic.X\", \"Value\": \"5\"}, { \"ID\" : \"Basic.Y\", \"Value\": \"5\"\r\n  }]\r\n}");
     Assert.AreEqual(5M, scn.Givens.Find(t => t.Key == "Basic.X").Value);
     Assert.AreEqual(5M, scn.Givens.Find(t => t.Key == "Basic.Y").Value);
 }
Example #4
0
 public void IndirectionTest()
 {
     Scenario testScenario = new Scenario("IndirectionTest");
     TestData data = unpack.GetTestData("IndirectionTest");
     testScenario.InstallMarkup(data.Markup);
     testScenario.AssociateGivensFromXML(data.XML);
     Assert.AreEqual(25, testScenario.CalculateDerivative("Other.FOO"));
 }
Example #5
0
 public void ExceptionIfDerivativeNotFound()
 {
     Scenario testScenario = new Scenario("X Times Y");
     TestData data = unpack.GetTestData("BasicXTimesY");
     testScenario.InstallMarkup(data.Markup);
     testScenario.AssociateGivensFromXML(data.XML);
     testScenario.CalculateDerivative("Foo.PROD");
 }
Example #6
0
 public void BasicXTimesY()
 {
     Scenario testScenario = new Scenario("X Times Y");
     TestData data = unpack.GetTestData("BasicXTimesY");
     testScenario.InstallMarkup(data.Markup);
     testScenario.AssociateGivensFromXML(data.XML);
     Assert.AreEqual(25, testScenario.CalculateDerivative("Basic.PROD"));
 }
Example #7
0
 public void BasicXTimesYIsSelfDescribing()
 {
     Scenario testScenario = new Scenario("X Times Y");
     testScenario.InstallMarkup("Basic()\r\n{\r\nX\r\nY\r\nPROD(\"whose result is found by\")\r\n{\r\nPROD = X * Y\r\n}\r\n}");
     testScenario.AssociateGivensFromXML("<Givens><Basic.X>5</Basic.X><Basic.Y>5</Basic.Y></Givens>");
     string description = "";
     testScenario.CalculateDerivative("Basic.PROD", out description);
     Assert.AreEqual("Basic contains a PROD, whose result is found by the multiplication of the given Basic.X (5) and the given Basic.Y (5) yielding a value of 25", description);
 }
Example #8
0
 public void BasicXDividedByYIsSelfDescribing()
 {
     Scenario testScenario = new Scenario("X / Y");
     testScenario.InstallMarkup("Basic()\r\n{\r\nX\r\nY\r\nPROD(\"whose result is found by\")\r\n{\r\nPROD = X \\ Y\r\n}\r\n}");
     testScenario.AssociateGivensFromXML("<Givens><Basic.X>10</Basic.X><Basic.Y>2</Basic.Y></Givens>");
     string description = "";
     testScenario.CalculateDerivative("Basic.PROD", out description);
     Assert.AreEqual("Basic contains a PROD, whose result is found by the division of the given Basic.X (10) by the given Basic.Y (2) yielding a value of 5", description);
 }
Example #9
0
 public void IndirectionIsSelfDescribing()
 {
     Scenario testScenario = new Scenario("IndirectionTest");
     TestData data = unpack.GetTestData("IndirectionTest");
     testScenario.InstallMarkup(data.Markup);
     testScenario.AssociateGivensFromXML(data.XML);
     string description = "";
     testScenario.CalculateDerivative("Other.FOO", out description);
     throw new TestIncompleteException();
 }