// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Drawing; using System.Resources; using System.Windows.Forms; using System.Xml; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.WixBinding; using NUnit.Framework; using WixBinding; using WixBinding.Tests.Utils; namespace WixBinding.Tests.DialogLoading { /// /// Tests that we get WixDialogExceptions with detailed information about /// invalid X and Y location. /// [TestFixture] public class InvalidLocationTests { [TestFixtureSetUp] public void SetupFixture() { SD.InitializeForUnitTests(); MessageLoopHelper.RegisterStubService(); WixBindingTestsHelper.RegisterResourceStringsWithSharpDevelopResourceManager(); } [Test] public void MissingX() { WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); WixDocument doc = new WixDocument(project); string xml = "\r\n" + "\t\r\n" + "\t\t\r\n" + "\t\t\t\r\n" + "\t\t\t\t\r\n" + "\t\t\t\r\n" + "\t\t\r\n" + "\t\r\n" + ""; doc.LoadXml(xml); WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader()); try { wixDialog.CreateDialog(); Assert.Fail("Expected an exception before this line."); } catch (WixDialogException ex) { Assert.AreEqual("Control", ex.ElementName); Assert.AreEqual("Next", ex.Id); Assert.AreEqual("Required attribute 'X' is missing.", ex.Message); } } [Test] public void MissingWidth() { WixProject project = WixBindingTestsHelper.CreateEmptyWixProject(); WixDocument doc = new WixDocument(project); string xml = "\r\n" + "\t\r\n" + "\t\t\r\n" + "\t\t\t\r\n" + "\t\t\t\t\r\n" + "\t\t\t\r\n" + "\t\t\r\n" + "\t\r\n" + ""; doc.LoadXml(xml); WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader()); try { wixDialog.CreateDialog(); Assert.Fail("Expected an exception before this line."); } catch (WixDialogException ex) { Assert.AreEqual("Control", ex.ElementName); Assert.AreEqual("Next", ex.Id); Assert.AreEqual("Required attribute 'Y' is missing.", ex.Message); } } } }