/// <summary>Mocks a subscriber for the events of a choice</summary> /// <param name="choice">Choice to mock an event subscriber for</param> /// <returns>The mocked event subscriber</returns> private IChoiceSubscriber mockSubscriber(ChoiceControl choice) { IChoiceSubscriber mockedSubscriber = this.mockery.NewMock <IChoiceSubscriber>(); choice.Changed += new EventHandler(mockedSubscriber.Changed); return(mockedSubscriber); }
/// <summary>Mocks a subscriber for the events of a choice</summary> /// <param name="choice">Choice to mock an event subscriber for</param> /// <returns>The mocked event subscriber</returns> private Mock <IChoiceSubscriber> mockSubscriber(ChoiceControl choice) { Mock <IChoiceSubscriber> mockedSubscriber = this.mockery.CreateMock <IChoiceSubscriber>(); choice.Changed += new EventHandler(mockedSubscriber.MockObject.Changed); return(mockedSubscriber); }
/// <summary>Disables all sibling choices on the same level</summary> private void unselectSiblings() { // Disable any other choices in the same frame if (Parent != null) { Collection <Control> siblings = Parent.Children; for (int index = 0; index < siblings.Count; ++index) { ChoiceControl control = siblings[index] as ChoiceControl; if ((control != null) && (control != this) && (control.Selected)) { control.Selected = false; control.OnChanged(); } } } }
public void TestChoiceWithoutParent() { ChoiceControl choice = new ChoiceControl(); choice.Bounds = new UniRectangle(10, 10, 100, 100); IChoiceSubscriber mockedSubscriber = mockSubscriber(choice); Expect.Once.On(mockedSubscriber).Method("Changed").WithAnyArguments(); Assert.IsFalse(choice.Selected); // Move the mouse over the choice and do a left-click choice.ProcessMouseMove(0, 0, 50, 50); choice.ProcessMousePress(MouseButtons.Left); choice.ProcessMouseRelease(MouseButtons.Left); this.mockery.VerifyAllExpectationsHaveBeenMet(); Assert.IsTrue(choice.Selected); }
public void TestClickOnSelectedChoice() { ChoiceControl choice = new ChoiceControl(); choice.Bounds = new UniRectangle(10, 10, 100, 100); choice.Selected = true; Mock <IChoiceSubscriber> mockedSubscriber = mockSubscriber(choice); mockedSubscriber.Expects.No.Method(m => m.Changed(null, null)).WithAnyArguments(); Assert.IsTrue(choice.Selected); // Move the mouse over the choice and do a left-click choice.ProcessMouseMove(0, 0, 50, 50); choice.ProcessMousePress(MouseButtons.Left); choice.ProcessMouseRelease(MouseButtons.Left); this.mockery.VerifyAllExpectationsHaveBeenMet(); Assert.IsTrue(choice.Selected); }
protected void InitializeComponents() { this.callsignLabel = new LabelControl(); this.tagLabel = new LabelControl(); this.hostLabel = new LabelControl(); this.teamLabel = new LabelControl(); this.callsignInput = new InputControl(); this.tagInput = new InputControl(); this.hostInput = new InputControl(); this.joinButton = new ButtonControl(); this.backButton = new ButtonControl(); this.teamChoice = new Control(); this.redTeam = new ChoiceControl(); this.blueTeam = new ChoiceControl(); this.greenTeam = new ChoiceControl(); this.callsignLabel.Text = "Callsign: "; this.callsignLabel.Bounds = new UniRectangle(new UniScalar(.7f, 0f), new UniScalar(.2f, 0f), 50, 24); this.callsignInput.Bounds = new UniRectangle(new UniScalar(.7f, 80f), new UniScalar(0.2f, 0f), 150, 24); this.callsignInput.Enabled = true; this.tagLabel.Text = "Tag: "; this.tagLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.3f, 0f), 50, 24); this.tagInput.Bounds = new UniRectangle(new UniScalar(0.7f, 80f), new UniScalar(0.3f, 0f), 150, 24); this.tagInput.Enabled = true; this.hostLabel.Text = "Host: "; this.hostLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.4f, 0f), 50, 24); this.hostInput.Bounds = new UniRectangle(new UniScalar(0.7f, 80f), new UniScalar(0.4f, 0f), 150, 24); this.hostInput.Enabled = true; this.teamLabel.Text = "Team: "; this.teamLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.5f, 0f), 50, 24); this.teamChoice.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.5f, 0f), 150, 94); this.redTeam.Text = "Red Team"; this.redTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 10f), 10, 10); this.redTeam.Enabled = true; this.blueTeam.Text = "Blue Team"; this.blueTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 30f), 10, 10); this.blueTeam.Enabled = true; this.greenTeam.Text = "Green Team"; this.greenTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 50f), 10, 10); this.greenTeam.Enabled = true; this.joinButton.Text = "Join!"; this.joinButton.Bounds = new UniRectangle(new UniScalar(.7f, 80f), new UniScalar(0.7f, 0f), 150, 72); // 80, 24 for regular button this.backButton.Text = "Back"; this.backButton.Bounds = new UniRectangle(new UniScalar(0.1f, 0.0f), new UniScalar(0.9f, 0f), 80, 24); joinScreen.Desktop.Children.Add(callsignLabel); joinScreen.Desktop.Children.Add(callsignInput); joinScreen.Desktop.Children.Add(tagLabel); joinScreen.Desktop.Children.Add(tagInput); joinScreen.Desktop.Children.Add(hostLabel); joinScreen.Desktop.Children.Add(hostInput); joinScreen.Desktop.Children.Add(teamLabel); joinScreen.Desktop.Children.Add(teamChoice); joinScreen.Desktop.Children.Add(joinButton); joinScreen.Desktop.Children.Add(backButton); teamChoice.Children.Add(redTeam); teamChoice.Children.Add(blueTeam); teamChoice.Children.Add(greenTeam); }
private void LoadContent(Screen mainScreen, ContentManager content) { background = content.Load<Texture2D>("Images\\CreateRoom\\background2"); header = content.Load<SpriteFont>("Images\\CreateRoom\\header"); LabelControl roomNameLabel = new LabelControl("Room Name"); roomNameLabel.Bounds = new UniRectangle(44, 91, 98, 20); roomNameLabel.Name = "Label Room Name"; roomNameInput = new InputControl(); roomNameInput.Bounds = new UniRectangle(217, 88, 213, 26); roomNameInput.Name = "Input Room Name"; LabelControl maxPlayerLabel = new LabelControl("Maimum Player"); maxPlayerLabel.Bounds = new UniRectangle(44, 155, 123, 20); maxPlayerLabel.Name = "Label Maximum Player"; twoChoice = new ChoiceControl(); twoChoice.Name = "Choice Two Player"; twoChoice.Text = "2"; twoChoice.Bounds = new UniRectangle(217, 155, 35, 20); twoChoice.Selected = true; fourChoice = new ChoiceControl(); fourChoice.Name = "Choice Four Player"; fourChoice.Text = "4"; fourChoice.Bounds = new UniRectangle(258, 155, 35, 20); sixChoice = new ChoiceControl(); sixChoice.Name = "Choice Six Player"; sixChoice.Text = "6"; sixChoice.Bounds = new UniRectangle(299, 155, 35, 20); eightChoice = new ChoiceControl(); eightChoice.Name = "Choice Eight Player"; eightChoice.Text = "8"; eightChoice.Bounds = new UniRectangle(340, 155, 35, 20); ButtonControl createRoomButton = new ButtonControl(); createRoomButton.Bounds = new UniRectangle(48, 208, 104, 46); createRoomButton.Name = "Create Room Button"; createRoomButton.Pressed += new EventHandler(createRoomPressed); createRoomButton.Text = "Create"; ButtonControl cancelButton = new ButtonControl(); cancelButton.Bounds = new UniRectangle(326, 208, 104, 46); cancelButton.Name = "Cancel Button"; cancelButton.Pressed += new EventHandler(cancelPressed); cancelButton.Text = "Cancel"; mainScreen.Desktop.Children.Add(roomNameLabel); mainScreen.Desktop.Children.Add(roomNameInput); mainScreen.Desktop.Children.Add(maxPlayerLabel); mainScreen.Desktop.Children.Add(twoChoice); mainScreen.Desktop.Children.Add(fourChoice); mainScreen.Desktop.Children.Add(sixChoice); mainScreen.Desktop.Children.Add(eightChoice); mainScreen.Desktop.Children.Add(createRoomButton); mainScreen.Desktop.Children.Add(cancelButton); }
/// <summary>Mocks a subscriber for the events of a choice</summary> /// <param name="choice">Choice to mock an event subscriber for</param> /// <returns>The mocked event subscriber</returns> private IChoiceSubscriber mockSubscriber(ChoiceControl choice) { IChoiceSubscriber mockedSubscriber = this.mockery.NewMock<IChoiceSubscriber>(); choice.Changed += new EventHandler(mockedSubscriber.Changed); return mockedSubscriber; }