Beispiel #1
0
        public void ConstructorStreamTest()
        {
            ReportStart();

            byte[]       bytes = new byte[] { 6, 5, 4, 3, 2, 1 };
            MemoryStream s     = new MemoryStream();

            s.Write(bytes, 0, bytes.Length);

            // without XmlDebug
            s.Position = 0;
            _sub1      = new SubComponent(s);
            Assert.AreEqual(ErrorState.Ok, _sub1.ConsolidatedState);
            CollectionAssert.AreEqual(bytes, _sub1.Bytes);
            string xml
                = "<Message>There is no DebugXml because XML debugging "
                  + "has not been enabled for this SubComponent instance.</Message>";

            Assert.AreEqual(xml, _sub1.DebugXml);

            // with XmlDebug
            s.Position = 0;
            _sub1      = new SubComponent(s, true);
            Assert.AreEqual(ErrorState.Ok, _sub1.ConsolidatedState);
            CollectionAssert.AreEqual(bytes, _sub1.Bytes);
            Assert.AreEqual(ExpectedDebugXml, _sub1.DebugXml);

            ReportEnd();
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void WriteNullIntegersTest()
        {
            ReportStart();

            MemoryStream s = new MemoryStream();

            s.WriteByte((byte)1);
            s.Position = 0;
            try
            {
                _sub1 = new SubComponent(s, true, false, true);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("bytes", ex.ParamName);
                ReportEnd();
                throw;
            }
        }
Beispiel #4
0
        public void SetStatusTest()
        {
            ReportStart();

            // without XmlDebug
            _sub1 = new SubComponent();
            _sub1.SetMyStatus(ErrorState.EndOfInputStream, "Oops");
            Assert.AreEqual(ErrorState.EndOfInputStream, _sub1.ErrorState);
            Assert.AreEqual("Oops", _sub1.ErrorMessage);

            // with XmlDebug
            byte[]       bytes = new byte[] { 1, 4 };       // too short, causes error state
            MemoryStream s     = new MemoryStream();

            s.Write(bytes, 0, bytes.Length);
            s.Position = 0;
            _sub1      = new SubComponent(s, true);
            Assert.AreEqual(ErrorState.ColourTableTooShort, _sub1.ErrorState);
            Assert.AreEqual("Bother!", _sub1.ErrorMessage);
            Assert.AreEqual(ExpectedDebugXml, _sub1.DebugXml);

            ReportEnd();
        }
Beispiel #5
0
 /// <summary>
 /// Adds the supplied component to the SubComponents collection.
 /// </summary>
 /// <param name="component"></param>
 public void AddSubComponent(SubComponent component)
 {
     _subComponents.Add(component);
 }
Beispiel #6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public ExampleComponent()
 {
     _subComponent1 = new SubComponent();
     _subComponents = new Collection <SubComponent>();
     _byteArray     = new byte[] { 1, 2, 3, 4, 5, 6 };
 }
 /// <summary>
 /// Adds the supplied component to the SubComponents collection.
 /// </summary>
 /// <param name="component"></param>
 public void AddSubComponent( SubComponent component )
 {
     _subComponents.Add( component );
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 public ExampleComponent()
 {
     _subComponent1 = new SubComponent();
     _subComponents = new Collection<SubComponent>();
     _byteArray = new byte[] { 1, 2, 3, 4, 5, 6 };
 }
        public void WriteNullIntegersTest()
        {
            ReportStart();

            MemoryStream s = new MemoryStream();
            s.WriteByte( (byte) 1 );
            s.Position = 0;
            try
            {
                _sub1 = new SubComponent( s, true, false, true );
            }
            catch( ArgumentNullException ex )
            {
                Assert.AreEqual( "bytes", ex.ParamName );
                ReportEnd();
                throw;
            }
        }
        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 );
        }
        public void SetStatusTest()
        {
            ReportStart();

            // without XmlDebug
            _sub1 = new SubComponent();
            _sub1.SetMyStatus( ErrorState.EndOfInputStream, "Oops" );
            Assert.AreEqual( ErrorState.EndOfInputStream, _sub1.ErrorState );
            Assert.AreEqual( "Oops", _sub1.ErrorMessage );

            // with XmlDebug
            byte[] bytes = new byte[] { 1, 4 }; // too short, causes error state
            MemoryStream s = new MemoryStream();
            s.Write( bytes, 0, bytes.Length );
            s.Position = 0;
            _sub1 = new SubComponent( s, true );
            Assert.AreEqual( ErrorState.ColourTableTooShort, _sub1.ErrorState );
            Assert.AreEqual( "Bother!", _sub1.ErrorMessage );
            Assert.AreEqual( ExpectedDebugXml, _sub1.DebugXml );

            ReportEnd();
        }
        public void ConstructorStreamTest()
        {
            ReportStart();

            byte[] bytes = new byte[] { 6, 5, 4, 3, 2, 1 };
            MemoryStream s = new MemoryStream();
            s.Write( bytes, 0, bytes.Length );

            // without XmlDebug
            s.Position = 0;
            _sub1 = new SubComponent( s );
            Assert.AreEqual( ErrorState.Ok, _sub1.ConsolidatedState );
            CollectionAssert.AreEqual( bytes, _sub1.Bytes );
            string xml
                = "<Message>There is no DebugXml because XML debugging "
                + "has not been enabled for this SubComponent instance.</Message>";
            Assert.AreEqual( xml, _sub1.DebugXml );

            // with XmlDebug
            s.Position = 0;
            _sub1 = new SubComponent( s, true );
            Assert.AreEqual( ErrorState.Ok, _sub1.ConsolidatedState );
            CollectionAssert.AreEqual( bytes, _sub1.Bytes );
            Assert.AreEqual( ExpectedDebugXml, _sub1.DebugXml );

            ReportEnd();
        }