public void Dependency_has_protected_constructor()
        {
            var spec = new Spec<DependencyWithProtectedConstructor>();
            var sut = spec.Build();

            //Should fall back to default mocked instance
            sut.Echo("foo").ShouldBeNull();
        }
 public void Multi_dependency_subject_with_mocks()
 {
     var sut = new Spec<MultiDependencyClass>();
     sut.The<IFirstDependency>()
         .Setup(fd => fd.StringValue).Returns("Gorilla");
     sut.The<ISecondDependency>()
         .Setup(sd => sd.Calculate()).Returns(5150);
     var instance = sut.Build();
     instance.TheNumber.ShouldEqual(5150);
     instance.TheValue.ShouldEqual("Gorilla");
 }
 public void Deep_level_dependency_mock()
 {
     var sut = new Spec<DeepDependencyClass>();
     sut.The<IFirstDependency>()
         .Setup(fd => fd.StringValue).Returns("Gorilla");
     sut.The<ISecondDependency>()
         .Setup(sd => sd.Calculate()).Returns(5150);
     var instance = sut.Build();
     instance.NumericValue.ShouldEqual(5150);
     instance.StringValue.ShouldEqual("Gorilla");
 }
        public void Specify_mock_for_dependency_has_protected_constructor()
        {
            var spec = new Spec<DependencyWithProtectedConstructor>();
            spec.The<IProtectedConstructor>()
                .Setup(c => c.Echo("foo"))
                .Returns("NotFoo");
            var sut = spec.Build();

            //Should fall back to specific mocked instance
            sut.Echo("foo").ShouldEqual("NotFoo");
        }
        public void Setup_mocked_operations_on_a_type_with_more_than_one_interface_dependency()
        {
            var spec = new Spec<MultiDependencyClass>();

            spec.The<IFirstDependency>().SetupGet(fd => fd.StringValue).Returns("TheValue");
            spec.The<ISecondDependency>().Setup(sd => sd.Calculate()).Returns(42);

            var sut = spec.Build();

            sut.ShouldNotBeNull()
                .ShouldBeOfType<MultiDependencyClass>()
                .TheValue.ShouldEqual("TheValue");
            sut.TheNumber.ShouldEqual(42);
        }
        public void Setup_a_mocked_operation_on_a_type_with_an_interface_dependency()
        {
            var spec = new Spec<SingleDependencyClass>();

            spec.The<IFirstDependency>()
                .SetupGet(d => d.StringValue)
                .Returns("TheValue");

            var sut = spec.Build();

            sut.ShouldNotBeNull()
                .ShouldBeOfType<SingleDependencyClass>()
                .TheValue
                .ShouldNotBeNull()
                .ShouldEqual("TheValue");
        }
        public void Setup_multiple_mocked_operations_on_a_single_interface_dependency()
        {
            var spec = new Spec<AnotherClass>();

            spec.The<IDependency>()
                .Setup(x => x.FirstOperation())
                .Returns("Foo");

            spec.The<IDependency>()
                .Setup(x => x.SecondOperation())
                .Returns("Bar");

            var sut = spec.Build();

            sut.Write().ShouldEqual("FooBarFoo");
        }
        public void Setup_operations_on_a_single_interface_dependency()
        {
            var spec = new Spec<AnotherClass>();

            var sut = spec.Build();

            sut.Write().ShouldEqual("MonkeyPantsMonkey");
        }
 public void Dependency_has_private_constructor()
 {
     var spec = new Spec<DependencyWithPrivateConstructor>();
     spec.Build();
 }