c# - Can't load images from project during vs2012 load test -
i'm trying load test wcf service visual studio 2012 web performance , load test project. added unit test file shown below , execute them load test. seems work fine except populating image byte[] in test object.
unit test
[testmethod, testcategory("wcf - primary tests")] public void eventitem_insert() { //arrange var service = new eventservicereference.servicecontractclient(); var item = unittesthelpers.eventitemfactory(guid.newguid(), guid.newguid()); debug.writeline(item.data.length.tostring()); //act guid pk = service.saveeventitem(item); //assert assert.arenotequal(guid.empty, pk, "the key returned empty"); }
snippet calls image load routine eventitemfactory.
eventitem.data = (byte[])loadtestimagefromproject();
code issues is. works when run unit test test explorer throws invalid parameter when called load test.
public static byte[] loadtestimagefromproject() { fileinfo fileinfo = new fileinfo(system.reflection.assembly.getexecutingassembly().location); string file = path.combine(fileinfo.directoryname, @"assets\bg.jpg"); bitmap bmp = new bitmap(file); imageconverter converter = new imageconverter(); byte[] bytearray = (byte[])converter.convertto(bmp, typeof(byte[])); return bytearray; }
thanks in advance help.
i couldn't figure out how reference files project during load test did find workaround.
i added images resource file , worked perfectly.
it had how virtual users handed in test, resource file available project artifacts not.
Comments
Post a Comment