コード例 #1
0
        public void SelectedObject_Null2()
        {
            PropertyGrid pg  = new PropertyGrid();
            EventLogger  log = new EventLogger(pg);

            Assert.IsNull(pg.SelectedObject, "#A1");
            Assert.IsNotNull(pg.SelectedObjects, "#A2");
            Assert.AreEqual(0, pg.SelectedObjects.Length, "#A3");
            Assert.IsNull(pg.SelectedGridItem, "A4");

            pg.SelectedObject = new TextBox();
            Assert.IsNotNull(pg.SelectedObject, "#B1");
            Assert.IsNotNull(pg.SelectedObjects, "#B2");
            Assert.AreEqual(1, pg.SelectedObjects.Length, "#B3");
            Assert.IsNotNull(pg.SelectedGridItem, "B4");
            Assert.AreEqual(1, log.EventsRaised, "B5");
            Assert.AreEqual("SelectedObjectsChanged", log.EventsJoined(";"), "B6");

            pg.SelectedObject = null;
            Assert.IsNull(pg.SelectedObject, "#C1");
            Assert.IsNotNull(pg.SelectedObjects, "#C2");
            Assert.AreEqual(0, pg.SelectedObjects.Length, "#C3");
            Assert.IsNull(pg.SelectedGridItem, "C4");
            Assert.AreEqual(2, log.EventsRaised, "C5");
            Assert.AreEqual("SelectedObjectsChanged;SelectedObjectsChanged", log.EventsJoined(";"), "C6");
        }
コード例 #2
0
        [Test]         // bug #413898
        public void EventOrder_Dialog()
        {
            if (TestHelper.RunningOnUnix)
            {
                Assert.Ignore("#A3 fails");
            }

            string [] expectedEvents =
            {
                "Load",
                "VisibleChanged",
                "GotFocus",
                "Activated",
                "Closing",
                "FormClosing",
                "Closed",
                "FormClosed",
                "VisibleChanged",
                "Deactivate",
                "LostFocus",
                "HandleDestroyed"
            };

            _form = new DelayedCloseForm();
            EventLogger logger = new EventLogger(_form);

            _form.ShowDialog();
            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents), "#A1:" + logger.EventsJoined());
            Assert.AreEqual(1, logger.CountEvents("Load"), "#A2");
            Assert.AreEqual(2, logger.CountEvents("VisibleChanged"), "#A3");
            Assert.AreEqual(1, logger.CountEvents("GotFocus"), "#A4");
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#A5");
            Assert.AreEqual(1, logger.CountEvents("Closing"), "#A6");
            Assert.AreEqual(1, logger.CountEvents("FormClosing"), "#A7");
            Assert.AreEqual(1, logger.CountEvents("Closed"), "#A8");
            Assert.AreEqual(1, logger.CountEvents("FormClosed"), "#A9");
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#A10");
            Assert.AreEqual(1, logger.CountEvents("LostFocus"), "#A11");
            Assert.AreEqual(1, logger.CountEvents("HandleDestroyed"), "#A12");
            Assert.AreEqual(0, logger.CountEvents("Disposed"), "#A13");

            logger.Clear();

            _form.ShowDialog();
            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents), "#B1:" + logger.EventsJoined());
            Assert.AreEqual(1, logger.CountEvents("Load"), "#B2");
            Assert.AreEqual(2, logger.CountEvents("VisibleChanged"), "#B3");
            Assert.AreEqual(1, logger.CountEvents("GotFocus"), "#B4");
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#B5");
            Assert.AreEqual(1, logger.CountEvents("Closing"), "#B6");
            Assert.AreEqual(1, logger.CountEvents("FormClosing"), "#B7");
            Assert.AreEqual(1, logger.CountEvents("Closed"), "#B8");
            Assert.AreEqual(1, logger.CountEvents("FormClosed"), "#B9");
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#B10");
            Assert.AreEqual(1, logger.CountEvents("LostFocus"), "#B11");
            Assert.AreEqual(1, logger.CountEvents("HandleDestroyed"), "#B12");
            Assert.AreEqual(0, logger.CountEvents("Disposed"), "#B13");
        }
