Code smell, I'm not sure. I'm used to using spring, with one config for test, one for dev local, one for the TFS, prod etc.
Testing all the parts individually would be better, but some of my services rely on other services so I have to test that they play nice together. I gave up trying to have multiple configs, it's a headache to configure. I've mocked out the database and now running all the tests through the complete object hierarchy, coverage is at 98% that last two percent is staring me in the face mocking me! Davy, The US Congress voted Pizza sauce a vegetable. Don't even try to convince me of anything in the states is sane any more! On Mon, Apr 15, 2013 at 11:03 AM, Dave Walker <[email protected]> wrote: > I'd suggest it's a code smell to be using your IOC container in your test > environment. You can test parts in isolation by instantiating them > individually and mocking out their dependencies. > > > > > On 15 April 2013 09:05, David Rhys Jones <[email protected]> wrote: > >> I'm trying to mock one of the classes, but I also have tests that use the >> concrete class. >> >> I could test the whole thing together but that defeats the point of unit >> testing. >> >> I don't like the "automagically" part, is there some way I can tell it to >> give me the class in the configuration I want? >> Davy, >> >> The US Congress voted Pizza sauce a vegetable. Don't even try to convince >> me of anything in the states is sane any more! >> >> >> On Sat, Apr 13, 2013 at 3:11 AM, Stephen Price < >> [email protected]> wrote: >> >>> Where are you using the container to get your registered interfaces? >>> Inside or outside the using block? >>> >>> The property will automatically be populated when you ask unity for an >>> ITransactionService. Its been a while since I used unity, but with ninject >>> you have to add a [Inject] attribute on the property. There might be >>> something similar for unity... Constructor dependencies are created >>> automagically >>> >>> >>> On Apr 13, 2013 12:21 AM, "David Rhys Jones" <[email protected]> >>> wrote: >>> > >>> > I'm having a huge problem trying to get unity to work, I've spent a >>> whole day fighting it and can't get anywhere. I've used Spring.Net for a >>> long time and have no problems. >>> > >>> > This is my class. >>> > >>> > public class TransactionService : ITransactionService >>> > >>> > { >>> > >>> > [ >>> > >>> > Dependency] >>> > >>> > public ITransactionData TransactionData { get; set; } >>> > >>> > } >>> > >>> > And this is my Setup. >>> > >>> > using (var u = new UnityContainer()) >>> > >>> > { >>> > >>> > u.RegisterType<IConnection, Connection>() >>> > >>> > .Configure<InjectedMembers>() >>> > >>> > .ConfigureInjectionFor<Connection>(new >>> InjectionProperty("ConnectionString", >>> "Server=waihopar11-0125;Database=Spirit;Trusted_Connection=True;")); >>> > >>> > u.RegisterType<ITransactionService, TransactionService>() >>> > >>> > u.RegisterType<ITransactionData, MockTransactionData>("mock"); >>> > >>> > .Configure< >>> > >>> > InjectedMembers>() >>> > >>> > // This bit I don't know how to do. how do I set >>> the "Mock" TransactionData on the TransactionService. >>> > >>> > // I Can't find any examples that work with Unity 2.0.. >>> > >>> > .ConfigureInjectionFor<TransactionService>(new >>> InjectionProperty("TransactionData", ?????? ); >>> > >>> > Help! >>> > >>> > thanks. >>> > >>> > Davy, >>> > >>> > The US Congress voted Pizza sauce a vegetable. Don't even try to >>> convince me of anything in the states is sane any more! >>> >> >> >
