Community Page
- www.emadibrahim.com Jump to website »
-
Subscribe -
Community
-
Top Commenters
-
Popular Threads
-
Recent Comments
- Excellent post! I've been looking for a way to DRY up my own code as well and your post led me on the right way.
- Thanks a lot.It works also with SQL Server 2008 Express and NetworkService instead of LocalSystem.
- There is another validation toolkit called Validator Toolkit for ASP.NET on Codeplex.com. See http://www.codeplex.com/MvcValidatorToolkit
- Is that a compile error or runtime error? Did you copy & paste the code correctly? Sometimes the browser messes up the code formatting. Other than that you should add a breakpoint and examine...
- Hi Emad I just tried your code, but it is throwing me an error at this part: var x = (from result in resultXml.Descendants("nodeKeyVal") ... It tells me : error CS1026: ) expected Do you...
Jump to original thread »
//I got a design challenge with asp.net mvc. I want to keep track of the currently logged in user in the session because I don’t want to hit the database every time I need to get the username or id for a query. And I have all my controllers inherit from a base controller
... Continue reading »
10 months ago
10 months ago
Why are you opposed to Kernel.Get? It seems like I can easily achieve the goal I want without having to force every derived controller from calling the base controller consturctor with interfaces...
I am trying to get away from doing this
class DerviedClass : BaseClass
public DerivedClass(IService1, IService2) : base(IBaseService1, IBaseService2)
By using Kernel.Get in the base class then I eliminate the use of base(IBaseService1, IBaseService2) in the derived classes constructor... I hope that makes sense.
10 months ago
From the testing angle I'd rather be able to pass my dependencies in via the constructor (or set via a property) than have to mock an instance of IKernel up.
Think about how you're going to write tests for the controllers that use that property. With the code listed above you would have to either (a) mock the Kernel or (b) actually wire up DI for your tests.
10 months ago
to do anyway to inject constructor arguments. Actually my DI code in my
test project didn't change when I moved from constructor to property to
kernel.get...
At points, I feel like kernel.get is a good solution and at other points I
feel it's not. I can't explain it :)...
10 months ago
Btw, how deep can these threads go? =)
10 months ago
one method that just sets up my DI and all it is really doing is mocking all
the interfaces...
I don't know how deep the threads go... But we can find out :)... Are you
posting your comments on the site or are you just replying to the emails?
10 months ago
My only concern about doing DI on your tests is that now your tests have
dependencies that you can't see while reading the test.
10 months ago
with a lot of repetition in my unit tests and test fixtures. I might have
to post an example of how I am doing this, to get feedback from the
community. I might be experiencing tunnel vision, since I am the only one
writing, reviewing and refactoring the code...
10 months ago
var Provider = Kernel.Get<MembershipProvider>();