Contents tagged with C#
-
DateTime to String with Custom Formatting
When formatting
DateTime
to a string, the format specifier provides access to the parts of the date and time we want to express as a string. E.g. -
Fixing NServiceBus default databus serializer in .NET 6
Upgrading to .NET 6, updating all the packages, boosters turned on, launching testing.
-
Content Disposition Bug in HttpResponseMessage.Conent.Headers
If you’re running into a bug like I did, there are good and bad news. Good – Microsoft acknowledged this bug and will fix it, bad – it will happen in the next release (not sure then). In MS favour I have to admit that they turn things really quick, so who knows, it might be already in the release notes of the next release :)
-
Moq with NameValueCollection
Mocking HttpRequest and HttpResponse is not complicated with HttpRequestBase and HttpResponseBase introduced in ASP.NET. I had to mock ServerVariables property of HttpRequest and run into an issue – I was accessing an indexer property and didn’t know how to do this. Gladly, ran into a post that mentioned that indexer is actually utilizing a virtual Get() method. Reflector has confirmed that.
-
Writing a Custom ConfigurationSection
Writing a Custom ConfigurationSection is not a big task, but can be very challenging if you forget some details. I loved this post as it reminded me that you have to have both the Section tag and the collection within it tag… dah!
-
Stop Asserting Arguments by Name
Asserting arguments is essentially a healthy practice. What I don’t like, is the fact that since day one ArgumentNullException used a string for argument name, and now with .NET 4.5 almost knocking on the door, there’s still only string option.
-
Curing Singletonitis
A few years ago I have blogged about Singletonitis. Another place, different people, yet the same problem appears again – singletonitis. The issues I have outlined back then where
-
Creating collection with no code (almost)
When doing testing, I tend to create an object mother for the items generated multiple times for specifications. Quite often these objects need to be a part of a collection. A neat way to do so is to leverage .NET params mechanism:
-
MbUnit–Hidden Gem
Row tests are fun. You can simulate various inputs with expected outputs and execute them all with a single observation (test). The problem for myself was always the fact that when this was done, the only way to accomplish it was to merge the logical because which operates on system under test behaviour and the observation itself (assertion). This leads to a slightly less readable code IMO.
-
Creating BizTalk Message in Custom .NET Component
In my previous blog about consuming WCF service from BizTalk orchestration I wrote about how we’d invoke a service based on a document coming in and mapping it into the service request schema.