Beispiel #1
0
        public void Instance_WhenDefaultDelegateSupplied_ShouldReturnInstance()
        {
            var sut = new AmbientServiceWithDefault();

            var instance = sut.Instance;

            instance.Should().BeOfType <Foo>();
        }
Beispiel #2
0
        public void Instance_WhenInstanceSetToNull_ShouldThrow()
        {
            AmbientServiceWithDefault.Create = () => new Foo2();
            var sut = new AmbientServiceWithDefault();

            Action setInstanceToNull = () => sut.Instance = null;

            setInstanceToNull.ShouldThrow <ArgumentNullException>();
        }
Beispiel #3
0
        public void Instance_WhenDefaultDelegateSuppliedAndCreateSet_ShouldReturnCreateInstance()
        {
            AmbientServiceWithDefault.Create = () => new Foo2();
            var sut = new AmbientServiceWithDefault();

            var instance = sut.Instance;

            instance.Should().BeOfType <Foo2>();
        }
Beispiel #4
0
        public void Instance_WhenInstanceSet_ShouldReturnInstance()
        {
            AmbientServiceWithDefault.Create = () => new Foo2();
            var sut = new AmbientServiceWithDefault();

            sut.Instance = new Foo();

            var instance = sut.Instance;

            instance.Should().BeOfType <Foo>();
        }