forked from sshnet/SSH.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSftpFileReaderTestBase.cs
More file actions
61 lines (50 loc) · 1.66 KB
/
Copy pathSftpFileReaderTestBase.cs
File metadata and controls
61 lines (50 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Sftp;
using System;
using System.Threading;
namespace Renci.SshNet.Tests.Classes.Sftp
{
public abstract class SftpFileReaderTestBase
{
internal Mock<ISftpSession> SftpSessionMock { get; private set;}
protected abstract void SetupData();
protected void CreateMocks()
{
SftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict);
}
protected abstract void SetupMocks();
protected virtual void Arrange()
{
SetupData();
CreateMocks();
SetupMocks();
}
[TestInitialize]
public void SetUp()
{
Arrange();
Act();
}
protected abstract void Act();
protected static SftpFileAttributes CreateSftpFileAttributes(long size)
{
var utcDefault = DateTime.SpecifyKind(default(DateTime), DateTimeKind.Utc);
return new SftpFileAttributes(utcDefault, utcDefault, size, default(int), default(int), default(uint), null);
}
protected static byte[] CreateByteArray(Random random, int length)
{
var chunk = new byte[length];
random.NextBytes(chunk);
return chunk;
}
protected static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout)
{
var result = WaitHandle.WaitAny(waitHandles, millisecondsTimeout);
if (result == WaitHandle.WaitTimeout)
throw new SshOperationTimeoutException();
return result;
}
}
}