This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
LockFileReaderTests.cs
54 lines (49 loc) · 1.82 KB
/
LockFileReaderTests.cs
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
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.IO;
using System.Text;
using FluentAssertions;
using Microsoft.DotNet.ProjectModel.Graph;
using Xunit;
using NuGet.Versioning;
namespace Microsoft.DotNet.ProjectModel.Tests
{
public class LockFileReaderTests
{
[Theory]
[InlineData("", null)]
[InlineData(@"""path"": null,", null)]
[InlineData(@"""path"": ""foo/1.0.0"",", "foo/1.0.0")]
public void SupportsTheOptionalPathPropertyOfALibraryPackage(string pathProperty, string expected)
{
// Arrange
var reader = new LockFileReader();
var lockFileJson = @"
{
""libraries"": {
""Foo/1.0.0"": {
""sha512"": ""something"",
" + pathProperty + @"
""type"": ""package"",
""files"": [
""lib/netstandard1.0/Foo.dll""
]
}
}
}
";
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(lockFileJson));
// Act
var lockFile = reader.ReadLockFile("project.lock.json", memoryStream, false);
// Assert
lockFile.PackageLibraries.Should().HaveCount(1);
var library = lockFile.PackageLibraries[0];
library.Path.Should().Be(expected);
library.Name.Should().Be("Foo");
library.Version.Should().Be(new NuGetVersion("1.0.0"));
library.Sha512.Should().Be("something");
library.Files.Should().HaveCount(1);
library.Files[0].Should().Be(Path.Combine("lib", "netstandard1.0", "Foo.dll"));
}
}
}