-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from AArnott/BuildNumberFromVersionJson
Allow user control of build number integer
- Loading branch information
Showing
13 changed files
with
382 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.IO; | ||
using System.Reflection; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using Newtonsoft.Json.Schema; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
public class VersionSchemaTests | ||
{ | ||
private readonly ITestOutputHelper Logger; | ||
|
||
private readonly JSchema schema; | ||
|
||
private JObject json; | ||
|
||
public VersionSchemaTests(ITestOutputHelper logger) | ||
{ | ||
this.Logger = logger; | ||
using (var schemaStream = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($"{ThisAssembly.RootNamespace}.version.schema.json"))) | ||
{ | ||
this.schema = JSchema.Load(new JsonTextReader(schemaStream)); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void VersionField_BasicScenarios() | ||
{ | ||
json = JObject.Parse(@"{ ""version"": ""2.3"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3-beta"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3-beta-final"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3-beta.2"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3-beta.0"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3-beta.01"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""1.2.3"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""1.2.3.4"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
|
||
json = JObject.Parse(@"{ ""version"": ""02.3"" }"); | ||
Assert.False(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.03"" }"); | ||
Assert.False(json.IsValid(this.schema)); | ||
} | ||
|
||
[Fact] | ||
public void VersionField_HeightMacroPlacement() | ||
{ | ||
// Valid uses | ||
json = JObject.Parse(@"{ ""version"": ""2.3.0-{height}"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3.0-{height}.beta"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3.0-beta.{height}"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3.0-beta+{height}"" }"); | ||
Assert.True(json.IsValid(this.schema)); | ||
|
||
// Invalid uses | ||
json = JObject.Parse(@"{ ""version"": ""2.3.{height}-beta"" }"); | ||
Assert.False(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3.0-beta-{height}"" }"); | ||
Assert.False(json.IsValid(this.schema)); | ||
json = JObject.Parse(@"{ ""version"": ""2.3.0-beta+height-{height}"" }"); | ||
Assert.False(json.IsValid(this.schema)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.