Ejemplo n.º 1
0
        public void NullReferenceException_When_Invoking()
        {
            Duck  source = null;
            IDuck target = source.As <IDuck>();

            Assert.NotNull(target);
            Assert.Throws <NullReferenceException>(() => target.Quack());
        }
Ejemplo n.º 2
0
        public void Null_Can_Be_Goosed()
        {
            Duck  source = null;
            IDuck target = source.As <IDuck>();

            Assert.NotNull(target);
            Assert.Null(target.GetSource <Duck>());
        }
Ejemplo n.º 3
0
        public void Should_Use_Original_Object()
        {
            Duck  source = new Duck();
            IDuck target = source.As <IDuck>();

            Assert.Same(source, target);
            Assert.Same(source, target.GetSource <Duck>());
            Assert.Throws <ArgumentException>(() => target.GetSource <ExecitedDuck>());
        }