Example #1
0
        public void GivenSingletonConfiguration_WhenCallingBeginScope_EachTimeShouldReturnTheSame()
        {
            //arrange
            var depResolver = new NinjectResolver(new FakeNinjectModule());
            //act
            var instance1 = depResolver.BeginScope().GetService(typeof(IFakeService));
            var instance2 = depResolver.BeginScope().GetService(typeof(IFakeService));

            Assert.That(instance1, Is.EqualTo(instance2));
        }
Example #2
0
        public void GivenScopedConfiguration_WhenCallingBeginScope_EachTimeShouldReturnNewInstance()
        {
            //arrange
            var depResolver = new NinjectResolver();

            depResolver.AddRequestScopedModules(new FakeNinjectModule());

            //act
            var instance1 = depResolver.BeginScope().GetService(typeof(IFakeService));
            var instance2 = depResolver.BeginScope().GetService(typeof(IFakeService));

            Assert.That(instance1, Is.Not.EqualTo(instance2));
        }
Example #3
0
        public void CanResolve_RequestScopedDependency()
        {
            //arrange
            var depResolver = new NinjectResolver();

            depResolver.AddRequestScopedModules(new FakeNinjectModule());
            //assert
            Assert.That(depResolver.BeginScope().GetService(typeof(IFakeService)), Is.TypeOf <FakeService>());
        }