Пример #1
0
        public void should_use_explict_interface_impl_if_you_want_to_hide_something_for_certain_type()
        {
            var readOnlyStreamWithWriteExplicitlyImpl = new ReadOnlyStream();

            var hasWriteMethod = readOnlyStreamWithWriteExplicitlyImpl.HasInstanceMethod(
                "Write",
                new[] { typeof(string) });

            // change the variable value to fix the test.
            const bool expectedHasWriteMethod = false;

            Assert.Equal(expectedHasWriteMethod, hasWriteMethod);
        }
Пример #2
0
        public void should_use_explict_interface_impl_if_you_want_to_hide_something_for_certain_type()
        {
            // ReadOnlyStream implement ITextStream, explicity implement Write
            // lets the two methods coexist in one class.
            // The only way to call an explicitly implemented member is to cast to its interface
            // as the next test
            var readOnlyStreamWithWriteExplicitlyImpl = new ReadOnlyStream();

            // see if reafOnlyStreamWithExplicitImpl has write method
            var hasWriteMethod = readOnlyStreamWithWriteExplicitlyImpl.HasInstanceMethod(
                "Write",
                new[] { typeof(string) });

            // change the variable value to fix the test.
            const bool expectedHasWriteMethod = false;

            Assert.Equal(expectedHasWriteMethod, hasWriteMethod);
        }