|
i need to create some nunit tests for a method, but here's the problem.
i have an object InternalUser it has a method Authenticate(), this one fires events depending on authentication is successful or not.
public InternalUser Authenticate(string userName, string password)
{
Events.PreAuthentication(userName, password, State.PreAuthentication);
...more stuff here...
}
in events class
public static void PreAuthentication(...)
{
Application.Instance().ExecutePreAuthentication(...);
}
in application class
internal static Application Instance()
{
in here i use HttpContext so nunit fails saying no context here.
}
ihave other methods that do the same, but i cant create tests for these because nunit says no context available, any ideas on how i can get around this problem?
thanks
|
|
|
|
|
There isn't an HttpContext beccause you aren't running in asp.net. I've been thinking about modifing one of my articles to allow testing like this. Would you be interested?
For a quick fix, is there any way to mimic the calls you make to HttpContext if it is null? Ie. add code if (HttpContext.Current == null) //etc. If not, another short term solution is to use something like nunitasp.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
yeah id be very interested, i could change it to work without HttpContext.
i cant use nunitasp because the frontend pages havent been created yet.
|
|
|
|
|
after looking around google i found this
http://www.biasecurities.com/blogs/jim/archive/2005/08/11/2058.aspx, works like a charm
|
|
|
|
|
My C# app needs to call a C++ SDK ( for controlling a digital camera ). I started writing a MC++ dll to wrap it, but I've come unstuck. The SDK uses function pointers, and when I tried to put those in the MC++ app, they would not compile, because everything was garbage collected. __nogc on the class just caused new errors. I also tried building a standard C++ DLL and pInvoking it, but my early attempts were not successful. I'm thinking the third option is COM, however I want to pass Bitmap objects into C#, and also I need to pass a HWND from C# to the dll, for it to draw an image preview on to.
What's the best way for me to go about this ? Is there a way around the MC++ problem ? It seems the best idea to me, but as I've come to a problem, I'm stopping to re-evaluate my approach...
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
The SDK uses function pointers, and when I tried to put those in the MC++ app, they would not compile, because everything was garbage collected. __nogc on the class just caused new errors.
Compile all unmanaged code as unmanaged, without /clr. But its weird you say it cant deal with function pointers. What errors are you getting?
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
leppie wrote:
Compile all unmanaged code as unmanaged, without /clr.
How do I then call it from C# ? Where does the MC++ code go into it ?
I get errors like this :
d:\Contract Work\Fotovision\Imaging\Imaging.cpp(121): error C2664: 'CDStartViewfinder' : cannot convert parameter 3 from 'cdUInt32 (cdVoid *,cdUInt32,cdUInt32,cdContext)' to 'cdViewFinderCallbackFunction (__stdcall *)'
d:\Contract Work\Fotovision\Imaging\Imaging.cpp(136): error C2440: 'type cast' : cannot convert from 'LPVOID' to 'Imaging::Canon __gc *'
The second was for passing this into a function.
If I put __nogc on the class, I get this:
d:\Contract Work\Fotovision\Imaging\Imaging.h(22): error C3381: 'Imaging::Canon' : an assembly access specifier can only be applied to a managed type
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am displaying all members of class Test:
Type ClassType = typeof(Test);
MemberInfo[] Members = ClassType.GetMembers();
foreach(MemberInfo Member in Members)
{
Writer.WriteLine("<" + Member.Name + ">" + <big>???</big>));
}
and I would like also to display in the same foreach loop values of these members of given object Test. How to make it?
|
|
|
|
|
Make the function recursive, and keep calling it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I cannot see a difference... I must display a value of a member, but this member is different each time.
|
|
|
|
|
Because you don't know how deep you need to go, the program decides for you, by calling itself until there are no more properties to display.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
but how this function should know which member is to be showned?
|
|
|
|
|
It needs to change from it's current signature to take an object and use reflection to work out what the properties are on the object, and what the object is.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm... but still, I don`t know how to display the value of the member after using reflection...
Maybe could you support your post with code/pseudo-code of that function?
anyway, tnx for your time
|
|
|
|
|
Oh, sorry. I thought you wanted to walk objects that were properties and had properties. You want to walk the objects you're walking now, and get their values. Try this[^] article for info.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
use recursive function function which call its self
MCAD
-- modified at 18:03 Monday 5th September, 2005
|
|
|
|
|
Hi,
I'm trying to find a way to do something like CustomDraw in a Windows.Forms.ListView.
What I want to do is: reuse the scrolling, selection, and column resizing, but draw each "cell" manually.
I found references to Owner/CustomDraw only in .NET 2.0 (that's VS8, right? )
Is this possible?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
The only way I know of with 1.1 is to subclass ListView and override the WndProc method and listen for the relevant messages (like you would with a non .Net app). This article[^] is a pretty good example.
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
Hello All,
I am tring to redrew the button to be a Circleur button. but affte i did it there is a rectangle apper when i click the button.
How can i remove this rectangle or disable it?
Regards
Hay
|
|
|
|
|
Hello Hay,
I think you just have to change the Property "FlatStyle" from "Flat" to "Popup", "Standard" or "System".
Good luck
Martin
|
|
|
|
|
Thanks Martin
I did it but there is still doted rectangle apper when i click to the button.
Regards
Hay
|
|
|
|
|
this is a focus rectangle which appear when buttn have Focused if you make your button circular by set its region
the focus rectangle will still appear
Do You Inherit youe control from button ?if yes you need to handle focus staff in your painting functions like draw circle instead rectangle when your control have the focus orany thing else
MCAD
|
|
|
|
|
Hello everybody!
In my VS2003 Windows application, I created an instance of a Form during runtime.
I then whant to use it with the ShowDialog method.
everything worked fine, until I whanted to set the Witdh of the Form smaller then 112 pixel.
Can I block this limitation?
Thank you for your time.
Martin
|
|
|
|
|
There are minimum and maximum size properties, perhaps they are set ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can I change the Frame color of a textbox?
|
|
|
|