public void CanMockNonSealedClasses()
        {
            var result = TestInstance.GetDependency(typeof(object)) as Object;

            Should.NotThrow(() => Mock <Object> .Get(result),
                            "should be a Moq provided mock object");
            result.ShouldNotBeNull();
        }
        public void CanMockInterfaces()
        {
            var result = TestInstance.GetDependency(typeof(IDisposable)) as IDisposable;

            Should.NotThrow(() => Mock <IDisposable> .Get(result),
                            "should be a Moq provided mock object");
            result.ShouldNotBeNull();
        }
Ejemplo n.º 3
0
        public void ThrowsAnExceptionWhenAskedForADependencyWhereThereAreNoneInTheCurrentScope()
        {
            GivenTheTestScopeIs(TestScopes.Class <PublicClassWithDefaultConstructor>());
            GivenTheDependencyProviderIs(FakeDependencyProvider);

            var exception = Should.Throw <BigUnitsException>(
                () => TestInstance.GetDependency <object>());

            exception.Data[ExceptionData.DependencyType].ShouldBe(typeof(object));
        }
Ejemplo n.º 4
0
        public void ThrowsAnExceptionWhenAskedForADependencyOutsideOfTheCurrentScope()
        {
            GivenTheTestScopeIs(TestScopes.Class <PublicClassWithASingleConstructorDependency>());
            GivenTheDependencyProviderIs(FakeDependencyProvider);

            var exception = Should.Throw <BigUnitsException>(
                () => TestInstance.GetDependency <RankException>());

            exception.Data[ExceptionData.DependencyType].ShouldBe(typeof(RankException));
        }
Ejemplo n.º 5
0
        public void CanRetrieveTheDependenciesThatAreGoingToBeUsedToBuildTheTestInstance()
        {
            GivenTheTestScopeIs(TestScopes.Namespace <PublicClassWithConcreteNamespaceDependencies>());
            GivenTheDependencyProviderIs(FakeDependencyProvider);

            var concreteClass = TestInstance.GetDependency <PublicClassWithMultipleConstructorDependencies>();

            WhenATestInstanceIsRequested <PublicClassWithConcreteNamespaceDependencies>(out var result);

            result.ConcreteDependency.ShouldBe(concreteClass);
        }
Ejemplo n.º 6
0
        public void CanRetrieveTheDependenciesThaAreGoingToBeIndirectlyUsedToBuildTheTestInstance()
        {
            GivenTheTestScopeIs(TestScopes.Namespace <PublicClassWithConcreteNamespaceDependencies>());
            GivenTheDependencyProviderIs(FakeDependencyProvider);

            var dependency1 = TestInstance.GetDependency <IDependency <One> >();
            var dependency2 = TestInstance.GetDependency <IDependency <Two> >();
            var dependency3 = TestInstance.GetDependency <IDependency <Three> >();

            WhenATestInstanceIsRequested <PublicClassWithConcreteNamespaceDependencies>(out var result);

            result.ShouldSatisfyAllConditions(
                () => result.ConcreteDependency.Dependency1.ShouldBe(dependency1),
                () => result.ConcreteDependency.Dependency2.ShouldBe(dependency2),
                () => result.ConcreteDependency.Dependency3.ShouldBe(dependency3)
                );
        }
Ejemplo n.º 7
0
        public void CanRetrieveTheDependenciesThatAreGoingToBeUsedToBuildTheTestInstance()
        {
            GivenTheTestScopeIs(TestScopes.Class <PublicClassWithMultipleConstructorDependencies>());
            GivenTheDependencyProviderIs(FakeDependencyProvider);

            var dependency1 = TestInstance.GetDependency <IDependency <One> >();
            var dependency2 = TestInstance.GetDependency <IDependency <Two> >();
            var dependency3 = TestInstance.GetDependency <IDependency <Three> >();

            WhenATestInstanceIsRequested <PublicClassWithMultipleConstructorDependencies>(out var result);

            result.ShouldSatisfyAllConditions(
                () => result.Dependency1.ShouldBe(dependency1),
                () => result.Dependency2.ShouldBe(dependency2),
                () => result.Dependency3.ShouldBe(dependency3)
                );
        }