Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add write/increment methods

  • Loading branch information...
commit b5afabe2c27cb06849e699ad61cc5411c3c48e94 1 parent 106cafe
@maddenpj maddenpj authored
View
48 Client.Tests/IncrementTests.cs
@@ -67,4 +67,52 @@ public void RequestCount()
mockClient.Verify(cl => cl.Execute(It.IsAny<RestRequest>()), Times.Exactly(100));
}
}
+
+ [TestFixture]
+ public class MultiIncrementTests
+ {
+ [Test]
+ public void RequestMethod()
+ {
+ var mockclient = TestCommon.GetMockRestClient();
+ var client = TestCommon.GetClient(mockclient.Object);
+
+ var dp1 = new MultiIdPoint("id1", new DateTime(2013, 9, 25, 0, 0, 1), 1224L);
+ var dp2 = new MultiKeyPoint("key1", new DateTime(2013, 9, 25, 0, 0, 1), 1000L);
+ var list = new List<MultiPoint>{ dp1, dp2 };
+ client.IncrementMultiData(list);
+
+ Expression<Func<RestRequest, bool>> assertion = req => req.Method == Method.POST;
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(assertion)));
+ }
+
+ [Test]
+ public void RequestUrl()
+ {
+ var mockclient = TestCommon.GetMockRestClient();
+ var client = TestCommon.GetClient(mockclient.Object);
+
+ var dp1 = new MultiIdPoint("id1", new DateTime(2013, 9, 25, 0, 0, 1), 1224);
+ var dp2 = new MultiKeyPoint("key1", new DateTime(2013, 9, 25, 0, 0, 1), 1000L);
+ var list = new List<MultiPoint>{ dp1, dp2 };
+ client.IncrementMultiData(list);
+
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => req.Resource == "/multi/increment/")));
+ }
+
+ [Test]
+ public void IncludesPoints()
+ {
+ var mockclient = TestCommon.GetMockRestClient();
+ var client = TestCommon.GetClient(mockclient.Object);
+
+ var dp1 = new MultiIdPoint("id1", new DateTime(2013, 9, 25, 0, 0, 1), 1224);
+ var dp2 = new MultiKeyPoint("key1", new DateTime(2013, 9, 25, 0, 0, 1), 1000L);
+ var list = new List<MultiPoint>{ dp1, dp2 };
+ client.IncrementMultiData(list);
+
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "1224"))));
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "1000"))));
+ }
+ }
}
View
48 Client.Tests/WriteTests.cs
@@ -67,4 +67,52 @@ public void RequestCount()
mockClient.Verify(cl => cl.Execute(It.IsAny<RestRequest>()), Times.Exactly(100));
}
}
+
+ [TestFixture]
+ public class MultiTests
+ {
+ [Test]
+ public void RequestMethod()
+ {
+ var mockclient = TestCommon.GetMockRestClient();
+ var client = TestCommon.GetClient(mockclient.Object);
+
+ var dp1 = new MultiIdPoint("id1", new DateTime(2013, 9, 25, 0, 0, 1), 12.24);
+ var dp2 = new MultiKeyPoint("key1", new DateTime(2013, 9, 25, 0, 0, 1), 1000L);
+ var list = new List<MultiPoint>{ dp1, dp2 };
+ client.WriteMultiData(list);
+
+ Expression<Func<RestRequest, bool>> assertion = req => req.Method == Method.POST;
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(assertion)));
+ }
+
+ [Test]
+ public void RequestUrl()
+ {
+ var mockclient = TestCommon.GetMockRestClient();
+ var client = TestCommon.GetClient(mockclient.Object);
+
+ var dp1 = new MultiIdPoint("id1", new DateTime(2013, 9, 25, 0, 0, 1), 12.24);
+ var dp2 = new MultiKeyPoint("key1", new DateTime(2013, 9, 25, 0, 0, 1), 1000L);
+ var list = new List<MultiPoint>{ dp1, dp2 };
+ client.WriteMultiData(list);
+
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => req.Resource == "/multi/")));
+ }
+
+ [Test]
+ public void IncludesPoints()
+ {
+ var mockclient = TestCommon.GetMockRestClient();
+ var client = TestCommon.GetClient(mockclient.Object);
+
+ var dp1 = new MultiIdPoint("id1", new DateTime(2013, 9, 25, 0, 0, 1), 12.24);
+ var dp2 = new MultiKeyPoint("key1", new DateTime(2013, 9, 25, 0, 0, 1), 1000L);
+ var list = new List<MultiPoint>{ dp1, dp2 };
+ client.WriteMultiData(list);
+
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "12.24"))));
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "1000"))));
+ }
+ }
}
View
22 Client/Client.cs
@@ -236,6 +236,17 @@ public virtual void WriteBulkData(BulkDataSet dataSet)
}
/// <summary>
+ /// Writes a set of datapoints for different series for different timestamp
+ /// </summary>
+ /// <param name="data"> A List<MultiPoint> to write </param>
+ public virtual void WriteMultiData(List<MultiPoint> data)
+ {
+ const string url = "/multi/";
+ RestRequest request = BuildRequest(url, Method.POST, data);
+ Execute(request);
+ }
+
+ /// <summary>
/// Increments a DataSet by id
/// </summary>
/// <param name="seriesId"> The id of the series into which the data points will be incremented</param>
@@ -276,6 +287,17 @@ public virtual void IncrementBulkData(BulkDataSet dataSet)
}
/// <summary>
+ /// Increments a set of datapoints for different series for different timestamp
+ /// </summary>
+ /// <param name="data"> A List<MultiPoint> to increment </param>
+ public virtual void IncrementMultiData(List<MultiPoint> data)
+ {
+ const string url = "/multi/increment/";
+ RestRequest request = BuildRequest(url, Method.POST, data);
+ Execute(request);
+ }
+
+ /// <summary>
/// Deletes a range of data by id
/// </summary>
/// <param name="seriesId"> The id of the series into which the data points will be deleted</param>

0 comments on commit b5afabe

Please sign in to comment.
Something went wrong with that request. Please try again.