public void should_declare_out_if_generic_type_is_covariant()
        {
            var covariantDemoObject = new CovariantContravariantDemoClass<string>("Hello");
            ICovariantGetDemo<object> covariantWithBaseTypeArgument = covariantDemoObject;
            object value = covariantWithBaseTypeArgument.Get();

            // correct the variable value to fix the test
            object expectedValue = null;

            Assert.Equal(expectedValue, value);
        }
Beispiel #2
0
        public void should_declare_out_if_generic_type_is_covariant()
        {
            var covariantDemoObject = new CovariantContravariantDemoClass <string>("Hello");
            ICovariantGetDemo <object> covariantWithBaseTypeArgument = covariantDemoObject;
            object value = covariantWithBaseTypeArgument.Get();

            // correct the variable value to fix the test
            object expectedValue = null;

            Assert.Equal(expectedValue, value);
        }
        public void should_declare_in_if_generic_type_is_contravariant()
        {
            var contravariantDemoObject = new CovariantContravariantDemoClass<object>(null);
            IContravariantSetDemo<string> contravariantWithDerivedTypeArgument =
                contravariantDemoObject;
            contravariantWithDerivedTypeArgument.Put("Hello");

            // correct the variable value to fix the test
            object expectedValue = null;

            Assert.Equal(expectedValue, contravariantDemoObject.Get());
        }
Beispiel #4
0
        public void should_declare_in_if_generic_type_is_contravariant()
        {
            var contravariantDemoObject = new CovariantContravariantDemoClass <object>(null);
            IContravariantSetDemo <string> contravariantWithDerivedTypeArgument =
                contravariantDemoObject;

            contravariantWithDerivedTypeArgument.Put("Hello");

            // correct the variable value to fix the test
            object expectedValue = null;

            Assert.Equal(expectedValue, contravariantDemoObject.Get());
        }