コード例 #3
0
		public void TextTest ()
		{
			CheckCulture ();

			DateTimePicker dt = new DateTimePicker ();
			EventLogger log = new EventLogger (dt);
			DateTime tomorrow = DateTime.Today.AddDays (1);

			log.Clear ();
			dt.Value = tomorrow;
			Assert.AreEqual ("", dt.Text, "#1");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged"), "#1.1");

			log.Clear ();
			dt.CreateControl ();
			Assert.AreEqual (tomorrow.ToLongDateString (), dt.Text, "#2");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleCreated"), "#2.1");

			log.Clear ();
			dt.Text = "";
			Assert.AreEqual (DateTime.Today.ToLongDateString (), dt.Text, "#3");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#3.1");
			
			log.Clear ();
			dt.Text = null;
			Assert.AreEqual (DateTime.Today.ToLongDateString (), dt.Text, "#4");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#4.1, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());

			log.Clear (); 
			dt.CustomFormat = "yyyy-MM-dd HH-mm";
			dt.Format = DateTimePickerFormat.Custom;
			Assert.AreEqual (DateTime.Now.ToString (dt.CustomFormat), dt.Text, "#5");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleDestroyed", "HandleCreated", "FormatChanged"), "#5.1");

			log.Clear ();
			dt.CustomFormat = "yyyy-MM-dd";
			Assert.AreEqual (DateTime.Now.ToString (dt.CustomFormat), dt.Text, "#6");
			Assert.AreEqual ("", log.EventsJoined (), "#6.1");
			
			log.Clear ();
			dt.Format = DateTimePickerFormat.Short;
			Assert.AreEqual (DateTime.Now.ToShortDateString (), dt.Text, "#7");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleDestroyed", "HandleCreated", "FormatChanged"), "#7.1");

			dt.Value = DateTime.Today;
			log.Clear ();
			dt.Value = DateTime.Today;
			Assert.AreEqual (0, log.EventsRaised, "#8");

			dt.Text = null;
			log.Clear ();
			dt.Text = null;
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#9, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());
			
			dt.Text = "";
			log.Clear ();
			dt.Text = "";
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#19, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());
		}
コード例 #4
0
		public void SelectedObject_Null2 ()
		{
			PropertyGrid pg = new PropertyGrid ();
			EventLogger log = new EventLogger (pg);
			
			Assert.IsNull (pg.SelectedObject, "#A1");
			Assert.IsNotNull (pg.SelectedObjects, "#A2");
			Assert.AreEqual (0, pg.SelectedObjects.Length, "#A3");
			Assert.IsNull (pg.SelectedGridItem, "A4");
			
			pg.SelectedObject = new TextBox ();
			Assert.IsNotNull (pg.SelectedObject, "#B1");
			Assert.IsNotNull (pg.SelectedObjects, "#B2");
			Assert.AreEqual (1, pg.SelectedObjects.Length, "#B3");
			Assert.IsNotNull (pg.SelectedGridItem, "B4");
			Assert.AreEqual (1, log.EventsRaised, "B5");
			Assert.AreEqual ("SelectedObjectsChanged", log.EventsJoined (";"), "B6");

			pg.SelectedObject = null;
			Assert.IsNull (pg.SelectedObject, "#C1");
			Assert.IsNotNull (pg.SelectedObjects, "#C2");
			Assert.AreEqual (0, pg.SelectedObjects.Length, "#C3");
			Assert.IsNull (pg.SelectedGridItem, "C4");
			Assert.AreEqual (2, log.EventsRaised, "C5");
			Assert.AreEqual ("SelectedObjectsChanged;SelectedObjectsChanged", log.EventsJoined (";"), "C6");
		}
