Skip to content

Commit de06f45

Browse files
committed
Fix flaky test.
1 parent 5941626 commit de06f45

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelDataMessageTest.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
using Renci.SshNet.Messages.Connection;
44
using Microsoft.VisualStudio.TestTools.UnitTesting;
55
using System;
6+
using Renci.SshNet.Abstractions;
67
using Renci.SshNet.Tests.Common;
78

89
namespace Renci.SshNet.Tests.Classes.Messages.Connection
910
{
1011
/// <summary>
11-
///This is a test class for ChannelDataMessageTest and is intended
12-
///to contain all ChannelDataMessageTest Unit Tests
13-
///</summary>
12+
/// This is a test class for ChannelDataMessageTest and is intended
13+
/// to contain all ChannelDataMessageTest Unit Tests
14+
/// </summary>
1415
[TestClass]
1516
public class ChannelDataMessageTest : TestBase
1617
{
@@ -98,10 +99,9 @@ public void GetBytes()
9899
var random = new Random();
99100

100101
var localChannelNumber = (uint) random.Next(0, int.MaxValue);
101-
var data = new byte[random.Next(10, 20)];
102-
random.NextBytes(data);
103-
var offset = random.Next(2, 4);
104-
var size = random.Next(5, 9);
102+
var data = CryptoAbstraction.GenerateRandom(random.Next(10, 20));
103+
var offset = random.Next(0, data.Length - 1);
104+
var size = random.Next(0, data.Length - offset);
105105

106106
var target = new ChannelDataMessage(localChannelNumber, data, offset, size);
107107

@@ -133,11 +133,10 @@ public void Load()
133133
var random = new Random();
134134

135135
var localChannelNumber = (uint) random.Next(0, int.MaxValue);
136-
var data = new byte[random.Next(10, 20)];
137-
random.NextBytes(data);
136+
var data = CryptoAbstraction.GenerateRandom(random.Next(10, 20));
138137

139-
var offset = random.Next(2, 4);
140-
var size = random.Next(5, 9);
138+
var offset = random.Next(0, data.Length - 1);
139+
var size = random.Next(0, data.Length - offset);
141140
var channelDataMessage = new ChannelDataMessage(localChannelNumber, data, offset, size);
142141
var bytes = channelDataMessage.GetBytes();
143142
var target = new ChannelDataMessage();

0 commit comments

Comments
 (0)