using System; using NUnit.Framework; using DelphiProjectHandler; namespace DelphiProjectHandler.Tests { [TestFixture] public class UnitFormReaderClassTests { protected void TestGetBinaryFormName(string iTestValue, string iExpected, string iMessage) { string vActual = UnitFormReader.GetBinaryFormName(iTestValue); Assert.AreEqual(iExpected, vActual, iMessage); } [Test] public void GetBinaryFormName() { #region (Test values) string vTestValue1 = @"ÿ TFRMACFTDISCREPANCIES 0É TPF0ñTfrmAcftDiscrepanciesfrmAcftDiscrepanciesLeftî TopiWidth™Height¸ CaptionAircraft DiscrepanciesVisibleOnClose FormClose OnCloseQueryFormCloseQuery"; string vTestValue2 = @"ÿ TFRMAIRCRAFTINFO 02 TPF0TfrmAircraftInfofrmAircraftInfoLeftÖ Top"; string vTestValue3 = @"ÿ TFRMBASESI 0í TPF0ñTfrmBaseSI frmBaseSILeftUTop° CaptionfrmBa"; #endregion TestGetBinaryFormName(vTestValue1, "frmAcftDiscrepancies", "1"); TestGetBinaryFormName(vTestValue2, "frmAircraftInfo", "2"); TestGetBinaryFormName(vTestValue3, "frmBaseSI", "3"); } [Test] [ExpectedException(typeof(Exception))] public void GetBinaryFormName_FormNameIsLast() { string vTestValue = @"ÿ TFRMBASESI 0í TPF0ñTfrmBase"; TestGetBinaryFormName(vTestValue, "", ""); } [Test] [ExpectedException(typeof(Exception))] public void GetBinaryFromName_WithoutMarker() { string vTestValue = @"ÿ TFRMACFTDISCREPANCIES 0É ñTfrmAcftDiscrepanciesfrmAcftDiscrepanciesLeftî TopiWidth™Height¸ CaptionAircraft DiscrepanciesVisibleOnClose FormClose OnCloseQueryFormCloseQuery"; TestGetBinaryFormName(vTestValue, "", ""); } [Test] [ExpectedException(typeof(Exception))] public void GetBinaryFormName_WithoutFormName() { string vTestValue = @"ÿ TFRMACFTDISCREPANCIES 0É TPF0ñ"; TestGetBinaryFormName(vTestValue, "", ""); } } }