示例#1
0
        public void Instantiating_the_automoqer_sets_the_static_mocker()
        {
            WithAutoMoqer.mocker = null;
            var test = new WithAutoMoqer();

            Assert.NotNull(WithAutoMoqer.mocker);
        }
示例#2
0
        public void SetInstance_sets_the_instance()
        {
            WithAutoMoqer.mocker = new AutoMoqer();

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

            WithAutoMoqer.SetInstance(instance);

            Assert.Same(WithAutoMoqer.Create <Test>().Dependency, 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;
            }
            Assert.True(errorHit);
        }
示例#4
0
        public void Create_returns_the_class_resolved_from_automoqer()
        {
            WithAutoMoqer.mocker = new AutoMoqer();

            Assert.Same(WithAutoMoqer.Create <Test>().Dependency, WithAutoMoqer.GetMock <IDependency>().Object);
        }
示例#5
0
        public void GetMock_returns_the_mock()
        {
            WithAutoMoqer.mocker = new AutoMoqer();

            Assert.Same(WithAutoMoqer.GetMock <IDependency>(), WithAutoMoqer.mocker.GetMock <IDependency>());
        }