コード例 #1
0
ファイル: SocketStreamTest.cs プロジェクト: smartpcr/SparkCLR
        public void TestInvalidSocketStream()
        {
            Assert.Throws <ArgumentNullException>(() => new SocketStream((SaeaSocketWrapper)null));
            Assert.Throws <ArgumentNullException>(() => new SocketStream((RioSocketWrapper)null));

            Environment.SetEnvironmentVariable(ConfigurationService.CSharpSocketTypeEnvName, "Saea");
            SocketFactory.SocketWrapperType = SocketWrapperType.None;

            using (var socket = SocketFactory.CreateSocket())
                using (var stream = new SocketStream((SaeaSocketWrapper)socket))
                {
                    // Verify SocketStream
                    Assert.IsTrue(stream.CanRead);
                    Assert.IsTrue(stream.CanWrite);
                    Assert.IsFalse(stream.CanSeek);
                    long lengh = 10;
                    Assert.Throws <NotSupportedException>(() => lengh           = stream.Length);
                    Assert.Throws <NotSupportedException>(() => stream.Position = lengh);
                    Assert.Throws <NotSupportedException>(() => lengh           = stream.Position);
                    Assert.Throws <NotSupportedException>(() => stream.Seek(lengh, SeekOrigin.Begin));
                    Assert.Throws <NotSupportedException>(() => stream.SetLength(lengh));
                }

            Environment.SetEnvironmentVariable(ConfigurationService.CSharpSocketTypeEnvName, string.Empty);
            SocketFactory.SocketWrapperType = SocketWrapperType.None;
        }