From dce6d87dfb6952cabf0129cb6aa78dda2486b246 Mon Sep 17 00:00:00 2001 From: Johan Larsson Date: Sun, 26 Jun 2016 12:31:13 +0200 Subject: [PATCH] New packages now. --- Gu.Units.Json/Properties/AssemblyInfo.cs | 4 +- Gu.Units.Tests/Gu.Units.Tests.csproj | 2 + Gu.Units.Tests/LengthTests.Conversions.cs | 43 ++++++++++++++++++++ Gu.Units.Tests/LengthTests.cs | 2 +- Gu.Units.Tests/TemperatureTests.cs | 37 +++++++++++++++++ Gu.Units.Tests/TestHelpers/ConversionData.cs | 15 ++++++- Gu.Units.Wpf/Properties/AssemblyInfo.cs | 4 +- Gu.Units/Properties/AssemblyInfo.cs | 4 +- 8 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 Gu.Units.Tests/LengthTests.Conversions.cs create mode 100644 Gu.Units.Tests/TemperatureTests.cs diff --git a/Gu.Units.Json/Properties/AssemblyInfo.cs b/Gu.Units.Json/Properties/AssemblyInfo.cs index 201a7101..a9b17d60 100644 --- a/Gu.Units.Json/Properties/AssemblyInfo.cs +++ b/Gu.Units.Json/Properties/AssemblyInfo.cs @@ -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")] diff --git a/Gu.Units.Tests/Gu.Units.Tests.csproj b/Gu.Units.Tests/Gu.Units.Tests.csproj index 6b0fc32a..e770a3b5 100644 --- a/Gu.Units.Tests/Gu.Units.Tests.csproj +++ b/Gu.Units.Tests/Gu.Units.Tests.csproj @@ -47,6 +47,8 @@ + + diff --git a/Gu.Units.Tests/LengthTests.Conversions.cs b/Gu.Units.Tests/LengthTests.Conversions.cs new file mode 100644 index 00000000..65b4cea1 --- /dev/null +++ b/Gu.Units.Tests/LengthTests.Conversions.cs @@ -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 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()); + } + } + } +} \ No newline at end of file diff --git a/Gu.Units.Tests/LengthTests.cs b/Gu.Units.Tests/LengthTests.cs index 8be45df0..5a90a817 100644 --- a/Gu.Units.Tests/LengthTests.cs +++ b/Gu.Units.Tests/LengthTests.cs @@ -8,7 +8,7 @@ /// /// Just testing for length assuming the other generated units will work. /// - public class LengthTests + public partial class LengthTests { [Test] public void Equality() diff --git a/Gu.Units.Tests/TemperatureTests.cs b/Gu.Units.Tests/TemperatureTests.cs new file mode 100644 index 00000000..39870a24 --- /dev/null +++ b/Gu.Units.Tests/TemperatureTests.cs @@ -0,0 +1,37 @@ +namespace Gu.Units.Tests +{ + using System.Collections.Generic; + using System.Globalization; + + using NUnit.Framework; + + public class TemperatureTests + { + public static IReadOnlyList 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()); + } + } + } +} \ No newline at end of file diff --git a/Gu.Units.Tests/TestHelpers/ConversionData.cs b/Gu.Units.Tests/TestHelpers/ConversionData.cs index e4d02d12..350fce08 100644 --- a/Gu.Units.Tests/TestHelpers/ConversionData.cs +++ b/Gu.Units.Tests/TestHelpers/ConversionData.cs @@ -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; @@ -25,5 +29,14 @@ public override string ToString() : "~"; return $"{this.From} {equalitySymbol} {this.To}"; } + + /// + /// The reason for this is that the generator chokes. Nice to be able to write tests as reminders + /// + public enum GenerationStatus + { + Ok, + NotGenerated + } } } \ No newline at end of file diff --git a/Gu.Units.Wpf/Properties/AssemblyInfo.cs b/Gu.Units.Wpf/Properties/AssemblyInfo.cs index 8e97e51d..690ca8d4 100644 --- a/Gu.Units.Wpf/Properties/AssemblyInfo.cs +++ b/Gu.Units.Wpf/Properties/AssemblyInfo.cs @@ -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")] diff --git a/Gu.Units/Properties/AssemblyInfo.cs b/Gu.Units/Properties/AssemblyInfo.cs index a219478d..2155d41c 100644 --- a/Gu.Units/Properties/AssemblyInfo.cs +++ b/Gu.Units/Properties/AssemblyInfo.cs @@ -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")]