Jeff and .NET

The .NET musings of Jeff Putz

Sponsors

News

My Sites

Archives

May 2004 - Posts

Can't get config settings... Argh!

I'm having such a grand old time with all this new junk that it's a real buzz kill to hit a roadblock. I'm trying to run some unit tests against some DAL classes and they aren't seeing the appSettings keys in my config file at all. As far as I can tell, everything is as it should be. The config file is the same name as the assembly with .config on the end, and it's in the same directory. Do you think NUnit is doing something odd? Is it some weird symptom of using this alpha software?

Most frustrating!

EDIT: Turns out the config file needs to be called <nunitproject>.nunit.config. Not what anyone really expected, but it works!

Posted: May 31 2004, 10:36 PM by Jeff | with 1 comment(s)
Filed under:
Unit testing with HttpContext

I've become a real fan of unit testing, though I was somewhat skeptical about its use in Web apps. NUnitASP is pretty cool for testing UI, but what I really needed was a way to test classes running in the context of a Web app, not actual requests for pages.

I do some caching voodoo in POP Forums to reduce database hits. Naturally this relies on the cache of the Web app, which you don't have in a unit testing context. Bummer! After some searching and link hopping I got to this article by Steve Padfield. Bam! That's what I needed. I only needed to make it work in .NET v2.

After some messing around, I arrived at this:

TextWriter tw = new StringWriter();
HttpWorkerRequest
wr = new SimpleWorkerRequest("/webapp", "c:\\inetpub\\wwwroot\\webapp\\", "default.aspx", "", tw);
HttpContext
.Current = new HttpContext(wr);

Pop that code in any test that will call a class that needs a non-null HttpContext. Works like a champ, and life is grand. Now if I can only get the damn tests, or the assembly being tested, to see my config settings.

Posted: May 31 2004, 07:42 PM by Jeff | with 11 comment(s)
Filed under: ,
How do you handle a record not found?

Just out of curiosity, how do you handle a database record not found?

Throw an exception or some other predictable value?

Posted: May 31 2004, 02:38 PM by Jeff | with 2 comment(s)
Filed under:
I really dig the provider model

As I've been musing lately about how to integrate POP Forums with the new security features of ASP.NET v2, I have to say that I really, really dig the new provider model. Since I had to come up with all of the plumbing once upon a time to set roles and such, this is much easier having to just write the plumbing code to the data store.

The last day or so, between holiday picnics, I wrote a provider for RoleProvider and MembershipProvider, and both have been mostly easy to implement since I had most of the necessary data calls already written to get the data. What an outstanding addition to the framework!

It is clear, however, that when I get around to writing the UI, that I'll have to do two separate versions for the “customer” (I use quotes because, hey, it's not like they're paying for it). I'm not sure that everyone will be willing to plug in my provider, so doing things the old-fashioned way with my People object and the Principal replacement in Global.asax is something I should still allow.

I'm starting to wonder now if I should shift my data layer for the forum to this provider model. As of now, the app loads a the right class implementing the IPopForumsData interface and caches it, calling it for the actual data access (something I ripped off from the www.asp.net forum). This works well enough, and the interface doesn't need its own implementation of any kind. I suppose it's easiest to just leave it.

Programming is a little more fun when you've got new stuff to mess with!

Posted: May 31 2004, 01:59 PM by Jeff | with no comments
Filed under: ,
NUnit against v2 of .NET Framework?

Thought I'd toss this out to the “blogosphere” (I hate that term)... Has anyone been able to make NUnit work with the May build of .NET v2? I was able to get the source to compile, but running it throws errors I'm too dense to understand. Not sure if it's being configured right either.

Anyone that can help is my hero!

 

Posted: May 30 2004, 04:08 PM by Jeff | with 2 comment(s)
Filed under:
Rob Howard goes solo

Wow... I couldn't believe it when I read that Rob Howard was going solo. Didn't see that coming.

I can't entirely blame him though. I went solo last week (not from Microsoft), hopefully on to something that will allow me to make a living. I hope that the rest of the Microsoft .NET folks are in good hands. My future depends on it!

Posted: May 29 2004, 07:34 PM by Jeff | with no comments
Filed under: ,
Membership in POP Forums revisited again

Last week I posed the question on whether or not I should write my own Membership provider for use in POP Forums. As I mentioned in that post, I already have my People class that does so much of what Membership does, but it might be convenient for users including the forum in their app to use the familiar (well, it'll be familiar someday!) Membership class instead of my own.

Now that I've spent some time with it, creating my own provider would be a piece of cake because I'd only need to override the various methods of MembershipProvider and have them make calls to my classes. It would in fact be ridiculously easy!

Using the Profile class looks like it's a little more complicated, and of course is dependent on web.config to map properties. The SDK docs are missing a lot of stuff, so I'm not sure where to go next on this. Is it possible to programmatically set properties for the profile object on app startup instead of having to do it from web.config? Would it make more sense to hard-code properties into a derived Profile provider?

This is all pretty exciting stuff. It's neat to be doing new things in .NET and it seems like it will be forever before we get bits we can use in production!

 

Posted: May 29 2004, 12:29 AM by Jeff | with no comments
Filed under: ,
What am I uninstalling?

While uninstalling .NET Framework v2.0...

Posted: May 28 2004, 06:41 PM by Jeff | with 3 comment(s)
Filed under:
Source Safe by HTTP: It's about time!

I just read this about Visual SourceSafe 2005:


Remote Web Access over HTTP. Use Visual Studio to connect to Visual SourceSafe databases from anywhere in the world where HTTP or HTTPS Web access is available. (Requires Visual Studio 2005, IIS, and ASP .NET).

It's about time!

 

Posted: May 27 2004, 06:41 PM by Jeff | with 1 comment(s)
Filed under:
I am not at Tech-Ed!
...But the weather here in Cleveland is fairly nice, and I'll be riding roller coasters tomorrow.
Posted: May 26 2004, 10:28 PM by Jeff | with no comments
Filed under: ,
More Posts Next page »