Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Support parsing null dependencies from the lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed May 25, 2015
1 parent c6872ef commit 8287572
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public LockFile Read(string filePath)
}
}

private LockFile Read(Stream stream)
internal LockFile Read(Stream stream)
{
try
{
Expand Down Expand Up @@ -254,6 +254,10 @@ private string ReadString(JsonValue json)
{
return (json as JsonString).Value;
}
else if(json is JsonNull)
{
return null;
}
else
{
throw FileFormatException.Create("The value type is not string.", json);
Expand Down
79 changes: 79 additions & 0 deletions test/Microsoft.Framework.Runtime.Tests/LockFileReaderFacts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Framework.Runtime.DependencyManagement;
using NuGet;
using Xunit;

namespace Microsoft.Framework.Runtime.Tests
{
public class LockFileReaderFacts
{
[Fact]
public void NullDependencyVersionsAreParsed()
{
var lockFileData = @"{
""locked"": false,
""version"": -9996,
""targets"": {
"".NETFramework,Version=v4.5"": {
""WindowsAzure.ServiceBus/2.6.7"": {
""dependencies"": {
""Microsoft.WindowsAzure.ConfigurationManager"": null
},
""frameworkAssemblies"": [
""System.ServiceModel"",
""System.Xml"",
""System.Runtime.Serialization""
],
""compile"": {
""lib/net40-full/Microsoft.ServiceBus.dll"": {}
},
""runtime"": {
""lib/net40-full/Microsoft.ServiceBus.dll"": {}
}
}
}
},
""libraries"": {
""WindowsAzure.ServiceBus/2.6.7"": {
""sha512"": ""AhQ4nya0Pu0tGev/Geqt5+yBTI+ov66ginMHCm+HqmXezTIOSfBu7HOI5RuvmiQqM99AeTuASD6gMz+zWueHNQ=="",
""files"": [
""WindowsAzure.ServiceBus.2.6.7.nupkg"",
""WindowsAzure.ServiceBus.2.6.7.nupkg.sha512"",
""WindowsAzure.ServiceBus.nuspec"",
""content/app.config.install.xdt"",
""content/web.config.install.xdt"",
""lib/net40-full/Microsoft.ServiceBus.dll"",
""lib/net40-full/Microsoft.ServiceBus.xml""
]
}
},
""projectFileDependencyGroups"": {
"""": [
""WindowsAzure.ServiceBus >= 2.6.7""
],
"".NETFramework,Version=v4.5"": []
}
}";

var reader = new LockFileReader();

var stream = new MemoryStream(Encoding.UTF8.GetBytes(lockFileData));
var lockFile = reader.Read(stream);

Assert.False(lockFile.Islocked);
Assert.Equal(1, lockFile.Targets.Count);
var library = lockFile.Targets[0].Libraries[0];
Assert.Equal("WindowsAzure.ServiceBus", library.Name);
Assert.Equal(SemanticVersion.Parse("2.6.7"), library.Version);
Assert.Equal(1, library.Dependencies.Count);
var dependency = library.Dependencies[0];
Assert.Equal(dependency.Id, "Microsoft.WindowsAzure.ConfigurationManager");
Assert.Null(dependency.VersionSpec);
}
}
}

0 comments on commit 8287572

Please sign in to comment.