예제 #1
0
 public void MainMenu_Ctor_Default()
 {
     using var menu = new SubMainMenu();
     Assert.True(menu.CanRaiseEvents);
     Assert.Null(menu.Container);
     Assert.False(menu.DesignMode);
     Assert.NotNull(menu.Events);
     Assert.Same(menu.Events, menu.Events);
     Assert.Empty(menu.MenuItems);
     Assert.Empty(menu.Name);
     Assert.False(menu.IsParent);
     Assert.Equal(RightToLeft.Inherit, menu.RightToLeft);
     Assert.Null(menu.GetForm());
     Assert.Null(menu.Site);
     Assert.Null(menu.Tag);
 }
예제 #2
0
 public void MainMenu_Ctor_MenuItemArray(MenuItem[] items, bool expectedIsParent, MenuItem[] expectedItems)
 {
     using var menu = new SubMainMenu(items);
     Assert.True(menu.CanRaiseEvents);
     Assert.Null(menu.Container);
     Assert.False(menu.DesignMode);
     Assert.NotNull(menu.Events);
     Assert.Same(menu.Events, menu.Events);
     Assert.Equal(expectedIsParent, menu.IsParent);
     Assert.Equal(expectedItems, menu.MenuItems.Cast <MenuItem>());
     for (int i = 0; i < menu.MenuItems.Count; i++)
     {
         Assert.Equal(i, menu.MenuItems[i].Index);
         Assert.Equal(menu, menu.MenuItems[i].Parent);
     }
     Assert.Empty(menu.Name);
     Assert.Equal(RightToLeft.Inherit, menu.RightToLeft);
     Assert.Null(menu.GetForm());
     Assert.Null(menu.Site);
     Assert.Null(menu.Tag);
 }
예제 #3
0
        public void MainMenu_OnCollapse_Invoke_CallsCollapse(EventArgs eventArgs)
        {
            using var menu = new SubMainMenu();
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(menu, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };

            // Call with handler.
            menu.Collapse += handler;
            menu.OnCollapse(eventArgs);
            Assert.Equal(1, callCount);

            // Remove handler.
            menu.Collapse -= handler;
            menu.OnCollapse(eventArgs);
            Assert.Equal(1, callCount);
        }
 // Function that login to our game.
 private void Button_Login(object sender, RoutedEventArgs e)
 {
     try
     {
         // Connect to the model.
         (Application.Current as App).SimulatorModel.Connect(ip.Text, int.Parse(port.Text));
         // Create the SubMainMenu.
         SubMainMenu view = new SubMainMenu();
         // Change the boolean type to true for closing the program.
         closeApp = true;
         this.Close();
         // Show the SubMainMenu.
         view.Show();
     }// Something got wrong
     catch (Exception)
     {
         string message = String.Format("The server or ip are not good, please try again.\n If you want, " +
                                        "you can try the default ip and port");
         MessageBox.Show(message, "", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #5
0
 public void MainMenu_CreateMenuHandle_Invoke_ReturnsExpected()
 {
     using var menu = new SubMainMenu();
     Assert.NotEqual(IntPtr.Zero, menu.CreateMenuHandle());
 }