Пример #1
0
        public void RegisterSingleInstance_TypeProvided_SingleInstanceRegistered()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.RegisterSingleInstance <TestClass>();

            Assert.AreEqual(simpleInjector.Resolve <TestClass>(), simpleInjector.Resolve <TestClass>());
        }
Пример #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>());
        }
Пример #3
0
        public void Register_ImplementationTypeProvided_InterfaceResolved()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.Register <ITestClass, TestClass>();

            Assert.IsNotNull(simpleInjector.Resolve <ITestClass>());
        }
Пример #4
0
        public void Resolve_ConstructorHasValueDependency_DependencyResolved()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

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

            Assert.IsNotNull(result);
        }
Пример #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>());
        }
Пример #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>());
        }
Пример #7
0
        public void Resolve_ClassHasRegisteredSetterDependency_DependencyResolved()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.Register <ITestClass, TestClass>();

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

            Assert.IsNotNull(result);
        }
Пример #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>());
        }
Пример #9
0
        public void Resolve_SimpleInjectorTypeProvided_ExistingInstanceReturned()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            Assert.AreEqual(simpleInjector, simpleInjector.Resolve <SimpleInjector>());
        }
Пример #10
0
        public void Register_ImplementationTypeNotProvided_ThrowsArgumentException()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            simpleInjector.Resolve <ITestClass>();
        }
Пример #11
0
        public void Resolve_NoPublicConstructor_ThrowsEntryPointNotFoundException()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            TestClassNoPublicConstructor result = simpleInjector.Resolve <TestClassNoPublicConstructor>();
        }
Пример #12
0
        public void Resolve_DependencyPropertyHasNoSetter_ThrowsMissingMethodException()
        {
            SimpleInjector simpleInjector = new SimpleInjector();

            TestClassNoSetter result = simpleInjector.Resolve <TestClassNoSetter>();
        }
Пример #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();
 }