protected override void SetupData() { base.SetupData(); var data = new byte[10]; Random.NextBytes(data); _ignoreMessage = new IgnoreMessage(data); }
public void Load() { var ignoreMessage = new IgnoreMessage(_data); var bytes = ignoreMessage.GetBytes(); var target = new IgnoreMessage(); target.Load(bytes); Assert.IsNotNull(target.Data); Assert.AreEqual(_data.Length, target.Data.Length); Assert.IsTrue(target.Data.SequenceEqual(_data)); }
public void GetBytes() { var request = new IgnoreMessage(_data); var bytes = request.GetBytes(); var expectedBytesLength = 0; expectedBytesLength += 1; // Type expectedBytesLength += 4; // Data length expectedBytesLength += _data.Length; // Data Assert.AreEqual(expectedBytesLength, bytes.Length); var sshDataStream = new SshDataStream(bytes); Assert.AreEqual(IgnoreMessage.MessageNumber, sshDataStream.ReadByte()); Assert.AreEqual((uint) _data.Length, sshDataStream.ReadUInt32()); var actualData = new byte[_data.Length]; sshDataStream.Read(actualData, 0, actualData.Length); Assert.IsTrue(_data.SequenceEqual(actualData)); Assert.IsTrue(sshDataStream.IsEndOfData); }
public void Constructor_Data() { var target = new IgnoreMessage(_data); Assert.AreSame(_data, target.Data); }
public void DefaultConstructor() { var target = new IgnoreMessage(); Assert.IsNotNull(target.Data); Assert.AreEqual(0, target.Data.Length); }
public void Load_ShouldIgnoreDataWhenItsLengthIsGreatherThanItsActualBytes() { var ssh = new SshDataStream(1); ssh.WriteByte(2); // Type ssh.Write(5u); // Data length ssh.Write(new byte[3]); // Data var ignoreMessageBytes = ssh.ToArray(); var ignoreMessage = new IgnoreMessage(); ignoreMessage.Load(ignoreMessageBytes, 1, ignoreMessageBytes.Length - 1); Assert.IsNotNull(ignoreMessage.Data); Assert.AreEqual(0, ignoreMessage.Data.Length); }
public void Load_ShouldThrowNotSupportedExceptionWhenDataLengthIsGreaterThanInt32MaxValue() { var ssh = new SshDataStream(1); ssh.WriteByte(2); // Type ssh.Write(uint.MaxValue); // Data length ssh.Write(new byte[3]); var ignoreMessageBytes = ssh.ToArray(); var ignoreMessage = new IgnoreMessage(); try { ignoreMessage.Load(ignoreMessageBytes, 1, ignoreMessageBytes.Length - 1); Assert.Fail(); } catch (NotSupportedException ex) { Assert.IsNull(ex.InnerException); Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, "Data longer than {0} is not supported.", int.MaxValue), ex.Message); } }
public void IgnoreMessageConstructorTest1() { byte[] data = null; // TODO: Initialize to an appropriate value IgnoreMessage target = new IgnoreMessage(data); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void IgnoreMessageConstructorTest() { IgnoreMessage target = new IgnoreMessage(); Assert.Inconclusive("TODO: Implement code to verify target"); }