public void TestGetInstance() { { // when BusinessInformation information = BusinessInformation.GetInstance("xxx"); // then Assert.AreEqual("xxx", information.Name); Assert.AreEqual(null, information.Synopsis); Assert.AreEqual(null, information.Description); Assert.AreEqual(null, information.Examples); } { // setup BusinessesFolder.Initialize("zzz"); // when BusinessInformation information = BusinessInformation.GetInstance("zzz"); // then Assert.AreEqual("zzz", information.Name); Assert.AreEqual("Reports current time.", information.Synopsis); Assert.IsTrue(information.Description.StartsWith("Copyright ")); Assert.AreEqual("[<CommonParameters>]", information.Examples.Trim()); } }
public void TestCreateReport() { // setup BusinessesFolder.Initialize("zzz"); Business business = Business.GetInstance(BusinessesFolder.TimeKeeping); // when Hashtable report = business.CreateReport(new Hashtable()); // then Assert.AreEqual(true, report["IsUpdated"]); }
public void TestLoad() { // setup BusinessesFolder.Initialize("Check-Job-status"); // when BusinessInformation information = BusinessInformationScriptEngine.Load("Check-Job-status"); // then Assert.AreEqual("Check-Job-status", information.Name); Assert.AreEqual("Reports job statuses of a build server.", information.Synopsis); Assert.IsTrue(information.Description.StartsWith("Copyright ")); Assert.IsTrue(information.Examples.Trim().StartsWith("[-url] <String>")); }
public void TestScriptError() { // setup BusinessesFolder.Initialize(BusinessesFolder.CheckJobStatus); try { // when BusinessScriptEngine.Execute(BusinessesFolder.CheckJobStatus, null, new Hashtable()); Assert.Fail("ここにはこない"); } catch (ApplicationException e) { // then Console.WriteLine(e.Message); Assert.IsTrue(e.Message.StartsWith("Cannot process command because of ")); } }
public void TestErrorTheScriptMustReturnObject() { // setup BusinessesFolder.Initialize(BusinessesFolder.TimeKeeping); string script = Path.Combine(BusinessesFolder.GetFolder(BusinessesFolder.TimeKeeping), "main.ps1"); TestUtil.Replace(script, " $newReport\r\n}", "}"); try { // when BusinessScriptEngine.Execute(BusinessesFolder.TimeKeeping, null, new Hashtable()); Assert.Fail("ここにはこない"); } catch (ApplicationException e) { // then Console.WriteLine(e.Message); Assert.AreEqual("the script must return a instance of Hashtable", e.Message); } }