Beispiel #1
0
        public void GetRoomMeasure_With_Bad_Type_Should_Throw_ArgumentException()
        {
            var         sut = new Netatmo.EnergyClient("https://api.netatmo.com/", credentialManagerMock.Object);
            Func <Task> actTemperatureStep = async() => { await sut.GetRoomMeasure <DateTemperatureStep>(new GetRoomMeasureParameters
                {
                    HomeId = "5a327cbdb05a2133678b5d3e",
                    RoomId = "2255031728",
                    Scale  = Scale.Max,
                    Type   = ThermostatMeasurementType.Temperature
                }); };

            actTemperatureStep
            .Should().Throw <ArgumentException>()
            .WithMessage("TemperatureStep should be used with a temperature measurement");

            Func <Task> actDateTemperatureStep = async() => { await sut.GetRoomMeasure <TemperatureStep>(new GetRoomMeasureParameters
                {
                    HomeId = "5a327cbdb05a2133678b5d3e",
                    RoomId = "2255031728",
                    Scale  = Scale.OneMonth,
                    Type   = ThermostatMeasurementType.DateMinTemp
                }); };

            actDateTemperatureStep
            .Should().Throw <ArgumentException>()
            .WithMessage("DateTemperatureStep should be used with a date of temperature measurement");
        }
