Feeds:
Posts
Comments

Archive for April, 2010

Lets say we have some very simple objects such as these two classes: [Serializable] public class ClassA {  public string StrA { get; set; }  public ClassB B { get; set; }  public ClassA Clone()  {  return (ClassA)MemberwiseClone();  } } and [Serializable] public class ClassB {  public string StrB { get; set; } } There are three types of copying objects. These are [...]

Read Full Post »

My last post detailed how to test methods that are not public. The example code I used was a method that divides one decimal by another. I thought this a good chance to demonstrate how to test for expected Exceptions. To refresh our memories, the method we are testing is this: public decimal PublicDivide(decimal numerator, [...]

Read Full Post »

I have seen a lot of debate about testing methods that are private, internal or protected. There are different arguments for both sides of the argument of whether these methods should be tested or not. I like to have a fine grained test coverage as possible and as I like to keep methods as short [...]

Read Full Post »

I had an interview the other day and thought I would write abut one of the questions I had. It involved releasing references to COM objects in .NET. The pattern to do this is unsurprisingly called the Dispose pattern. The problems with using COM components in managed code are as follows: 1. Developers can accidentally [...]

Read Full Post »

This is the second in the series of design patterns. The first post might have been a little verbose so I thought I’d liven this one up a bit with a good old fashioned class diagram and some actual code! I used the decorator pattern recently on the advert booking project. The scenario is this: [...]

Read Full Post »

Ive been looking at the amazing book Head First Design Patterns by Erik and Elisabeth Freeman. I have been using various different design patterns for awhile and I thought I would write about some cool uses I have found for different types of patterns. This is the first post like this and it is about [...]

Read Full Post »

One thing I noticed, when using dependency injection was that the calling class, i.e the one that instantiates the container to do the injection wont be able to find the repository unless part of your code calls into the assembly it resides in. If you have a) Assembly for domain b) Assembly for DAL c) [...]

Read Full Post »

Why are the errors to do with mapping  from NHibernate so damn cryptic! As NHibernate uses Log4Net I added the following XML to an app.config file to my test project, included the log4net.dll reference and added this line of code to the TestFixture method to initialize Log4Net. log4net.Config.XmlConfigurator.Configure(); The config xml is: <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> [...]

Read Full Post »

My understanding of the NHibernate Session is that in the case of a web application, the ISession should be created and destroyed with each HttpRequest. This is probably the most efficient use of the session and enables easy use of lazy loading within a single request. Sessions do not require much overhead to create and [...]

Read Full Post »

This has probably been covered in a thousand blogs and technical articles but I couldn’t find one that covered this exact scenario, so here goes.. When adding a row to the link table between two entities in a many to many relationship, I wanted to make sure a single row is saved in the database but both [...]

Read Full Post »

Older Posts »

Follow

Get every new post delivered to your Inbox.