Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.

Donate Bitcoins

Programming and Learning from SD March 2013 Entries
Making jQuery UI Droppable Testable
I’m using jQuery UI’s droppable for drag and drop capabilities. I wanted to be able to test it with Jasmine, but I couldn’t find a way to mock it. I found Jasmine jQuery, but wasn’t able to figure out how to spyOn or mock $('#jQueryElement').droppab... accept: function (d) { return accept(d); }, drop: function (event, ui) { drop(event, ui); } }); So I created a wrapper for this function. I’ve found that creating wrappers is an easy way to make things testable and to remove coupling to libraries ......

Posted On Tuesday, March 26, 2013 9:47 AM

Use the bind method for Jasmine toThrow Tests
Thanks to Danyal Aytekin for his Stackoverflow answer. If you want to use the toThrow in Jasmin tests on actual functions, you can use the “Function.bind, which was introduced in JavaScript 1.8.5. This works in the latest versions of Chrome and Firefox, and you can patch other browsers by defining the function yourself.” From his answer:describe('using bind with jasmine', function() { var f = function(x) { if(x === 2) { throw new Error(); } } it('lets us avoid using an anonymous function', function() ......

Posted On Thursday, March 21, 2013 2:11 PM

Visual Studio 2012.2 Hanging When Editing Razor Pages
Since I installed the v2 update, Visual Studio has been hanging on occasion. The CPU for the process jumps to 25% and stays there and Visual Studio stops responding. I found a Microsoft Connect feedback which describes the same problem. It seems to be connected to intellisense for Knockout. There is a registry hack to turn it off, and this has worked for me. On March 13th, they report that the fix will be in VS Update 2, which is currently in CTP4 state (on March 19, 2013) with a “go-live” license.Update ......

Posted On Tuesday, March 19, 2013 8:06 AM

Specification Test for the Authorized Attribute in MVC
I wanted to Unit Test (in BDD I’d call it a specification) that the controller had the authorize attribute so I found this approach in a GoodSearch a while back and forgotten who to give credit for it, but I thought I’d post it, so I won’t have to search for it next time. I put this in a base class and it’s been very useful. EDIT: March 21st, 2013 I added a way to also verify the correct roles are in the attribute. This is especially nice, sine the attribute takes strings. [Authorize(Roles = "Super ......

Posted On Friday, March 15, 2013 1:27 PM

Here’s why the Unit of Work is needed
I didn’t understand why I would want to use the Unit of Work pattern before I ran into this. I had a ManagerBase class that had an IRepository. (The managers implement ManagerBase which have a private Repository that follows Juans approach Repository had the context and saveChanges method. This means that each “Manager” I had, contained a different instance of the context. This ......

Posted On Tuesday, March 12, 2013 4:21 PM

FakeItEasy - Sealed Methods can not be intercepted exception
I was trying to do a partial mock in FakeItEasy and kept getting "The current proxy generator can not intercept the specified method for the following reason: - Sealed methods can not be intercepted".The fix is to make the method virtual. (notice the A.Fake<LayoutManager>, not A.Fake<ILayoutManager> for the partial mock) var layoutManagerFake = A.Fake<LayoutManager>(); A.CallTo(() => layoutManagerFake.UpdateAss... assigned, "user")).CallsBaseMethod(); In LayoutManager (note ......

Posted On Tuesday, March 12, 2013 3:09 PM

A Look at NDepend
I was contacted by NDepend and asked if I wanted a free version of their professional license in exchange for writing a post about it. I agreed and have been running it for a few weeks. My first impression was, “wow, that’s a lot of information” about my code base. I have the opportunity to be a part of a rebuild of a project and creating a new code base. One of the main requirements is to create maintainable code (the old one if very impressive, but was created adhoc and by someone learning programming ......

Posted On Wednesday, March 6, 2013 12:55 PM

JsonIgnore attribute in Json.Net to ignore properties
We’re using Entity Framework to query a complex object graph using the .Include(“”) method to eager load the results, then sending it to the client with the WebApi. We’ve overridden the JavaScript Serializer in the Application_Start of Global.asax.cs of our MVC application to avoid circular dependencies. These occurred because of the Code First classes that were generated from the EF Power Tools had references to each other. It also created really large JSON structures that we didn’t need all the ......

Posted On Tuesday, March 5, 2013 1:57 PM

Copyright © Aligned | Powered by: