Пример #1
0
        public void WriteStringNullTest()
        {
            ReportStart();

            MemoryStream s = new MemoryStream();

            ExampleComponent.CallWriteString(null, s);
            Assert.AreEqual(0, s.Length);

            ReportEnd();
        }
Пример #2
0
        public void ReadShortTest1Byte()
        {
            ReportStart();

            byte[] bytes = new byte[] { 1 };
            Stream s     = new MemoryStream();

            s.Write(bytes, 0, bytes.Length);
            s.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(-1, ExampleComponent.CallReadShort(s));

            ReportEnd();
        }
Пример #3
0
        public void ReadTestNullArgument()
        {
            ReportStart();

            try
            {
                ExampleComponent.CallRead(null);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("inputStream", ex.ParamName);
                ReportEnd();
                throw;
            }
        }
Пример #4
0
        public void WriteByteTest()
        {
            ReportStart();

            MemoryStream s            = new MemoryStream();
            int          valueToWrite = 0x3b2a13;

            ExampleComponent.CallWriteByte(valueToWrite, s);
            s.Seek(0, SeekOrigin.Begin);
            Assert.AreEqual(1, s.Length);               // first 2 bytes will have been discarded
            int byte1 = s.ReadByte();

            Assert.AreEqual(0x13, byte1);

            ReportEnd();
        }
Пример #5
0
        public void WriteByteNullStreamTest()
        {
            ReportStart();

            Stream s = null;

            try
            {
                ExampleComponent.CallWriteByte(12, s);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("outputStream", ex.ParamName);
                ReportEnd();
                throw;
            }
        }
Пример #6
0
        public void Setup()
        {
            _component = new ExampleComponent();
            _sub1      = new SubComponent();
            _sub2      = new SubComponent();
            _sub3      = new SubComponent();

            _sub1.SetMyStatus(_sub1State, _sub1Message);
            _sub2.SetMyStatus(_sub2State, _sub2Message);
            _sub3.SetMyStatus(_sub3State, _sub3Message);
            _sub3.SetMyStatus(_sub3State, _sub3Message2);
            _component.SetMyStatus(_componentState, _componentMessage);

            _component.SubComponent1 = _sub1;
            _component.AddSubComponent(_sub2);
            _component.AddSubComponent(_sub3);
        }
Пример #7
0
        public void WriteStringTest()
        {
            ReportStart();

            string       text = "hello world";
            MemoryStream s    = new MemoryStream();

            ExampleComponent.CallWriteString(text, s);
            s.Seek(0, SeekOrigin.Begin);
            byte[] bytes = new byte[s.Length];
            s.Read(bytes, 0, (int)s.Length);
            StringBuilder sb = new StringBuilder();

            foreach (byte b in bytes)
            {
                sb.Append((char)b);
            }
            string textRead = sb.ToString();

            Assert.AreEqual(text, textRead);

            ReportEnd();
        }
Пример #8
0
        public void ReadTest()
        {
            ReportStart();

            // Write some bytes to a stream and then position it at the start
            byte[] bytes = new byte[]
            {
                21, 18, 69
            };
            Stream s = new MemoryStream();

            s.Write(bytes, 0, bytes.Length);
            s.Seek(0, SeekOrigin.Begin);

            // Use the Read method of GifComponent to read the stream back in
            Assert.AreEqual(21, ExampleComponent.CallRead(s));
            Assert.AreEqual(18, ExampleComponent.CallRead(s));
            Assert.AreEqual(69, ExampleComponent.CallRead(s));
            // There are no more bytes to read, so the next read should return -1
            Assert.AreEqual(-1, ExampleComponent.CallRead(s));

            ReportEnd();
        }
        public void Setup()
        {
            _component = new ExampleComponent();
            _sub1 = new SubComponent();
            _sub2 = new SubComponent();
            _sub3 = new SubComponent();

            _sub1.SetMyStatus( _sub1State, _sub1Message );
            _sub2.SetMyStatus( _sub2State, _sub2Message );
            _sub3.SetMyStatus( _sub3State, _sub3Message );
            _sub3.SetMyStatus( _sub3State, _sub3Message2 );
            _component.SetMyStatus( _componentState, _componentMessage );

            _component.SubComponent1 = _sub1;
            _component.AddSubComponent( _sub2 );
            _component.AddSubComponent( _sub3 );
        }