using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using MiniSqlQuery.Core;
using NUnit.Extensions.Forms;
using Rhino.Mocks;
namespace MiniSqlQuery.Tests.Gui
{
///
/// Query Form Tester class for use with NUnitForms.
/// Inherit from this class in standard unit tests.
///
public class QueryFormTester : NUnitFormTest
{
protected IApplicationServices StubAppServices;
protected IApplicationSettings StubAppSettings;
protected IHostWindow StubHostWindow;
protected IQueryEditor QueryEditor;
protected QueryForm QueryForm;
public QueryFormTester()
{
}
///
/// Sets up various mock object required for the form to run (does not cover query execution).
///
public override void Setup()
{
SetUpApplicationServicesMock();
SetUpApplicationSettingsMock();
SetUpHostWindowMock();
base.Setup();
}
///
/// Sets up an empty mock object.
///
public virtual void SetUpApplicationServicesMock()
{
StubAppServices = MockRepository.GenerateStub();
}
///
/// Sets up an empty mock object.
///
public virtual void SetUpApplicationSettingsMock()
{
StubAppSettings = MockRepository.GenerateStub();
}
///
/// Sets up a basic mock assigning it to .
///
///
/// The SetStaus method just takes any parameters.
///
public virtual void SetUpHostWindowMock()
{
StubHostWindow = MockRepository.GenerateStub();
StubAppServices.Expect(services => services.HostWindow).Return(StubHostWindow).Repeat.Any();
}
///
/// Displays an basic query editor form with the relevent dependency injection applied.
///
public virtual void ShowBasicForm()
{
QueryForm = new QueryForm(StubAppServices, StubAppSettings);
QueryEditor = QueryForm; // for reference by interface
QueryForm.Show();
Application.DoEvents(); // ensure fully displayed
}
}
}