Exemple #1
0
        public void RegisteredTypeLifecycleTransientDefault()
        {
            //Register an IExistent type.
            myIoc.Register <IExistent, ExistentImpl>();
            //Resolved should be a new instance.
            IExistent resolved      = myIoc.Resolve <IExistent>();
            IExistent resolvedAgain = myIoc.Resolve <IExistent>();

            //The two objects should be different (transient) instances.
            Assert.False(resolved == resolvedAgain);
        }
Exemple #2
0
        public void ResolveRegisteredTypeNoDependencies()
        {
            //Register an IExistent type.
            myIoc.Register <IExistent, ExistentImpl>();
            ///Resolving the type should return an object of the same type.
            IExistent resolved = myIoc.Resolve <IExistent>();

            //Object should be nonnull and should be an instance of what was registered
            Assert.NotNull(resolved);
            Assert.Equal(resolved.GetType(), typeof(ExistentImpl));
            Assert.NotNull(resolved as IExistent);
        }
Exemple #3
0
        public void RegisteredTypeLifecycleSingleton()
        {
            //Register an IExistent type.
            myIoc.Register <IExistent, ExistentImpl>(Lifecycle.Singleton);
            //Resolved should be a new instance.
            IExistent resolved = myIoc.Resolve <IExistent>();

            Assert.NotNull(resolved);
            IExistent resolvedAgain = myIoc.Resolve <IExistent>();

            Assert.NotNull(resolvedAgain);
            //The two objects should be different (transient) instances.
            Assert.True(resolved == resolvedAgain);
        }
Exemple #4
0
 public ExistentWithDepsImpl(IExistent dependency)
 {
     this.dependency = dependency;
 }