forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlobSourceCheckpointDataTests.cs
More file actions
67 lines (56 loc) · 2.25 KB
/
BlobSourceCheckpointDataTests.cs
File metadata and controls
67 lines (56 loc) · 2.25 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
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
extern alias DMBlobs;
using System.IO;
using Azure.Storage.Blobs.Models;
using DMBlobs::Azure.Storage.DataMovement.Blobs;
using NUnit.Framework;
namespace Azure.Storage.DataMovement.Blobs.Tests
{
public class BlobSourceCheckpointDataTests
{
[Test]
public void Ctor()
{
BlobSourceCheckpointData data = new(BlobType.Block);
Assert.AreEqual(DataMovementBlobConstants.SourceCheckpointData.SchemaVersion, data.Version);
Assert.AreEqual(BlobType.Block, data.BlobType);
}
[Test]
public void Serialize()
{
BlobSourceCheckpointData data = new(BlobType.Block);
byte[] expected;
using (MemoryStream stream = new MemoryStream(DataMovementBlobConstants.SourceCheckpointData.DataSize))
{
BinaryWriter writer = new BinaryWriter(stream);
writer.Write(DataMovementBlobConstants.SourceCheckpointData.SchemaVersion);
writer.Write((byte)BlobType.Block);
expected = stream.ToArray();
}
byte[] actual;
using (MemoryStream stream = new MemoryStream(DataMovementBlobConstants.SourceCheckpointData.DataSize))
{
data.Serialize(stream);
actual = stream.ToArray();
}
CollectionAssert.AreEqual(expected, actual);
}
[Test]
[TestCase(BlobType.Block)]
[TestCase(BlobType.Page)]
[TestCase(BlobType.Append)]
public void Deserialize(BlobType blobType)
{
BlobSourceCheckpointData data = new(blobType);
using (Stream stream = new MemoryStream(DataMovementBlobConstants.DestinationCheckpointData.VariableLengthStartIndex))
{
data.Serialize(stream);
stream.Position = 0;
BlobSourceCheckpointData deserialized = BlobSourceCheckpointData.Deserialize(stream);
Assert.AreEqual(DataMovementBlobConstants.SourceCheckpointData.SchemaVersion, deserialized.Version);
Assert.AreEqual(blobType, deserialized.BlobType);
}
}
}
}