Beispiel #1
0
        public void RegisterSingleInstance_TypeProvided_SingleInstanceRegistered()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.RegisterSingleInstance <TestClass>();

            Assert.AreEqual(simpleInjector.Resolve <TestClass>(), simpleInjector.Resolve <TestClass>());
        }
Beispiel #2
0
        public void Constructor_InjectorWithControlledLifetimeTypesProvided_ControlledLifetimeTypesCopied()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.RegisterSingleInstance <TestClass>();

            SimpleInjector simpleInjectorCopy = new SimpleInjector(simpleInjector);

            Assert.AreEqual(simpleInjectorCopy.Resolve <TestClass>(), simpleInjectorCopy.Resolve <TestClass>());
        }
Beispiel #3
0
        public void Register_ImplementationTypeProvided_InterfaceResolved()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.Register <ITestClass, TestClass>();

            Assert.IsNotNull(simpleInjector.Resolve <ITestClass>());
        }
Beispiel #4
0
        public void Resolve_ConstructorHasValueDependency_DependencyResolved()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            TestClassValueParameter result = simpleInjector.Resolve <TestClassValueParameter>();

            Assert.IsNotNull(result);
        }
Beispiel #5
0
        public void RegisterSingleInstance_InstanceProvided_SingleInstanceRegistered()
        {
            TestClass      singleton      = new TestClass(16);
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.RegisterSingleInstance(singleton);

            Assert.AreEqual(singleton, simpleInjector.Resolve <TestClass>());
        }
Beispiel #6
0
        public void Constructor_InjectorWithImplementationMapProvided_ImplementationMapCopied()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.Register <ITestClass, TestClass>();

            SimpleInjector simpleInjectorCopy = new SimpleInjector(simpleInjector);

            Assert.IsNotNull(simpleInjectorCopy.Resolve <ITestClass>());
        }
Beispiel #7
0
        public void Resolve_ClassHasRegisteredSetterDependency_DependencyResolved()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.Register <ITestClass, TestClass>();

            TestClassSetter result = simpleInjector.Resolve <TestClassSetter>();

            Assert.IsNotNull(result);
        }
Beispiel #8
0
        public void Constructor_InjectorWithInstanceMapProvided_InstanceMapCopied()
        {
            TestClass      singleton      = new TestClass(16);
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.RegisterSingleInstance(singleton);

            SimpleInjector simpleInjectorCopy = new SimpleInjector(simpleInjector);

            Assert.AreEqual(singleton, simpleInjectorCopy.Resolve <TestClass>());
        }
Beispiel #9
0
        public void Resolve_SimpleInjectorTypeProvided_ExistingInstanceReturned()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            Assert.AreEqual(simpleInjector, simpleInjector.Resolve <SimpleInjector>());
        }
Beispiel #10
0
        public void Register_ImplementationTypeNotProvided_ThrowsArgumentException()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.Resolve <ITestClass>();
        }
Beispiel #11
0
        public void Resolve_NoPublicConstructor_ThrowsEntryPointNotFoundException()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            TestClassNoPublicConstructor result = simpleInjector.Resolve <TestClassNoPublicConstructor>();
        }
Beispiel #12
0
        public void Resolve_DependencyPropertyHasNoSetter_ThrowsMissingMethodException()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            TestClassNoSetter result = simpleInjector.Resolve <TestClassNoSetter>();
        }
Beispiel #13
0
        public void Resolve_PrimitiveTypeProvided_DefaultValueReturned()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            Assert.AreEqual(default(int), simpleInjector.Resolve <int>());
        }
 /// <summary>
 /// Creates a new instance of the <see cref="App"/> class.
 /// </summary>
 public App() : base()
 {
     _simpleInjector.RegisterSingleInstance <BinarySerializerOptions>();
     _simpleInjector.RegisterSingleInstance <BinarySerializer>();
     _simpleInjector.Resolve <MainWindow>().Show();
 }