Skip to main content

Posts

TDD on .NET without Visual Studio

I've been long time user of the NUnit framework (I mean for ages) and I was quite happy with the overall experience. Good performance, lots of tests runners, great integration with Visual Studio, reasonable documentation, the list goes on and on... But lately I've been working mostly on mac and/or linux, and on that space, the experience wasn't that great. I still advocate for TDD (and any kind of automated tests for that matter) but I have to admit that doing TDD with NUnit outside Visual Studio (and without ReSharper support) was quite tedious. While NUnit comes with a console runner, I guess it's there just for CI Servers and not for developers to use. I mean you can use it, but the output is xml... and ... should I say more? ;) So with that problem at hand, I decided to write Contest , a small library that allows me to do TDD on .NET with just an editor and a console . Basic feature set but capable enough to get stuff done. And of course, easy to use from de con...

C# - How about using json files instead of app.config

I think we all agree that working with any kind of xml files is a bit of a pain in the ass. App.config is not an exception to that rule, so I'll show you a little trick that will help you to wipe out those nasty files replacing them for a more sane config file format with almost no changes to your code base.  Thanks to Json.Net, is really easy to read/write C# objects to json files, so if you are starting a new project, use a plain old C# object to store your settings and you are done. But what happens if you wanna replace the way you work with settings in an existing code base? I guess you will try to do it in a way that doesn't requires a whole lotta changes. Well this is one! Keep reading on github And of course, feel free to contact me if you have any question.

Bare metal HTTP

This time I’ll show you how to create a simple console app that requests resources over the internet using the lowest level APIs (at least the lowest level available in .NET). The whole point of this post is to prove that there is no magic behind entering a URL in the web browser and get a web page out of that. This little app requests a webpage and prints out the response to the console. If you want, you can extend it to save the content to a local file and then show it up in the web browser or whatever. (Maybe I'll do that in a future post). Here I’m using IP and TCP (Network and Transport protocol respectively) to connect the app to the web site, send a request and get a response. The code is self-descriptive but as usual if you have any doubt feel free to contact me. (For the sake of simplicity, I'm not handling exceptions nor writing single responsibility methods and stuff like that). If you are interested in learn more about http and how the web works, I h...

Oracle - How to insert a string longer than 4k using C#

And this is another PITA sponsored by our good friends of Oracle ;) After being struggling whit this issue for a whole day, I finally figure it out. There is a bunch of posts on the web saying that you should change the column type on the table from let’s say LONG to CLOB or stuff like that… but I have tried it and it has no effect if you are working with C# (maybe make sense if you are working with PL. I’m not sure, haven’t test it). The thing is even if you change the column type, you’ll still get an error saying “the string literal is too long…” The way to insert strings larger than 4K into Oracle databases is using bindings. And yes, you can insert 4k plus strings into LONG columns, there is no such 4k limit. This is how you do that: * I skip error handling, disposing objects, etc… just for brevity, of course you shouldn't ;) Another interesting thing that almost every posts got wrong is that you don’t have to specify the parameter type, the library will choose th...

How to upgrade an Acer Aspire V5 122P to SSD

Just two weeks ago I've upgrade my Acer v5 to SSD, and to my surprise, by following these tutorials, everything worked as expected ;) http://www.youtube.com/watch?v=z8OJTZGdVq4 http://www.youtube.com/watch?v=ZBJsh-lkQt8 http://www.youtube.com/watch?v=dm7xY_hviaY For those who doesn’t know about the Acer Aspire V5, I think it’s the cheapest touchscreen Win8 ultrabook on the market. I forced myself to use it as development machine (running visual studio 2012, R#, SQL Server and all that stuff) and for 450 bucks, it’s more than I expected. The touchpad is decent enough (although it can be better), the keyboard works great and by throwing another 100 for a SSD into the mix, increased the overall system performance, making the Acer a budget dev machine. The only drawbacks I found so far it’s the AMD 1GHz processor (of course you cannot change that) and the plastic case, but for the price I payed for it, I’m more than satisfied. If you are on a budget, I high...

How to get windows.external to work when using Awesomium.NET – Take 2

I got asked to provide the code from my post on How to get windows.external to work when using Awesomium.NET . Since I don’t have it (I don’t know why, but it’s gone…). I decided to create a new example, post it  on this repo at github  and hopefully don't loose it anymore ;). I’m assuming you are familiar with Awesomium.NET and just can’t figure out how to get windows.external at work (which is a must have on embedded web browser controls). I’m not going to show you what is Awesomium or how to use it, there’s a lot of good tutorials on the official site  and it has no sense I retype that here. So, enough jibber jabber, let’s go to the code. First of all, be sure you setup the right platform prior to compile the code (Last time I checked Awesomium.NET only works on x86). If you download the sample code, you will find this html file within the solution.  The whole point of _external.html_click is to marshall the function call from javascript to c#...

How to replace text with images on Word documents using C#

This post it’s a reply to a question I got from a previous post that shows how to work with Word templates from C# code . If you haven’t read it, I recommend to do so because I’m not going into details here. But basically it was about how to create a Word document from a template and perform same text manipulation. So, the question from Marcel Kieboom  was “Do you know if it would be also possible to replace one of the words with an image which is locally stored?” The answer is yes, and this is how you can do that. Based on the same convention I had used in the previous post, I should have a template like this: What I’m trying to do here is replace the text [angus-young] for an actual pic of Angus. The technique I’m using it’s pretty common on web sites and basically consist in have an image with a matching name for each keyword I want to replace and then create the image path dynamically. This is the C# code to do that. * When I execute t...