Beispiel #2
0
        public async Task GetRoomMeasure_Should_Return_TemperatureSteps()
        {
            var parameters = new GetRoomMeasureParameters
            {
                HomeId = "5a327cbdb05a2133678b5d3e",
                RoomId = "2255031728",
                Scale  = Scale.Max,
                Type   = ThermostatMeasurementType.Temperature
            };

            httpTest.RespondWith(
                "{\"body\":[{\"beg_time\":1513259100,\"step_time\":1800,\"value\":[[27.9],[27.1],[26.2],[25.4],[25.8],[26.2],[26.7],[26.9],[27],[27.1],[27.2],[27],[26.8],[26.6],[26.5],[26.3],[26.3],[26.3],[26.2],[26.2],[26.2],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26],[26],[26.1],[26],[26],[26],[26],[26],[25.9],[24.8],[24],[23.6],[23.5],[23.2],[23],[22.9],[22.7],[22.5],[22.4],[22.4],[22.6],[22.8],[23.1],[23.2],[23.4],[23.4],[23.3],[23.1],[22.9],[22.5],[22.2],[21.9],[21.6],[21.6],[21.4],[21.2],[21.1],[21],[20.9],[20.8],[20.7],[20.7],[20.6],[20.6],[20.6],[20.5],[20.5],[20.5],[20.4],[20.4],[20.4],[20.4],[20.4],[20.3],[20.3],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.3],[20.3],[20.3],[20.3],[20.2],[20.2],[20.1],[20],[20],[19.9],[19.8],[19.8],[19.8],[19.7],[19.7],[19.7],[19.6],[19.9],[20.2],[20.6],[20.6],[20.7],[20.6],[20.7],[20.7],[20.7],[20.8],[20.7],[20.8],[20.7],[20.8],[20.5],[20.2],[20],[19.9],[19.7],[19.6],[19.5],[19.5],[19.4],[19.4],[19.4],[19.5],[19.5],[19.6],[19.6],[19.6],[19.7],[19.7],[19.7],[19.7],[19.7],[19.7],[19.6],[19.6],[19.5],[19.4],[19.4],[19.3],[19.3],[19.3],[19.3],[19.2],[19.2],[19.3],[20],[20.6],[20.8],[20.9],[20.8],[20.9],[21],[20.8],[20.9],[20.9],[20.7],[20.8],[20.8],[20.7],[20.4],[20.2],[20],[19.9],[19.7],[19.6],[19.6],[19.5],[19.7],[20.3],[20.6],[21],[21.3],[21.7],[21.9],[21.7],[21.6],[21.6],[21.5],[21.6],[21.9],[22.1],[22],[22],[22.1],[22.2],[22.3],[22.2],[21.9],[21.5],[21.1],[20.7],[20.5],[20.3],[20.4],[20.6],[20.7],[20.7],[20.8],[20.7],[20.8],[20.7],[20.8],[20.7],[20.8],[20.7],[20.8],[20.8],[20.5],[20.2],[20],[19.9],[19.7],[19.7],[19.6],[19.5],[19.7],[20.2],[20.6],[21],[21.4],[21.7],[21.7],[21.5],[21.2],[21],[21],[21.2],[21.5],[21.8],[22.2],[22.2],[22.3],[22.6],[23.4],[23.8],[24.2],[24.4],[24.4],[24.4],[24.5],[24.5],[24.5],[24.6],[24.6],[24.6],[24.6],[24.6],[24.7],[24.7],[24.7],[24.7],[24.8],[24.8],[24.8],[24.9],[24.9],[24.9],[25],[25],[25.1],[25.1],[25.1],[25.2],[25.2],[25.3],[25.6],[25.9],[26.1],[26.4],[26.5],[26.4],[26.3],[26.2],[26.3],[26.4],[26.5],[26.7],[26.8],[26.7],[26.9],[27],[27],[26.7],[26.6],[26.5],[26.3],[26.2],[26.1],[26],[26],[26],[26],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[26],[26],[26],[26],[26],[26.1],[26.1],[25.2],[23.9],[23.2],[24.1],[25.1],[25.9],[26.3],[26.6],[26.6],[26.2],[25.7],[25],[24.4],[25.1],[25.7],[26.2],[26.3],[26.1],[25.9],[25.2],[24],[22.9],[21.9],[21],[20.2],[19.6],[19.3],[19.1],[19],[18.9],[18.8],[18.7],[18.6],[18.5],[18.4],[18.3],[18.2],[18.1],[18],[17.9],[17.8],[17.6],[17.4],[17.3],[17.1],[17],[17],[17.3],[18.2],[20.2],[21.9],[23.2],[24.1],[24.8],[25.2],[24.8],[23.9],[24.3],[25],[25.6],[26],[26.2],[26.3],[26.4],[26.4],[26.5],[26.5],[26.4],[26.3],[26.2],[26.1],[26],[25.9],[25.9],[25.9],[25.8],[25.8],[25.8],[25.8],[25.8],[25.8],[25.8],[25.8],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[25.9],[26],[26],[26],[26],[26],[26],[26],[26.1],[26.1],[26.1],[26.2],[26.2],[26.2],[26.2],[26.2],[26.3],[26.3],[26.3],[26.3],[26.2],[26.2],[26.2],[26.2],[26.2],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.3],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.2],[26.3],[26.3],[26.4],[26.4],[26.5],[26.4],[26.4],[26.3],[26.3],[26.3],[26.3],[26.2],[26.2],[26.2],[26.2],[26.2],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26.1],[26],[26],[25.9],[25.9],[25.8],[25.8],[25.8],[25.7],[25.7],[25.7],[25.7],[25.7],[25.7],[25.7],[25.8],[25.9],[26],[26],[24.8],[23.8],[24.4],[24.9],[25.3],[25.8],[26.1],[26.4],[26.6],[26.7],[26.7],[26.8],[26.9],[26.9],[27.1],[27.2],[27.3],[27.3],[27.3],[27.3],[27.2],[27.1],[27],[26.9],[26.8],[26.7],[26.6],[26.5],[26.5],[26.4],[26.4],[26.3],[26.2],[26.1],[26.1],[26],[26],[25.9],[25.9],[25.9],[25.8],[25.8],[25.8],[25.9],[26],[26.1],[26.2],[26.2],[26.3],[25.1],[24.9],[25.2],[25.6],[26],[26.4],[26.6],[26.7],[26.7],[26.7],[26.6],[26.6],[26.7],[26.7],[26.9],[26.6],[26.5],[26.6],[26.7],[26.7],[26.5],[26.5],[26.4],[26.4],[26.4],[26.4],[26.4],[26.3],[26.3],[26.2],[26.2],[26.1],[26.1],[26],[26],[25.9],[25.9],[25.9],[25.8],[25.8],[25.8],[25.8],[25.8],[25.8],[25.9],[25.9],[25.9],[25.9],[26],[26.1],[25.9],[24.8],[25.2],[25.7],[26.3],[26.6],[26.7],[26.8],[26.8],[26.7],[26.9],[27],[27.1],[27.1],[26.8],[26.3],[25.4],[24.6],[23.8],[23.2],[22.6],[22.2],[21.9],[21.6],[21.5],[21.4],[21.3],[21.2],[21.1],[21],[21],[20.9],[20.8],[20.8],[20.7],[20.7],[20.6],[20.6],[20.6],[20.5],[20.5],[20.4],[20.4],[20.3],[20.2],[20.2],[20.2],[20.3],[20.5],[20.7],[20.9],[21.1],[21.2],[21.3],[21.3],[21.3],[21.3],[21.3],[21.4],[21.5],[21.5],[21.6],[21.6],[21.6],[21.6],[21.6],[21.4],[21],[20.8],[20.6],[20.4],[20.3],[20.2],[20.4],[20.5],[20.5],[20.5],[20.5],[20.5],[20.5],[20.6],[20.5],[20.6],[20.5],[20.6],[20.5],[20.6],[20.4],[20.3],[20.3],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.3],[20.3],[20.3],[20.4],[20.4],[20.5],[20.5],[20.4],[20.4],[20.4],[20.4],[20.4],[20.4],[20.3],[20.3],[20.3],[20.3],[20.3],[20.2],[20.2],[20.2],[20.2],[20.2],[20.2],[20.5],[20.7],[20.7],[20.8],[20.7],[20.7],[20.7],[20.8],[20.8],[20.7],[20.8],[20.7],[20.8],[20.7],[20.5],[20.4],[20.3],[20.2],[20.2],[20.1],[20.1],[20.1],[20.1],[20.1],[20.1],[20.1],[20.1],[20.1],[20.2],[20.2],[20.3],[20.4],[20.3],[20.3],[20.3],[20.2],[20.2],[20.1],[20],[20],[19.9],[19.9],[19.9],[19.9],[19.8],[19.8],[19.8],[19.8],[20],[20.3],[20.7],[20.7],[20.8],[20.7],[20.8],[20.7],[20.8],[20.7],[20.8],[20.7],[20.8],[20.7],[20.4],[20.1],[20],[19.9],[19.7],[19.7],[19.5],[19.5],[19.5],[19.4],[19.4],[19.4],[19.4],[19.4],[19.4],[19.4],[19.4],[19.5],[19.7],[19.7],[19.6],[19.6],[19.5],[19.5],[19.5],[19.4],[19.4],[19.4],[19.3],[19.3],[19.3],[19.3],[19.3],[19.4],[20.2],[20.7],[20.9],[20.7],[20.8],[20.8],[20.7],[20.8],[20.7],[20.7],[20.8],[20.7],[20.8],[20.7],[20.4],[20.1],[19.8],[19.7],[19.6],[19.5],[19.4],[19.4],[19.5],[19.9],[20.5],[20.8],[21],[21.3],[21.3],[21.1],[20.9],[20.9],[21.2],[21.5],[21.8],[22.1],[22.2],[22.3],[22.3],[22.4],[22.4],[22.1],[21.7],[21.3],[21],[20.7],[20.5],[20.4],[20.6],[20.7],[20.7],[20.9],[20.8],[20.8],[20.8],[20.8],[20.9],[20.8],[20.8],[20.8],[20.8],[20.9],[20.6],[20.4],[20.3],[20.2],[20.1],[20.1],[20],[19.9],[20.2],[20.7],[21.2],[21.7],[21.9],[22],[21.9],[21.6],[21.5],[21.6],[21.8],[22]]},{\"beg_time\":1514992500,\"step_time\":1800,\"value\":[[22.8],[22.9],[22.8],[22.7],[22.8],[22.8],[22.7],[22.3],[21.8],[21.4],[21.1],[20.8],[20.6],[20.6],[20.8],[20.8],[20.9],[20.8],[20.9],[20.9],[20.9],[20.9],[20.9],[20.9],[20.9],[20.9],[20.9],[20.7],[20.6],[20.4],[20.4],[20.3],[20.3],[20.3],[20.3],[20.6],[21.2],[21.4],[21.6],[21.8],[22.1],[22.2],[22],[21.9],[21.9],[22],[22.3],[22.5],[22.6],[22.7],[22.8],[22.8],[22.9],[22.6],[22.3],[21.7],[21.4],[21.1],[20.9],[20.7],[20.5],[20.7]]}],\"status\":\"ok\",\"time_exec\":0.79246497154236,\"time_server\":1518023284}");

            var sut    = new Netatmo.EnergyClient("https://api.netatmo.com/", credentialManagerMock.Object);
            var result = await sut.GetRoomMeasure <TemperatureStep>(parameters);

            httpTest
            .ShouldHaveCalled("https://api.netatmo.com/api/getroommeasure")
            .WithVerb(HttpMethod.Post)
            .WithOAuthBearerToken(accessToken)
            .WithContentType("application/json").WithRequestJson(new GetRoomMeasureRequest
            {
                HomeId = parameters.HomeId,
                RoomId = parameters.RoomId,
                Scale  = parameters.Scale.Value,
                Type   = parameters.Type.Value
            })
            .Times(1);

            result.Body[0].BeginAt.Should().Be(Instant.FromDateTimeUtc(DateTime.SpecifyKind(new DateTime(2017, 12, 14, 13, 45, 0), DateTimeKind.Utc)));
            result.Body.Length.Should().Be(2);
            result.Body[0].Values[0][0].Should().Be(27.9);
            result.Body[0].Values[1][0].Should().Be(27.1);
        }
Beispiel #3
0
        public void GetRoomMeasure_Should_Throw_ArgumentException(GetRoomMeasureParameters parameters, string exceptionMessage)
        {
            var         sut = new Netatmo.EnergyClient("https://api.netatmo.com/", credentialManagerMock.Object);
            Func <Task> act = async() => { await sut.GetRoomMeasure <TemperatureStep>(parameters); };

            act
            .Should().Throw <ArgumentException>()
            .WithMessage(exceptionMessage);
        }