codeflood logo

Posts tagged in .net

Testable Code

Ahhh, automated testing. It's what gives you that warm fuzzy feeling that your code is all working as you intended. A validation that you're free from errors and a safety net for future modifications. OK, perhaps not necessarily free from errors, but you at least know the cases you've got covered are correct, and they're easy to run at any time to validate those cases are still working as...

Solving Generic Casting Issues with Actions

Generics in .net are a great way to avoid having to repeat your code when all you need to do is alter a few of the types involved in the code. Recently I was retrieving some objects from a data store in several different places in my code, and just altering the return types at each call. This felt like an ideal candidate for generics. I didn’t want to have to cast the array of objects to the...

Calling Control

Several years ago I remember watching a dnrTV (dot net rocks TV) episode featuring Venkat Subramaniam discussing Ruby like features of .NET 2 and C# 2. You can catch the episode at http://www.dnrtv.com/default.aspx?showNum=41. One programming technique that stuck in my head from that episode was to do with passing control inside a method back to the calling code to allow it to fill in the specific...

Few things going on in Sitecore land?

There's a few things going on at the moment in the world of Sitecore. Firstly the Sitecore Australian and New Zealand user group is having it's second user group meeting, this time in Sydney Australia on 28th October 2009. Tim Ward, Solution Architect for Sitecore Australia will be taking attendees through some of the new features of Sitecore 6.1 and some of the up coming features of Sitecore 6.2....

Multi environment config

Managing multiple environment configurations for any project has always been a bit of a challenge. Even when you're still in development, and different developers have different folder structures and drive assignments which would affect the location of your data folder in Sitecore, not to mention when you move to QA and production where server names will most likely also change. There are many...

Multithreading with Delegates

Multithreaded code is becoming more common place. Even for web applications. This is largely due to the increasing number of cores appearing on CPUs these days. The chip manufacturers have come close to the limit in terms of how fast a chip can run before it starts to melt. So to continue increases in processing speed, instead of continuing to try and increase speed vertically by increasing chip...

Extending the Sitecore image processor

You've no doubt used the dynamic image manipulation capabilities of Sitecore before. This feature allows you to dynamically manipulate images from the media library using the query string. For example, to request an image with width 150 I would append w=150 into the query string: http://domain/~/media/images/myimage.ashx?w=150 Sitecore will then dynamically scale this image to 150 pixels wide...

Warning: Memory leaks ahead

Hang on, memory leaks? But this is .net where memory leaks are a thing of the past. If you've never done C or C++ before, then you've probably never had the enjoyment of searching through your code looking for memory leaks. A memory leak is memory an application allocates, but doesn't deallocate when it's done with it. .net solved this issue by not letting the developer manage the memory of the...

Automated Testing and Sitecore - Part 8

Well. When I started writing this multi-part series on automated testing and Sitecore I never intended for it to flow over into 8 parts. But I think what I've covered in this series are the fundamental pieces any developer requires to be able to affectively automate their tests for Sitecore code. So, now that we're at the end of the series, I'll leave you with some tips. Don't get hung up on...

Automated Testing and Sitecore - Part 7

In the previous part of this series we covered testing the static output and behaviors of Sitecore presentation components such as rendering, layout and sublayout. But what about testing the dynamic behaviors of a component, such as "what happens when I push the button?", or "did my javascript make the ajax call to grab the content from the CMS?". In this part of the series...

Automated Testing and Sitecore - Part 2

In the first post of this series I mention I make use of a custom NUnit test runner which runs in the Sitecore context. In this post I'll take you through creating such a test runner. The test runner is just a web form deployed to the webroot of your Sitecore site. Because it runs inside your Sitecore application it runs within a Sitecore context. The test runner allows running a selection of test...

Automated Testing and Sitecore - Part 1

Well, my last post seems to have generated some interest. Automated testing with Sitecore is a hot topic. It is much more difficult and complex than those 2 second demos you see for general unit testing in your code. The purpose of this post is to describe how I currently perform my automated testing against Sitecore. I say currently because I am constantly updating how I do this as I discover...

Damn you VSUnit!

I ran into quite an unusual quirk with VSUnit today. (I've taken to calling Visual Studio Unit Testing VSUnit for brevity.) I've been doing some Sitecore dev using Test Driven Development (TDD) which I have had great success with in the past when working in a purely NUnit space. But with VSUnit I like the ability to run my tests straight inside the IDE (please don't point me at TestDriven.net :)...

XML serialization of read only properties

I was writing a service the other day where I wanted to marshal a custom class across the service boundary. This scenario starts off as a web service (no WCF here...at least not yet anyway). Now it's quite easy to marshal your own custom class across the web service server to the client...or so you would think. You end up with a class which looks like your class; it has the same properties, but...