Skip to content

Commit 81f94e6

Browse files
committed
Add test project
1 parent 87626d6 commit 81f94e6

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using libsignalservice.messages.multidevice;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Text;
7+
8+
namespace libsignal_service_dotnet_tests
9+
{
10+
[TestClass]
11+
public class ChunkedInputStreamTest
12+
{
13+
[TestMethod]
14+
public void TestReadRawVarint32()
15+
{
16+
MemoryStream ms = new MemoryStream();
17+
byte[] input;
18+
int i;
19+
20+
input = new byte[] { 216, 1, 0, 0, 0, 0, 0,};
21+
ms.Write(input, 0, input.Length);
22+
ms.Position = 0;
23+
24+
i = new ChunkedInputStream(ms).ReadRawVarint32();
25+
ms.Position = 0;
26+
Assert.AreEqual(216, i);
27+
28+
29+
input = new byte[] { 172, 2, 0xff, 0xff, 0, 0, 0, };
30+
ms.Write(input, 0, input.Length);
31+
ms.Position = 0;
32+
33+
i = new ChunkedInputStream(ms).ReadRawVarint32();
34+
ms.Position = 0;
35+
Assert.AreEqual(300, i);
36+
37+
38+
input = new byte[] { 5, 0xff, 0xff, 0xff, 0, 0, 0, };
39+
ms.Write(input, 0, input.Length);
40+
ms.Position = 0;
41+
42+
i = new ChunkedInputStream(ms).ReadRawVarint32();
43+
ms.Position = 0;
44+
Assert.AreEqual(5, i);
45+
46+
47+
input = new byte[] { 199, 232, 67, 0xff, 0, 0, 0, };
48+
ms.Write(input, 0, input.Length);
49+
ms.Position = 0;
50+
51+
i = new ChunkedInputStream(ms).ReadRawVarint32();
52+
ms.Position = 0;
53+
Assert.AreEqual(1111111, i);
54+
55+
56+
input = new byte[] { 128, 1, 0xff, 0xff, 0, 0, 0, };
57+
ms.Write(input, 0, input.Length);
58+
ms.Position = 0;
59+
60+
i = new ChunkedInputStream(ms).ReadRawVarint32();
61+
ms.Position = 0;
62+
Assert.AreEqual(128, i);
63+
}
64+
}
65+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<RootNamespace>libsignal_service_dotnet_tests</RootNamespace>
6+
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
12+
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
13+
<PackageReference Include="MSTest.TestFramework" Version="1.2.1" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\libsignal-service-dotnet\libsignal-service-dotnet.csproj" />
18+
</ItemGroup>
19+
20+
</Project>

libsignal-service-dotnet.sln

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26403.3
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsignal-service-dotnet", "libsignal-service-dotnet\libsignal-service-dotnet.csproj", "{088F38F5-EFA5-4264-BAC0-E745F9170222}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libsignal-service-dotnet", "libsignal-service-dotnet\libsignal-service-dotnet.csproj", "{088F38F5-EFA5-4264-BAC0-E745F9170222}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsignal-service-dotnet-tests", "libsignal-service-dotnet-tests\libsignal-service-dotnet-tests.csproj", "{BD335150-6F1F-42A7-9221-5D3FFF75CD99}"
79
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,8 +17,15 @@ Global
1517
{088F38F5-EFA5-4264-BAC0-E745F9170222}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{088F38F5-EFA5-4264-BAC0-E745F9170222}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{088F38F5-EFA5-4264-BAC0-E745F9170222}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{BD335150-6F1F-42A7-9221-5D3FFF75CD99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{BD335150-6F1F-42A7-9221-5D3FFF75CD99}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{BD335150-6F1F-42A7-9221-5D3FFF75CD99}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{BD335150-6F1F-42A7-9221-5D3FFF75CD99}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE
2127
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {B63990B0-8D7F-4CCF-A0E8-CD7C80CB951D}
30+
EndGlobalSection
2231
EndGlobal

0 commit comments

Comments
 (0)