Skip to content

Commit

Permalink
New packages now.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Jun 26, 2016
1 parent 68a3b9c commit dce6d87
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Gu.Units.Json/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]
[assembly: AssemblyVersion("0.10.0.0")]
[assembly: AssemblyFileVersion("0.10.0.0")]
[assembly: NeutralResourcesLanguage("en")]

2 changes: 2 additions & 0 deletions Gu.Units.Tests/Gu.Units.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<Compile Include="Benchmarks\FormattingBenchmarks.cs" />
<Compile Include="Benchmarks\ParsingBenchmarks.cs" />
<Compile Include="Benchmarks\SubstringCacheBenchmarks.cs" />
<Compile Include="LengthTests.Conversions.cs" />
<Compile Include="TemperatureTests.cs" />
<Compile Include="TestHelpers\ConversionData.cs" />
<Compile Include="ConversionTests.cs" />
<Compile Include="FormatTests.cs" />
Expand Down
43 changes: 43 additions & 0 deletions Gu.Units.Tests/LengthTests.Conversions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Gu.Units.Tests
{
using System.Collections.Generic;
using System.Globalization;

using NUnit.Framework;

public partial class LengthTests
{
public static IReadOnlyList<ConversionData> ConversionSource { get; } = new[]
{
new ConversionData("25.4 mm", "1 in"),
new ConversionData("0.0254 m", "1 in"),
new ConversionData("12 in", "1 ft", status:ConversionData.GenerationStatus.NotGenerated),
new ConversionData("1 ft", "0.3048 m",status:ConversionData.GenerationStatus.NotGenerated),
new ConversionData("1 m", "100 cm"),
new ConversionData("1 m", "1000 mm"),
new ConversionData("1 km", "1000 m"),
new ConversionData("1 mi", "1.609344 km"),
new ConversionData("1 mi", "1760 yd"),
};

[TestCaseSource(nameof(ConversionSource))]
public void Conversion(ConversionData data)
{
if (data.Status == ConversionData.GenerationStatus.NotGenerated)
{
Assert.Inconclusive(data.ToString());
}

var l1 = Length.Parse(data.From, CultureInfo.InvariantCulture);
var l2 = Length.Parse(data.To, CultureInfo.InvariantCulture);
if (data.Exactly)
{
Assert.AreEqual(l1, l2);
}
else
{
Assert.AreEqual(l1.ToString(), l2.ToString());
}
}
}
}
2 changes: 1 addition & 1 deletion Gu.Units.Tests/LengthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// <summary>
/// Just testing for length assuming the other generated units will work.
/// </summary>
public class LengthTests
public partial class LengthTests
{
[Test]
public void Equality()
Expand Down
37 changes: 37 additions & 0 deletions Gu.Units.Tests/TemperatureTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Gu.Units.Tests
{
using System.Collections.Generic;
using System.Globalization;

using NUnit.Framework;

public class TemperatureTests
{
public static IReadOnlyList<ConversionData> ConversionSource { get; } = new[]
{
new ConversionData("0.01°C", "273.16K", false),
new ConversionData("32.018°F", "273.16K", false),
new ConversionData("-40°F", "-40°C", false),
};

[TestCaseSource(nameof(ConversionSource))]
public void Conversion(ConversionData data)
{
if (data.Status == ConversionData.GenerationStatus.NotGenerated)
{
Assert.Inconclusive(data.ToString());
}

var t1 = Temperature.Parse(data.From, CultureInfo.InvariantCulture);
var t2 = Temperature.Parse(data.To, CultureInfo.InvariantCulture);
if (data.Exactly)
{
Assert.AreEqual(t1, t2);
}
else
{
Assert.AreEqual(t1.ToString(), t2.ToString());
}
}
}
}
15 changes: 14 additions & 1 deletion Gu.Units.Tests/TestHelpers/ConversionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ namespace Gu.Units.Tests
{
public class ConversionData
{
public readonly GenerationStatus Status;

public ConversionData(string @from,
string to,
bool exactly = true)
bool exactly = true,
GenerationStatus status = GenerationStatus.Ok)
{
this.Status = status;
this.From = @from;
this.To = to;
this.Exactly = exactly;
Expand All @@ -25,5 +29,14 @@ public override string ToString()
: "~";
return $"{this.From} {equalitySymbol} {this.To}";
}

/// <summary>
/// The reason for this is that the generator chokes. Nice to be able to write tests as reminders
/// </summary>
public enum GenerationStatus
{
Ok,
NotGenerated
}
}
}
4 changes: 2 additions & 2 deletions Gu.Units.Wpf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]
[assembly: AssemblyVersion("0.10.0.0")]
[assembly: AssemblyFileVersion("0.10.0.0")]
[assembly:InternalsVisibleTo("Gu.Units.Wpf.Tests", AllInternalsVisible = true)]

[assembly: XmlnsDefinition("http://Gu.com/Units", clrNamespace: "Gu.Units", AssemblyName = "Gu.Units")]
Expand Down
4 changes: 2 additions & 2 deletions Gu.Units/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]
[assembly: AssemblyVersion("0.10.0.0")]
[assembly: AssemblyFileVersion("0.10.0.0")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: InternalsVisibleTo("Gu.Units.Tests")]
[assembly: InternalsVisibleTo("Gu.Units.Wpf")]
Expand Down

0 comments on commit dce6d87

Please sign in to comment.