Beispiel #1
0
        public static void AsInputStream_Equal()
        {
            Stream stream = TestStreamProvider.CreateReadOnlyStream();

            using (IInputStream insOne = stream.AsInputStream())
                using (IInputStream insTwo = stream.AsInputStream())
                {
                    Assert.Equal(insOne, insTwo);
                }
        }
Beispiel #2
0
        public static void AsInputStream_RoundtripUnwrap()
        {
            // NetFx Stream -> IInputStream -> NetFx Stream -> roundtrip reference equality is preserved
            Stream managedStream = TestStreamProvider.CreateReadOnlyStream();

            using (IInputStream ins = managedStream.AsInputStream())
            {
                Assert.Same(managedStream, ins.AsStreamForRead());
            }
        }
Beispiel #3
0
        public static void AsInputStream_WrapsToSameInstance()
        {
            Stream managedStream = TestStreamProvider.CreateReadOnlyStream();

            using (IInputStream ins = managedStream.AsInputStream())
            {
                Assert.NotNull(ins);
                Assert.Same(ins, managedStream.AsInputStream());
            }
        }
Beispiel #4
0
        public static void AsInputStream_FromReadOnlyStream()
        {
            Stream managedStream = TestStreamProvider.CreateReadOnlyStream();

            using (IInputStream ins = managedStream.AsInputStream())
            {
                Assert.NotNull(ins);

                // Adapting a read-only managed Stream to IOutputStream must throw a NotSupportedException
                Assert.Throws <NotSupportedException>(() => { IOutputStream outs = managedStream.AsOutputStream(); });
            }
        }
Beispiel #5
0
        public static void AsInputStream_NotEqual()
        {
            Stream streamOne = TestStreamProvider.CreateReadOnlyStream();
            Stream streamTwo = TestStreamProvider.CreateReadOnlyStream();

            Assert.NotEqual(streamOne, streamTwo);

            using (IInputStream insOne = streamOne.AsInputStream())
                using (IInputStream insTwo = streamTwo.AsInputStream())
                {
                    Assert.NotEqual(insOne, insTwo);
                }
        }