public void GenericAnd_PassNewType_ShouldRegisterTypeWithContainer()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);

            // Act
            objectInfo.And <IServiceStub2>();

            // Assert
            Assert.IsTrue(this.container.IsRegistered <IServiceStub2>());
        }
        public void And_PassNullInstance_ThrowsException()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);

            // Act
            TestDelegate act = () => objectInfo.And(null);

            // Assert
            Assert.Throws<ArgumentNullException>(act);
        }
        public void And_PassNullInstance_ThrowsException()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);

            // Act
            TestDelegate act = () => objectInfo.And(null);

            // Assert
            Assert.Throws <ArgumentNullException>(act);
        }
        public void And_PassNewType_ShouldRegisterTypeWithContainer()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);
            var type = typeof(IServiceStub2);

            // Act
            objectInfo.And(type);

            // Assert
            Assert.IsTrue(this.container.IsRegistered<IServiceStub2>());
        }
        public void Resolve_AsSingletonWithoutImplementationForMoreThanOneType_ThrowException()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);

            objectInfo.And(typeof(ServiceStub));

            // Act
            TestDelegate act = objectInfo.AsSingleton;

            // Assert
            Assert.Throws <NotSupportedException>(act, InversionOfControlResources.ErrMsg_CannotRegisterTypeAsSingleton);
        }
        public void As_SetTypeImplementationWithWrongTypeForOneOfTwoServices_ThrowsException()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);
            objectInfo.And<IServiceProvider>();

            // Act
            TestDelegate testDelegate = () => objectInfo.As(typeof(ServiceStub));

            // Assert
            Assert.Throws<ArgumentException>(
                testDelegate,
                string.Format(
                    CultureInfo.CurrentCulture,
                    InversionOfControlResources.ErrMsg_CannotSetTypeAsImplementation,
                    typeof(ServiceStub),
                    typeof(IServiceProvider)));
        }
        public void As_SetTypeImplementationWithWrongTypeForOneOfTwoServices_ThrowsException()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);

            objectInfo.And <IServiceProvider>();

            // Act
            TestDelegate testDelegate = () => objectInfo.As(typeof(ServiceStub));

            // Assert
            Assert.Throws <ArgumentException>(
                testDelegate,
                string.Format(
                    CultureInfo.CurrentCulture,
                    InversionOfControlResources.ErrMsg_CannotSetTypeAsImplementation,
                    typeof(ServiceStub),
                    typeof(IServiceProvider)));
        }
        public void Resolve_AsSingletonWithoutImplementationForMoreThanOneType_ThrowException()
        {
            // Arrange
            var objectInfo = new ContainerInstance(this.registeredType, this.container);
            objectInfo.And(typeof(ServiceStub));

            // Act
            TestDelegate act = objectInfo.AsSingleton;

            // Assert
            Assert.Throws<NotSupportedException>(act, InversionOfControlResources.ErrMsg_CannotRegisterTypeAsSingleton);
        }