Ejemplo n.º 1
0
        public void ConcretionClassesCorrectlyApplyReuse()
        {
            // arrange
            var sut = new ContainerSetup();

            // act
            sut.RetrieveConcretionClassesRequiringRegistration(true);

            // assert
            var resolvedClasses = sut.ResolveMany <ITestInterfaceDummy>().ToList();
            var secondResolve   = sut.ResolveMany <ITestInterfaceDummy>().ToList();

            resolvedClasses.Should().BeEquivalentTo(secondResolve);
        }
Ejemplo n.º 2
0
        public void TryingToResolveMultipleServicesThrowsANotSupportedException()
        {
            // arrange
            var serviceCollectionDummy = new Mock <IServiceCollection>();

            var sut = new ContainerSetup(serviceCollectionDummy.Object);

            var act = new Action(() => sut.ResolveMany <DisposableDummy>());

            // act
            // assert
            act.Should().Throw <NotSupportedException>();
        }
Ejemplo n.º 3
0
        public void ConcretionClassesAreResolvedCorrectly()
        {
            // arrange
            var sut = new ContainerSetup();

            // act
            sut.RetrieveConcretionClassesRequiringRegistration(true);

            // assert
            var resolvedClass = sut.ResolveMany <BaseClassDummy>().ToList();

            resolvedClass.Count.Should().Be(1);
            resolvedClass.First().GetType().Should().Be(typeof(InheritorClassDummy));
        }
Ejemplo n.º 4
0
        public void ConcretionClassesFromInterfaceAreCorrectlyResolved()
        {
            // arrange
            var sut = new ContainerSetup();

            // act
            sut.RetrieveConcretionClassesRequiringRegistration(true);

            // assert
            var resolvedClasses = sut.ResolveMany <ITestInterfaceDummy>().ToList();

            resolvedClasses.Count.Should().Be(2);
            resolvedClasses.Should().Contain(x => x.GetType() == typeof(ImplementationClassDummy));
            resolvedClasses.Should().Contain(x => x.GetType() == typeof(ImplmentationClassTooDummy));
        }
Ejemplo n.º 5
0
        public void MultiTypeRegistrationSingletonsWorkCorrectly()
        {
            // arrange
            var sut = new ContainerSetup();

            // act
            sut.RetrieveConcretionClassesRequiringRegistration(true);

            // assert
            var resolvedClasses        = sut.ResolveMany <ITestInterfaceDummy>().ToList();
            var interfaceResolvedClass =
                resolvedClasses.FirstOrDefault(t => t.GetType() == typeof(ImplementationClassDummy));
            var directlyResolvedClass = sut.Resolve <ImplementationClassDummy>();

            interfaceResolvedClass.Should().Be(directlyResolvedClass);
        }