예제 #1
0
        public void Create_returns_the_class_resolved_from_automoqer()
        {
            var test = new WithAutomoqer();

            WithAutomoqer.Mocker = new AutoMoqer();

            WithAutomoqer.Create <Test>()
            .Dependency.Should().BeSameAs(WithAutomoqer.GetMock <IDependency>().Object);
        }
예제 #2
0
        public void SetInstance_sets_the_instance()
        {
            WithAutomoqer.Mocker = new AutoMoqer();

            var instance = new Mock <IDependency>().Object;

            WithAutomoqer.SetInstance(instance);

            WithAutomoqer.Create <Test>().Dependency.Should().BeSameAs(instance);
        }
예제 #3
0
        public void A_config_option_can_be_provided_when_setting_up()
        {
            WithAutomoqer.Mocker = null;
            new WithAutomoqer(new Config {
                MockBehavior = MockBehavior.Loose
            });

            WithAutomoqer.Create <Test>().DoSomething(); // should not fail

            new WithAutomoqer(new Config {
                MockBehavior = MockBehavior.Strict
            });
            var errorHit = false;

            try
            {
                WithAutomoqer.Create <Test>().DoSomething(); // should fail
            }
            catch
            {
                errorHit = true;
            }
            errorHit.Should().BeTrue();
        }