コード例 #5
0
ファイル: FormEventTest.cs プロジェクト: pmq20/mono_forked
        [Test]         // bug #413898
        public void EventOrder()
        {
            if (TestHelper.RunningOnUnix)
            {
                Assert.Ignore("#A3 fails");
            }

            string [] expectedEvents_Show =
            {
                "Load",
                "VisibleChanged",
                "GotFocus",
                "Activated"
            };

            string [] expectedEvents_Close =
            {
                "Closing",
#if NET_2_0
                "FormClosing",
#endif
                "Closed",
#if NET_2_0
                "FormClosed",
#endif
                "Deactivate",
                "LostFocus",
                "HandleDestroyed",
                "Disposed"
            };

            _form = new Form();
            EventLogger logger = new EventLogger(_form);

            _form.Show();
            Application.DoEvents();

            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents_Show), "#A1:" + logger.EventsJoined());
            Assert.AreEqual(1, logger.CountEvents("Load"), "#A2");
            Assert.AreEqual(1, logger.CountEvents("VisibleChanged"), "#A3");
            Assert.AreEqual(1, logger.CountEvents("GotFocus"), "#A4");
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#A5");
            Assert.AreEqual(0, logger.CountEvents("Closing"), "#A6");
#if NET_2_0
            Assert.AreEqual(0, logger.CountEvents("FormClosing"), "#A7");
#endif
            Assert.AreEqual(0, logger.CountEvents("Closed"), "#A8");
#if NET_2_0
            Assert.AreEqual(0, logger.CountEvents("FormClosed"), "#A9");
#endif
            Assert.AreEqual(0, logger.CountEvents("Deactivate"), "#A10");
            Assert.AreEqual(0, logger.CountEvents("LostFocus"), "#A11");
            Assert.AreEqual(0, logger.CountEvents("HandleDestroyed"), "#A12");
            Assert.AreEqual(0, logger.CountEvents("Disposed"), "#A13");

            logger.Clear();
            _form.Close();
            Application.DoEvents();

            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents_Close), "#B1:" + logger.EventsJoined());
            Assert.AreEqual(0, logger.CountEvents("Load"), "#B2");
            Assert.AreEqual(0, logger.CountEvents("VisibleChanged"), "#B3");
            Assert.AreEqual(0, logger.CountEvents("GotFocus"), "#B4");
            Assert.AreEqual(0, logger.CountEvents("Activated"), "#B5");
            Assert.AreEqual(1, logger.CountEvents("Closing"), "#B6");
#if NET_2_0
            Assert.AreEqual(1, logger.CountEvents("FormClosing"), "#B7");
#endif
            Assert.AreEqual(1, logger.CountEvents("Closed"), "#B8");
#if NET_2_0
            Assert.AreEqual(1, logger.CountEvents("FormClosed"), "#B9");
#endif
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#B10");
            Assert.AreEqual(1, logger.CountEvents("LostFocus"), "#B11");
            Assert.AreEqual(1, logger.CountEvents("HandleDestroyed"), "#B12");
            Assert.AreEqual(1, logger.CountEvents("Disposed"), "#B13");
        }
コード例 #6
0
ファイル: FormEventTest.cs プロジェクト: GirlD/mono
		[Test] // bug #413898
		public void EventOrder_Dialog ()
		{
			if (TestHelper.RunningOnUnix)
				Assert.Ignore ("#A3 fails");

			string [] expectedEvents = {
				"Load",
				"VisibleChanged",
				"GotFocus",
				"Activated",
				"Closing",
#if NET_2_0
				"FormClosing",
#endif
				"Closed",
#if NET_2_0
				"FormClosed",
#endif
				"VisibleChanged",
				"Deactivate",
				"LostFocus",
				"HandleDestroyed" };

			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);

			_form.ShowDialog ();
			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents), "#A1:" + logger.EventsJoined ());
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#A2");
			Assert.AreEqual (2, logger.CountEvents ("VisibleChanged"), "#A3");
			Assert.AreEqual (1, logger.CountEvents ("GotFocus"), "#A4");
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#A5");
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#A6");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"), "#A7");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#A8");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#A9");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#A10");
			Assert.AreEqual (1, logger.CountEvents ("LostFocus"), "#A11");
			Assert.AreEqual (1, logger.CountEvents ("HandleDestroyed"), "#A12");
			Assert.AreEqual (0, logger.CountEvents ("Disposed"), "#A13");

			logger.Clear ();

			_form.ShowDialog ();
			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents), "#B1:" + logger.EventsJoined ());
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#B2");
			Assert.AreEqual (2, logger.CountEvents ("VisibleChanged"), "#B3");
			Assert.AreEqual (1, logger.CountEvents ("GotFocus"), "#B4");
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#B5");
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#B6");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"), "#B7");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#B8");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#B9");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#B10");
			Assert.AreEqual (1, logger.CountEvents ("LostFocus"), "#B11");
			Assert.AreEqual (1, logger.CountEvents ("HandleDestroyed"), "#B12");
			Assert.AreEqual (0, logger.CountEvents ("Disposed"), "#B13");
		}
