예제 #1
0
        public void GetConstructor_WithNullArgument2_ThrowsException()
        {
            // Arrange
            var behavior = new ContainerOptions().ConstructorResolutionBehavior;

            // Act
            behavior.GetConstructor(typeof(TypeWithSinglePublicDefaultConstructor), null);
        }
예제 #2
0
        public void GetConstructor_WithNullArgument1_ThrowsException()
        {
            // Arrange
            var behavior = new ContainerOptions().ConstructorResolutionBehavior;

            // Act
            Action action = () => behavior.GetConstructor(null, typeof(TypeWithSinglePublicDefaultConstructor));

            // Assert
            AssertThat.Throws <ArgumentNullException>(action);
        }
예제 #3
0
        public void IsRegistrationPhase_InstancesResolvedFromTheContainer_ReturnsFalse()
        {
            // Arrange
            var behavior = new ContainerOptions().ConstructorResolutionBehavior;

            // Act
            var constructor = behavior.GetConstructor(typeof(TypeWithSinglePublicDefaultConstructor),
                                                      typeof(TypeWithSinglePublicDefaultConstructor));

            // Assert
            Assert.IsNotNull(constructor, "The constructor was expected to be returned.");
        }
예제 #4
0
        public void GetConstructor_TypeWithSingleInternalConstructor_ThrowsExpectedException()
        {
            // Arrange
            var behavior = new ContainerOptions().ConstructorResolutionBehavior;

            try
            {
                // Act
                behavior.GetConstructor(typeof(TypeWithSingleInternalConstructor),
                                        typeof(TypeWithSingleInternalConstructor));

                // Assert
                Assert.Fail("Exception expected.");
            }
            catch (ActivationException ex)
            {
                AssertThat.StringContains("For the container to be able to create " +
                                          "DefaultConstructorResolutionBehaviorTests.TypeWithSingleInternalConstructor, it should " +
                                          "contain exactly one public constructor, but it has 0.", ex.Message);
            }
        }