Posts

Es werden Posts vom November, 2011 angezeigt.

Using the MOQ framework to compare objects or: why equals are (not always) equal

In our current project we try to use the MOQ framework in order to mock away database accesss in our business logic tests. I was testing some business logic where the executed method would compare different objects and aggregations of objects with each other in order to behave one way or the other. The method builds intersections of collections using the Except extension method and stores intermediate values in lists using the Equals method. Some first tests were successful where the database wasn't mocked. Introducing mocks made me bang my head on the table because of two reasons at least: Getting used to the "over-Lambda'd" syntax of MOQ and trying to guess what was really meant on the MOQ QuickStart page . The documentation is rather sparse and a lot guess work and learning-by-pain seems to be the best way to get along. At least after some time you get along with the syntax and even start to like it. Lists don't behave like they behaved before. WTF! Compare