Permalink
Browse files

Added Include Points to Write Tests

  • Loading branch information...
1 parent dea1a59 commit d5c743cb4af34cae28b3a9e0a5b3ff387318d9d6 @maddenpj maddenpj committed Dec 17, 2012
Showing with 15 additions and 2 deletions.
  1. +9 −0 Client.Tests/TestCommon.cs
  2. +6 −2 Client.Tests/WriteTests.cs
@@ -61,5 +61,14 @@ public static bool ContainsParameter(List<Parameter> parameters, string name, st
}
return false;
}
+
+ public static bool ContainsParameterByPattern(List<Parameter> parameters, string name, string value)
+ {
+ foreach (var parameter in parameters)
+ {
+ if (parameter.Name.ToString() == name && parameter.Value.ToString().Contains(value)) return true;
+ }
+ return false;
+ }
}
}
@@ -41,13 +41,17 @@ public void ItShouldAddDataPointToSeriesByKey_RequestMethod()
}
[Test]
- public void ItShouldAddDataPointToSeriesByKey_JsonObject()
+ public void ItShouldAddDataPointToSeriesByKey_IncludesPoints()
{
- Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "application/json", "[{\"t\":\"2012-12-12T00:00:00.000-08:00\",\"v\":12.34}]");
+ Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "12.34") &&
+ TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "56.78") &&
+ TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "90.12");
var client = TestCommon.GetClient(TestCommon.GetMockRestClient(assertion).Object);
var data = new List<DataPoint>();
data.Add(new DataPoint(new DateTime(2012,12,12), 12.34));
+ data.Add(new DataPoint(new DateTime(2012, 12, 12, 0, 0, 1), 56.78));
+ data.Add(new DataPoint(new DateTime(2012, 12, 12, 0, 0, 2), 90.12));
client.WriteByKey("testkey", data);
}

0 comments on commit d5c743c

Please sign in to comment.