Пример #1
0
        public void CanSpecifyCustomLifestyle()
        {
            var myLifestyle = new CustomLifestyle();

            store.Register(p => p.Service <IService>()
                           .Implementor <ClassWithNoDependencies>()
                           .Lifestyle.Custom(myLifestyle));

            Assert.IsType <CustomLifestyle>(store.GetRegistrationsForService <IService>().First().Lifestyle);
        }
        public void ReturnsNullWhenKeyNotFound()
        {
            var store = new ComponentStore();

            var registrationsForService = store.GetRegistrationsForService<IService>();
            Assert.Equal(0, registrationsForService.Count);
        }
        public void ReturnsNullWhenKeyNotFound()
        {
            var store = new ComponentStore();

            var registrationsForService = store.GetRegistrationsForService <IService>();

            Assert.Equal(0, registrationsForService.Count);
        }
        public void CanInsertRegistration()
        {
            var store = new ComponentStore();

            store.Add <IService, ClassWithNoDependencies>();

            var registration = store.GetRegistrationsForService <IService>()[0];

            Assert.Equal(registration.Implementor, typeof(ClassWithNoDependencies));
        }
        public void CanInsertRegistration()
        {
            var store = new ComponentStore();

            Assert.DoesNotThrow(() =>
                    store.Add<IService, ClassWithNoDependencies>()
                );

            var registration = store.GetRegistrationsForService<IService>()[0];
            Assert.Equal(registration.Implementor, typeof(ClassWithNoDependencies));
        }
Пример #6
0
        public void CanRegisterMultipleParametersInARow()
        {
            store = new ComponentStore();
            store.Register(p => p.Service <IService>()
                           .Implementor <ClassWithNoDependencies>()
                           .Parameters("test").Set("test")
                           .Parameters("repository").Set("something"));


            var registrations = store.GetRegistrationsForService <IService>().First();

            Assert.NotNull(registrations.Parameters["test"]);
            Assert.NotNull(registrations.Parameters["repository"]);
        }
Пример #7
0
        public void CanRegisterMultipleParametersInARow()
        {
            store = new ComponentStore();
            store.Register(p => p.Service<IService>()
                                    .Implementor<ClassWithNoDependencies>()
                                    .Parameters("test").Set("test")
                                    .Parameters("repository").Set("something"));

            var registrations = store.GetRegistrationsForService<IService>().First();
            Assert.NotNull(registrations.Parameters["test"]);
            Assert.NotNull(registrations.Parameters["repository"]);
        }