public void CanDeleteReading()
        {
            var sut     = new ReadingRepository(TestHelper.GetDataAccessHelper());
            var reading = new ReadingModel()
            {
                Day            = DateTime.Today.AddDays(-1),
                LocationId     = 1,
                PowerUsed      = 19.8M,
                SolarGenerated = 30.1M
            };
            var taskCreate = sut.CreateReading(reading);

            taskCreate.Wait();
            var item = taskCreate.Result;

            Assert.NotNull(item);
            Assert.True(item.Id > 0);

            var taskDelete = sut.DeleteReading(item.Id);

            taskDelete.Wait();

            var taskGet = sut.GetReading(item.Id);

            taskGet.Wait();
            Assert.Null(taskGet.Result);
        }
        public void CanUpdateReading()
        {
            var sut     = new ReadingRepository(TestHelper.GetDataAccessHelper());
            var reading = new ReadingModel()
            {
                Day            = DateTime.Today.AddDays(-1),
                LocationId     = 1,
                PowerUsed      = 19.8M,
                SolarGenerated = 30.1M
            };
            var taskCreate = sut.CreateReading(reading);

            taskCreate.Wait();
            var item = taskCreate.Result;

            Assert.NotNull(item);
            Assert.True(item.Id > 0);
            var random = new Random();

            item.PowerUsed      = random.Next(5, 60);
            item.SolarGenerated = random.Next(50, 90);
            var taskUpdate = sut.UpdateReading(item);

            taskUpdate.Wait();
            var updatedItem = taskUpdate.Result;

            Assert.NotNull(updatedItem);
            Assert.Equal(item.Id, updatedItem.Id);
            Assert.Equal(item.LocationId, updatedItem.LocationId);
            Assert.Equal(item.PowerUsed, updatedItem.PowerUsed);
            Assert.Equal(item.SolarGenerated, updatedItem.SolarGenerated);
        }
        public void CantCreateReadingWithNoLocationId()
        {
            var sut     = new ReadingRepository(TestHelper.GetDataAccessHelper());
            var reading = new ReadingModel()
            {
                Day            = DateTime.Today.AddDays(-1),
                PowerUsed      = 19.8M,
                SolarGenerated = 30.1M
            };

            Assert.ThrowsAsync <ArgumentException>(() => sut.CreateReading(reading)).Wait();
        }