public void TestConvertVersionToInt() { TestClassForOfficeApplicationVersion test = new TestClassForOfficeApplicationVersion(); Dictionary<string, int> VersionNumbers = new Dictionary<string, int>(); VersionNumbers["Excel.Application.11"] = 11; VersionNumbers["Word.Application.12"] = 12; VersionNumbers["PowerPoint.Application.14"] = 14; foreach (KeyValuePair<string, int> value in VersionNumbers) { Assert.AreEqual(test.GetVersionNumberFromRegString(value.Key), value.Value, "Failed to retrieve expected version number from " + value.Key); } }
public void TestGetVersionNumber() { TestClassForOfficeApplicationVersion test = new TestClassForOfficeApplicationVersion(); Word.Application myWord = new Word.Application(); Assert.AreEqual(test.GetVersionFromAppType(testenum.AppWord, myWord), test.GetInstalledWordVersion(), "Versions are different for Word"); myWord.Quit(); Marshal.ReleaseComObject(myWord); PowerPoint.Application myPPT = new PowerPoint.Application(); Assert.AreEqual(test.GetVersionFromAppType(testenum.AppPowerPoint, myPPT), test.GetInstalledPowerPointVersion(), "Versions are different for PowerPoint"); Marshal.ReleaseComObject(myPPT); Excel.Application myExcel = new Excel.Application(); Assert.AreEqual(test.GetVersionFromAppType(testenum.AppExcel, myExcel), test.GetInstalledExcelVersion(), "Versions are different for Excel"); Marshal.ReleaseComObject(myExcel); GC.Collect(); }
public void TestForAnomalies() { TestClassForOfficeApplicationVersion test = new TestClassForOfficeApplicationVersion(); Assert.AreEqual(test.GetVersionFromAppType((testenum) 3, null), 0, "Test for bad enum failed"); Assert.AreEqual(test.GetVersionNumberFromRegString("14"), 14, "Test for unexpected string"); Assert.AreNotEqual(test.GetInstalledWordVersion(), 0, "Test for Word version returned 0"); Assert.AreNotEqual(test.GetInstalledExcelVersion(), 0, "Test for Excel version returned 0"); Assert.AreNotEqual(test.GetInstalledPowerPointVersion(), 0, "Test for PowerPoint version returned 0"); }