コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
        public void Create_returns_the_class_resolved_from_automoqer()
        {
            WithAutoMoqer.mocker = new AutoMoqer();

            Assert.Same(WithAutoMoqer.Create <Test>().Dependency, WithAutoMoqer.GetMock <IDependency>().Object);
        }