Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet410/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   406   407   408   409   410   411   412   413   ...   453
LISTINg 18-4: 
 Developing an application test harness
# Print out statements of everything the test is doing.
print ‘Beginning Test’
print ‘Loading clr’
continues
548592c18.indd 399
2/24/10 12:49:46 PM
www.finebook.ir


400

CHAPTER 18
Using ironPython for APPlicAtion testing
import clr
print ‘Loading System assembly support’
import System
print ‘Creating a blank event argument.’
EventArg = System.EventArgs()
print ‘Loading test module’
clr.AddReferenceToFile(‘TestApplication.EXE’)
from TestApplication import *
CreateHeading(‘0001’, ‘Creating a test form’)
MyForm = Form1()
CheckType(MyForm, ‘TestApplication.Form1’)
CreateFooter()
CreateHeading(‘0002’, ‘Testing a default add’)
MyForm.btnAdd_Click(object, EventArg)
ShowInit(MyForm.txtValue1.Text, MyForm.txtValue2.Text)
ShowValues(‘2’, MyForm.txtResult.Text)
CreateFooter()
CreateHeading(‘0003’, ‘Testing a default subtract’)
MyForm.btnSubtract_Click(object, EventArg)
ShowInit(MyForm.txtValue1.Text, MyForm.txtValue2.Text)
ShowValues(‘0’, MyForm.txtResult.Text)
CreateFooter()
CreateHeading(‘0004’, ‘Testing add with one change’)
MyForm.txtValue1.Text = ‘5’
MyForm.btnAdd_Click(object, EventArg)
ShowInit(MyForm.txtValue1.Text, MyForm.txtValue2.Text)
ShowValues(‘6’, MyForm.txtResult.Text)
CreateFooter()
# Pause after the debug session.
raw_input(‘\nPress any key to continue...’)
The test script begins by loading the required code for the test, beginning with 
clr
. Because this test 
has to work with event handlers, it needs to load the System assembly and create a 
System.EventArgs
object, 
EventArg
. Because the event handlers in this application don’t actually use the event arguments, 
EventArg
is actually a default object with no content. The call simply won’t succeed without it, how-
ever, so you must create it.
After the script finishes the prerequisites, it performs the first test, which is to create the Windows 
Forms object, 
Form1
, as 
MyForm
. The creation process could fail; you want to verify that 
MyForm
isn’t 
null, so that’s the first test that relies on the 
CheckType()
function. You don’t have to show the form 
LISTINg 18-4 
(continued)
548592c18.indd 400
2/24/10 12:49:46 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   406   407   408   409   410   411   412   413   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish