public string CreateTestData()
        {
            if (!Request.IsLocal)
            {
                throw new HttpException(401, "Unauthorized access");
            }

            var stationId  = "myTestStation";
            var sensorType = "Temperature";
            var startTime  = new DateTime(2016, 1, 1);

            _repository.DeleteAllByStationId(stationId);

            var points = Enumerable
                         .Range(1, 5000)
                         .Select(i => new DataPoint
            {
                ReceivedTimestampUtc = DateTime.UtcNow,
                SensorTimestampUtc   = startTime + TimeSpan.FromMinutes(15 * i),
                SensorType           = sensorType,
                StationId            = stationId,
                SensorValueNumber    = ToSensorValue(i)
            });

            foreach (var dataPoint in points)
            {
                _repository.Save(dataPoint);
            }

            return("OK");
        }
예제 #2
0
        public void DeleteAllByStationIdTest()
        {
            var dataPointToKeep = CreateDataPoint("s1");

            _repository.Save(dataPointToKeep);
            _repository.Save(CreateDataPoint("s2"));

            _repository.DeleteAllByStationId("s2");

            var dataPoints = _repository.FindAll();

            dataPoints.Should().HaveCount(1);
            DataPoint.IdentityEquals(dataPointToKeep, dataPoints[0]).Should().BeTrue();
        }