public void InitializeWriteOnlyProperty()
    {
        PropertyControlPanel control = new PropertyControlPanel();
        PropertyInfo         info    = typeof(TestClass).GetProperty("WriteOnlyProperty");

        control.Initialize(info);
        Assert.IsTrue(control.buttonSet.Enabled);
    }
    public void HandleNullResult()
    {
        PropertyControlPanel control = new PropertyControlPanel();
        PropertyInfo         info    = typeof(TestClass).GetProperty("NullProperty");

        control.Initialize(info);
        Assert.AreEqual("(null)", control.previewControl.textBoxToString.Text);
    }
    public void InitializeCallsGetterIfAvailable()
    {
        PropertyControlPanel control = new PropertyControlPanel();
        PropertyInfo         info    = typeof(TestClass).GetProperty("PublicStaticProperty");

        control.Initialize(info);
        Assert.AreEqual("365", control.previewControl.textBoxToString.Text);
    }
    public void SetterUpdatesPreviewTabs()
    {
        PropertyControlPanel control = new PropertyControlPanel();
        PropertyInfo         info    = typeof(TestClass).GetProperty("PublicStaticProperty");

        control.Initialize(info);
        control.buttonSet_Click(null, new EventArgs());
        Assert.AreEqual("0", control.previewControl.textBoxToString.Text);
    }
    public void InvokeSetMultipleTimes()
    {
        TestClass.set_counter = 0;
        PropertyControlPanel control = new PropertyControlPanel();
        PropertyInfo         info    = typeof(TestClass).GetProperty("PublicStaticProperty");

        control.Initialize(info);
        control.InvokeCount = 28;
        control.buttonSet_Click(null, null);
        Assert.AreEqual(28, TestClass.set_counter);
    }
    public void ResetButtonClearsCountersAndListBox()
    {
        PropertyControlPanel control = new PropertyControlPanel();
        PropertyInfo         info    = typeof(TestClass).GetProperty("PublicStaticProperty");

        control.Initialize(info);
        control.buttonGet_Click(null, null);
        control.buttonGet_Click(null, null);
        control.buttonGet_Click(null, null);
        control.buttonGet_Click(null, null);
        control.buttonReset_Click(null, null);
        Assert.AreEqual(0, control.average_count);
        Assert.AreEqual(0, control.comboBoxMessageBar.Items.Count);
        Assert.IsFalse(control.comboBoxMessageBar.Enabled);
    }
    public void InitializationWithPropertyInfo()
    {
        PropertyControlPanel control = new PropertyControlPanel();

        control.previewControl.textBoxToString.Text = "something";
        PropertyInfo info = typeof(TestClass).GetProperty("PublicStaticProperty");

        control.Initialize(info);
        Assert.AreSame(info, control.property_under_test);
        Assert.AreEqual(4, control.arguments_control.tableLayoutPanel.Controls.Count);
        Assert.IsTrue(control.buttonGet.Enabled);
        Assert.IsTrue(control.buttonSet.Enabled);
        Assert.IsFalse(control.comboBoxMessageBar.Enabled);
        Assert.AreNotEqual(0, control.comboBoxMessageBar.Items.Count);
        Assert.IsTrue(control.buttonDrillDown.Visible);
        Assert.IsTrue(control.buttonAddToPool.Visible);
    }
    public void DefaultInitialization()
    {
        PropertyControlPanel control = new PropertyControlPanel();

        control.previewControl.textBoxToString.Text = "something";
        control.buttonDrillDown.Visible             = true;
        control.buttonAddToPool.Visible             = true;
        control.Initialize();
        Assert.IsNull(control.instance_under_test);
        Assert.IsNull(control.property_under_test);
        Assert.AreEqual(0, control.arguments_control.tableLayoutPanel.Controls.Count);
        Assert.IsFalse(control.buttonGet.Enabled);
        Assert.IsFalse(control.buttonSet.Enabled);
        Assert.IsFalse(control.buttonDrillDown.Visible);
        Assert.IsFalse(control.buttonAddToPool.Visible);
        Assert.IsFalse(control.comboBoxMessageBar.Enabled);
    }