private async Task WCFReadMeasurementsAsync(MeasurementQueryModel q, int expectedCount) { MeasurementsServiceClient client = new MeasurementsServiceClient(); Stopwatch sw = Stopwatch.StartNew(); var result = await client.GetMeasurementsAsync(q); sw.Stop(); client.Close(); Trace.WriteLine(string.Format("GetMeasurements with query {0} took {1} ms and returned {2} results.", GetQueryString(q), sw.ElapsedMilliseconds, result.Length)); Assert.IsNotNull(result); Assert.AreEqual(expectedCount, result.Length); }
private void WCFSendMeasurements(int measurementsCount, int dataCount, bool useLocation, bool createFaultyMeasurements) { MeasurementsServiceClient client = new MeasurementsServiceClient(); DateTimeOffset measTime = DateTimeOffset.Now; var package = measTime.GetMeasurementPackageWithXMeasurementsAndYData("WCF client", measurementsCount, dataCount, useLocation); if (createFaultyMeasurements) { var lastMeasurement = package.Measurements[package.Measurements.Length - 1]; if (lastMeasurement.Data.Length > 1) { lastMeasurement.Data[0].Tag = lastMeasurement.Data[1].Tag; } } Stopwatch sw = Stopwatch.StartNew(); var result = client.SaveMeasurementPackage(package); sw.Stop(); client.Close(); Trace.WriteLine(string.Format("SaveMeasurementPackage with {0} measurement took {1} ms", package.Measurements.Length, sw.ElapsedMilliseconds)); Assert.IsNotNull(result); if (createFaultyMeasurements) { Assert.IsFalse(result.Success); Assert.IsNotNull(result.Failures); foreach (var f in result.Failures) { Trace.WriteLine(string.Format("{0}, {1}, {2}", f.Index, f.Code, f.Reason)); } } else { Assert.IsTrue(result.Success); Assert.IsNull(result.Failures); } //Assert.AreEqual<int>(result.Statuses.Length, measurementsCount); //var item = result.Statuses[0]; //Assert.IsTrue(item.IsSaved); //Assert.AreEqual<DateTimeOffset>(item.MeasurementTimeStamp, measTime); }
public async Task WCFReadMeasurementsTop100Async() { int expected = 100; MeasurementQueryModel q = new MeasurementQueryModel() { Key = TestHelper.TestKey, Take = expected }; MeasurementsServiceClient client = new MeasurementsServiceClient(); Stopwatch sw = Stopwatch.StartNew(); var result = await client.GetMeasurementsAsync(q); sw.Stop(); client.Close(); Trace.WriteLine(string.Format("GetMeasurements (async) with query {0} took {1} ms and returned {2} results.", GetQueryString(q), sw.ElapsedMilliseconds, result.Length)); Assert.IsNotNull(result); Assert.AreEqual(expected, result.Length); }