Skip to content

Commit 8d17e61

Browse files
committed
Add 0.9 and 0.95 handling to TCAPIVersion
* Fixes failing test for About resource because of unrecognized versions * Added new property for tracking "known" versions separate from "supported" versions * Added 0.9 and 0.95 to new "known" list as they may be /about response * Switched operator to look at known vs supported version list
1 parent 16938f1 commit 8d17e61

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

TinCan/TCAPIVersion.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,33 @@ public sealed class TCAPIVersion
2323
//public static readonly TCAPIVersion V102 = new TCAPIVersion("1.0.2");
2424
public static readonly TCAPIVersion V101 = new TCAPIVersion("1.0.1");
2525
public static readonly TCAPIVersion V100 = new TCAPIVersion("1.0.0");
26+
public static readonly TCAPIVersion V095 = new TCAPIVersion("0.95");
27+
public static readonly TCAPIVersion V090 = new TCAPIVersion("0.9");
2628

2729
public static TCAPIVersion latest()
2830
{
2931
return V101;
3032
}
3133

34+
private static Dictionary<String, TCAPIVersion> known;
3235
private static Dictionary<String, TCAPIVersion> supported;
3336

37+
public static Dictionary<String, TCAPIVersion> GetKnown()
38+
{
39+
if (known != null) {
40+
return known;
41+
}
42+
43+
known = new Dictionary<String, TCAPIVersion>();
44+
//known.Add("1.0.2", V102);
45+
known.Add("1.0.1", V101);
46+
known.Add("1.0.0", V100);
47+
known.Add("0.95", V095);
48+
known.Add("0.9", V090);
49+
50+
return known;
51+
}
52+
3453
public static Dictionary<String, TCAPIVersion> GetSupported()
3554
{
3655
if (supported != null) {
@@ -47,10 +66,10 @@ public static Dictionary<String, TCAPIVersion> GetSupported()
4766

4867
public static explicit operator TCAPIVersion(String vStr)
4968
{
50-
var s = GetSupported();
69+
var s = GetKnown();
5170
if (!s.ContainsKey(vStr))
5271
{
53-
throw new ArgumentException("Unsupported version: " + vStr);
72+
throw new ArgumentException("Unrecognized version: " + vStr);
5473
}
5574

5675
return s[vStr];

0 commit comments

Comments
 (0)