forked from aeron-io/simple-binary-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSinceDeprecatedTests.cs
More file actions
76 lines (66 loc) · 3.92 KB
/
Copy pathSinceDeprecatedTests.cs
File metadata and controls
76 lines (66 loc) · 3.92 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
68
69
70
71
72
73
74
75
76
// Copyright (C) 2017 MarketFactory, Inc
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Org.SbeTool.Sbe.Dll;
namespace Org.SbeTool.Sbe.Tests
{
[TestClass]
public unsafe class SinceDeprecatedTests
{
[TestMethod]
public void SinceDeprecatedTest()
{
byte[] buffer = new Byte[4096];
DirectBuffer directBuffer = new DirectBuffer(buffer);
SinceDeprecated.SinceDeprecated sinceDeprecated = new SinceDeprecated.SinceDeprecated();
// These versions are explicit in the test schema and the reason for this test
// Version 1 was initial with just field v1
// Version 2 added field v2
// Version 3 added field v3
// Version 4 deprecated field v3
Assert.AreEqual(0, SinceDeprecated.SinceDeprecated.V1SinceVersion);
Assert.AreEqual(2, SinceDeprecated.SinceDeprecated.V2SinceVersion);
Assert.AreEqual(3, SinceDeprecated.SinceDeprecated.V3SinceVersion);
Assert.AreEqual(0, SinceDeprecated.SinceDeprecated.V1Deprecated);
Assert.AreEqual(0, SinceDeprecated.SinceDeprecated.V2Deprecated);
Assert.AreEqual(4, SinceDeprecated.SinceDeprecated.V3Deprecated);
// Assign some values
sinceDeprecated.WrapForEncode(directBuffer, SinceDeprecated.MessageHeader.Size);
sinceDeprecated.V1 = 1;
sinceDeprecated.V2 = 2;
sinceDeprecated.V3 = 3;
// SchemaVersion is 4
sinceDeprecated.WrapForDecode(directBuffer, SinceDeprecated.MessageHeader.Size, SinceDeprecated.SinceDeprecated.BlockLength, SinceDeprecated.SinceDeprecated.SchemaVersion);
Assert.AreEqual(sinceDeprecated.V1, 1UL, "Incorrect V1 schemaversion:4");
Assert.AreEqual(sinceDeprecated.V2, 2UL, "Incorrect V2 schemaversion:4");
Assert.AreEqual(sinceDeprecated.V3, 3UL, "Incorrect V3 schemaversion:4");
// SchemaVersion is 3
sinceDeprecated.WrapForDecode(directBuffer, SinceDeprecated.MessageHeader.Size, SinceDeprecated.SinceDeprecated.BlockLength, 3);
Assert.AreEqual(sinceDeprecated.V1, 1UL, "Incorrect V1 schemaversion:3");
Assert.AreEqual(sinceDeprecated.V2, 2UL, "Incorrect V2 schemaversion:3");
Assert.AreEqual(sinceDeprecated.V3, 3UL, "Incorrect V3 schemaversion:3");
// SchemaVersion is 2
sinceDeprecated.WrapForDecode(directBuffer, SinceDeprecated.MessageHeader.Size, SinceDeprecated.SinceDeprecated.BlockLength, 2);
Assert.AreEqual(sinceDeprecated.V1, 1UL, "Incorrect V1 schemaversion:2");
Assert.AreEqual(sinceDeprecated.V2, 2UL, "Incorrect V2 schemaversion:2");
Assert.AreEqual(sinceDeprecated.V3, SinceDeprecated.SinceDeprecated.V3NullValue, "Incorrect V3 schemaversion:2");
// SchemaVersion is 1
sinceDeprecated.WrapForDecode(directBuffer, SinceDeprecated.MessageHeader.Size, SinceDeprecated.SinceDeprecated.BlockLength, 1);
Assert.AreEqual(sinceDeprecated.V1, 1UL, "Incorrect V1 schemaversion:1");
Assert.AreEqual(sinceDeprecated.V2, SinceDeprecated.SinceDeprecated.V2NullValue, "Incorrect V2 schemaversion:1");
Assert.AreEqual(sinceDeprecated.V3, SinceDeprecated.SinceDeprecated.V3NullValue, "Incorrect V3 schemaversion:1");
}
}
}