public void InvokingCreateUpdatesStatsListing()
    {
        ConstructorControlPanel control = new ConstructorControlPanel();
        ConstructorInfo         info    = typeof(TestClass).GetConstructor(new Type[] { });

        control.Initialize(info);
        control.OnCreateClick(null, null);
        Assert.IsTrue(control.comboBoxMessageBar.Items[0].ToString().EndsWith("to Create."));
    }
    public void InitializationWithInfo()
    {
        ConstructorControlPanel control = new ConstructorControlPanel();
        ConstructorInfo         info    = typeof(TestClass).GetConstructor(new Type[] { });

        control.comboBoxMessageBar.Items.Add("something");
        control.Initialize(info);
        Assert.AreEqual(0, control.comboBoxMessageBar.Items.Count);
        Assert.IsFalse(control.buttonDrillDown.Visible);
        Assert.IsFalse(control.buttonAddToPool.Visible);
    }
    public void PlusButtonAddsInstanceToObjectPool()
    {
        ObjectPool.pool.Clear();
        ConstructorControlPanel control = new ConstructorControlPanel();
        ConstructorInfo         info    = typeof(TestClass).GetConstructor(new Type[] { });

        control.Initialize(info);
        string instance = "something";

        control.Lastresult = instance;
        control.OnAddToPool(null, null);
        Assert.IsTrue(ObjectPool.pool.Contains(instance));
    }
    public void AddingInstanceToObjectPoolLogsMessage()
    {
        ObjectPool.pool.Clear();
        ConstructorControlPanel control = new ConstructorControlPanel();
        ConstructorInfo         info    = typeof(TestClass).GetConstructor(new Type[] { });

        control.Initialize(info);
        control.comboBoxMessageBar.Items.Add("other stuff 1");
        control.comboBoxMessageBar.Items.Add("other stuff 2");
        string instance = "something";

        control.Lastresult = instance;
        control.OnAddToPool(null, null);
        Assert.AreEqual("String added to Object pool.", (string)control.comboBoxMessageBar.Items[0]);
    }
    public void ResetButtonClearsCountersAndListBox()
    {
        ConstructorControlPanel control = new ConstructorControlPanel();
        ConstructorInfo         info    = typeof(TestClass).GetConstructor(new Type[] { });

        control.Initialize(info);
        control.OnCreateClick(null, null);
        control.OnCreateClick(null, null);
        control.OnCreateClick(null, null);
        control.OnCreateClick(null, null);
        control.OnCreateClick(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 DoNotAddSameInstanceToObjectPool()
    {
        ObjectPool.pool.Clear();
        ConstructorControlPanel control = new ConstructorControlPanel();
        ConstructorInfo         info    = typeof(TestClass).GetConstructor(new Type[] { });

        control.Initialize(info);
        string instance = "something";

        control.Lastresult = instance;
        control.OnAddToPool(null, null);
        control.OnAddToPool(null, null);
        control.OnAddToPool(null, null);
        control.OnAddToPool(null, null);
        Assert.AreEqual(1, ObjectPool.pool.Count);
    }
    public void InitializationWithNoInfo()
    {
        ConstructorControlPanel control = new ConstructorControlPanel();

        control.comboBoxMessageBar.Enabled = true;
        control.comboBoxMessageBar.Items.Add("something");
        control.buttonDrillDown.Visible = true;
        control.buttonAddToPool.Visible = true;
        control.Initialize();
        Assert.AreEqual(0, control.arguments_control.tableLayoutPanel.Controls.Count);
        Assert.IsFalse(control.buttonCreate.Enabled);
        Assert.AreEqual(0, control.comboBoxMessageBar.Items.Count);
        Assert.AreEqual(0, control.previewControl.textBoxToString.Text.Length);
        Assert.IsFalse(control.buttonDrillDown.Visible);
        Assert.IsFalse(control.buttonAddToPool.Visible);
        Assert.IsFalse(control.comboBoxMessageBar.Enabled);
    }