コード例 #7
0
ファイル: FormTest.cs プロジェクト: KonajuGames/SharpLang
		public void ParentedFormEventTest ()
		{

			using (Form Main = new Form ()) {
				Form Child = new Form ();
				Child.TopLevel = false;
				Child.Visible = true;
				Main.ShowInTaskbar = false;
				Main.Show ();

				EventLogger log = new EventLogger (Child);
				Assert.AreEqual (true, Child.Visible, "#A0");
				Main.Controls.Add (Child);
				Assert.AreEqual (true, Child.Visible, "#B0");
				Assert.AreEqual ("ParentChanged;BindingContextChanged;Layout;VisibleChanged;BindingContextChanged;BindingContextChanged", log.EventsJoined (), "#B1");
			}
		}
コード例 #8
0
ファイル: FormEventTest.cs プロジェクト: Profit0004/mono
		[Test] // bug #413898
		public void EventOrder ()
		{
			if (TestHelper.RunningOnUnix)
				Assert.Ignore ("#A3 fails");

			string [] expectedEvents_Show = {
				"Load",
				"VisibleChanged",
				"GotFocus",
				"Activated" };

			string [] expectedEvents_Close = {
				"Closing",
				"FormClosing",
				"Closed",
				"FormClosed",
				"Deactivate",
				"LostFocus",
				"HandleDestroyed",
				"Disposed" };

			_form = new Form ();
			EventLogger logger = new EventLogger (_form);

			_form.Show ();
			Application.DoEvents ();

			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents_Show), "#A1:" + logger.EventsJoined());
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#A2");
			Assert.AreEqual (1, logger.CountEvents ("VisibleChanged"), "#A3");
			Assert.AreEqual (1, logger.CountEvents ("GotFocus"), "#A4");
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#A5");
			Assert.AreEqual (0, logger.CountEvents ("Closing"), "#A6");
			Assert.AreEqual (0, logger.CountEvents ("FormClosing"), "#A7");
			Assert.AreEqual (0, logger.CountEvents ("Closed"), "#A8");
			Assert.AreEqual (0, logger.CountEvents ("FormClosed"), "#A9");
			Assert.AreEqual (0, logger.CountEvents ("Deactivate"), "#A10");
			Assert.AreEqual (0, logger.CountEvents ("LostFocus"), "#A11");
			Assert.AreEqual (0, logger.CountEvents ("HandleDestroyed"), "#A12");
			Assert.AreEqual (0, logger.CountEvents ("Disposed"), "#A13");

			logger.Clear ();
			_form.Close ();
			Application.DoEvents ();

			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents_Close), "#B1:" + logger.EventsJoined ());
			Assert.AreEqual (0, logger.CountEvents ("Load"), "#B2");
			Assert.AreEqual (0, logger.CountEvents ("VisibleChanged"), "#B3");
			Assert.AreEqual (0, logger.CountEvents ("GotFocus"), "#B4");
			Assert.AreEqual (0, logger.CountEvents ("Activated"), "#B5");
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#B6");
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"), "#B7");
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#B8");
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#B9");
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#B10");
			Assert.AreEqual (1, logger.CountEvents ("LostFocus"), "#B11");
			Assert.AreEqual (1, logger.CountEvents ("HandleDestroyed"), "#B12");
			Assert.AreEqual (1, logger.CountEvents ("Disposed"), "#B13");
		}