Professional.Open.Source.dot.NET.Development.Programming.with.NAnt.NUnit.NDoc [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional.Open.Source.dot.NET.Development.Programming.with.NAnt.NUnit.NDoc [Electronic resources] - نسخه متنی

John Wait

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید

NUnitASP


Once you start religiously using unit tests, you will find that user interfaces are really hard to unit test. Yes, of course you can use reflection to call all the control's Event Handlers but this is not adequate because most UIs have some sort of progression to their functionality. For instance, it is common for UIs to disable a button until some other dependent action is performed. There is screen-recording software available to "record" your clicks and play them back in an automated fashion, but if you are using an ASP.NET Webform for your application, there is an easier wayNUnit ASP. As an extension to NUnit, NUnitASP's functionality will already be somewhat familiar. Running the tests from the NUnit UI or within NAnt is exactly the same, and so is the results report. NUnitASP currently supports the following ASP.NET controls:

  • Button

  • CheckBox

  • DataGrid

  • DropDownList

  • Label

  • LinkButton

  • Panel

  • RadioButton

  • TextBox

  • UserControl

  • ValidationSummary


Listing 6.6 shows how easy it is to link test code to a control on your page.

Listing 6.6. NUnitASP Test


[Test]
public TestASP()
{
LinkButtonTester linktester = new LinkButtonTester("linkButton1",
CurrentWebForm);
Browser.GetPage("http://localhost/examples/link.aspx");
linktester.Click();
AssertEquals("Clicked once.", linktester.Text);
linktester.Click();
AssertEquals("Clicked twice.", linktester.Text);
}

This tests that a LinkButton was clicked twice. By using this model, you can test the progressions of your user interfaces. The functionality of the button on the tested page is only to change its text to the amount of times it was clicked. The Assert ensures that the button truly was clicked twice.

NUnitASP is not only a great study in extending NUnit but also a very useful tool in ASP.NET testing and development.

/ 275