Ejemplo n.º 1
0
        public void ResponseParse_TemperatureSensor_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(TEMPERATURESENSOR_RESPONSE);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(2, responseFromString.Context.Properties.Count);
            // Property 1
            TestFunctionsV3.TestContextProperty(responseFromString.Context.Properties[0], PropertyNames.TEMPERATURE,
                                                Namespaces.ALEXA_TEMPERATURESENSOR, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null);
            Assert.Equal(typeof(Setpoint), responseFromString.Context.Properties[0].Value.GetType());
            Setpoint s = responseFromString.Context.Properties[0].Value as Setpoint;

            Assert.Equal(24.0, s.Value);
            Assert.Equal(Scale.CELSIUS, s.Scale);
            // Property 2
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[1], ConnectivityModes.OK, DateTime.Parse("2017-09-27T18:30:30.45Z"));
            //Event Check
            Assert.NotNull(responseFromString.Event);
            Assert.Equal(typeof(Event), responseFromString.Event.GetType());
            Event e = responseFromString.Event as Event;

            TestFunctionsV3.TestHeaderV3(e.Header, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4", Namespaces.ALEXA, HeaderNames.STATE_REPORT);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", e.Header.CorrelationToken);
            TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
            Assert.NotNull(e.Payload);
            Assert.Equal(typeof(Payload), responseFromString.GetPayloadType());
        }
Ejemplo n.º 2
0
        public void ResponseParse_ChangeReport_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(CHANGE_REPORT);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(2, responseFromString.Context.Properties.Count);
            // Property 1
            TestFunctionsV3.TestContextProperty(responseFromString.Context.Properties[0], PropertyNames.BRIGHTNESS, Namespaces.ALEXA_BRIGHTNESSCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null);
            Assert.Equal(typeof(System.Int32), responseFromString.Context.Properties[0].Value.GetType());
            Assert.Equal(85, responseFromString.Context.Properties[0].Value);
            // Property 2
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[1], ConnectivityModes.OK, DateTime.Parse("2017-09-27T18:30:30.45Z"));
            //Event Check
            Assert.NotNull(responseFromString.Event);
            Assert.Equal(typeof(Event), responseFromString.Event.GetType());
            Event e = responseFromString.Event as Event;

            TestFunctionsV3.TestHeaderV3(e.Header, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4", Namespaces.ALEXA, HeaderNames.CHANGE_REPORT);
            TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
            Assert.NotNull(e.Payload);
            Assert.Equal(typeof(ChangeReportPayload), e.Payload.GetType());
            ChangeReportPayload p = e.Payload as ChangeReportPayload;

            Assert.NotNull(p.Change);
            Assert.NotNull(p.Change.Cause);
            Assert.Equal(CauseTypes.PHYSICAL_INTERACTION, p.Change.Cause.Type);
            Assert.NotNull(p.Change.Properties);
            Assert.Equal(1, p.Change.Properties.Count);
            TestFunctionsV3.TestContextProperty(p.Change.Properties[0], PropertyNames.POWER_STATE, Namespaces.ALEXA_POWERCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null);
            Assert.Equal(typeof(PowerStates), p.Change.Properties[0].Value.GetType());
            Assert.Equal(PowerStates.ON, p.Change.Properties[0].Value);
        }
Ejemplo n.º 3
0
        private void TestPropertySetpoint(Property p, string propertyName, string namespaceName, DateTime time, int uncertainty, string customname, double value, Scale scale)
        {
            TestFunctionsV3.TestContextProperty(p, propertyName, namespaceName, time, uncertainty, customname);
            Assert.Equal(typeof(Setpoint), p.Value.GetType());
            Setpoint s = p.Value as Setpoint;

            TestSetpoint(s, value, scale);
        }
Ejemplo n.º 4
0
        public void ResponseParse_Unlock_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(UNLOCK_RESPONSE);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(2, responseFromString.Context.Properties.Count);
            // Property 1
            TestFunctionsV3.TestContextProperty(responseFromString.Context.Properties[0], PropertyNames.LOCK_STATE, Namespaces.ALEXA_LOCKCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null);
            Assert.Equal(typeof(LockModes), responseFromString.Context.Properties[0].Value.GetType());
            Assert.Equal(LockModes.UNLOCKED, responseFromString.Context.Properties[0].Value);
            // Property 2
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[1], ConnectivityModes.OK, DateTime.Parse("2017-09-27T18:30:30.45Z"));
            //Event Check
            TestFunctionsV3.TestBasicEventWithEmptyPayload(responseFromString, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
                                                           "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", ScopeTypes.BearerToken,
                                                           "access-token-from-Amazon", "endpoint-001");
        }
Ejemplo n.º 5
0
        public void ResponseParse_SetColor_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(SET_COLOR_RESPONSE);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(2, responseFromString.Context.Properties.Count);
            // Property 1
            TestFunctionsV3.TestContextProperty(responseFromString.Context.Properties[0], PropertyNames.COLOR, Namespaces.ALEXA_COLORCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null);
            Assert.Equal(typeof(Color), responseFromString.Context.Properties[0].Value.GetType());
            Color color = responseFromString.Context.Properties[0].Value as Color;

            Assert.Equal(0.6524, color.Brightness);
            Assert.Equal(350.5, color.Hue);
            Assert.Equal(0.7138, color.Saturation);
            // Property 2
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[1], ConnectivityModes.OK, DateTime.Parse("2017-09-27T18:30:30.45Z"));
            //Event Check
            TestFunctionsV3.TestBasicEventWithEmptyPayload(responseFromString, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
                                                           "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", ScopeTypes.BearerToken,
                                                           "access-token-from-Amazon", "endpoint-001");
        }
        public void ResponseParse_CameraStream_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(CAMERA_STREAM_RESPONSE);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(1, responseFromString.Context.Properties.Count);
            // Property 1
            TestFunctionsV3.TestContextProperty(responseFromString.Context.Properties[0], PropertyNames.CONNECTIVITY, Namespaces.ALEXA_ENDPOINTHEALTH, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null);
            Assert.Equal(responseFromString.Context.Properties[0].Value.GetType(), typeof(ConnectivityPropertyValue));
            ConnectivityPropertyValue conn = responseFromString.Context.Properties[0].Value as ConnectivityPropertyValue;

            Assert.Equal(ConnectivityModes.OK, conn.Value);
            //Event Check
            Assert.NotNull(responseFromString.Event);
            Assert.Equal(typeof(Event), responseFromString.Event.GetType());
            //Header Check
            TestFunctionsV3.TestHeaderV3(responseFromString.Event.Header, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4", Namespaces.ALEXA_CAMERASTREAMCONTROLLER, HeaderNames.RESPONSE);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", responseFromString.Event.Header.CorrelationToken);
            //Endpoint Check
            Event e = responseFromString.Event as Event;

            TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
            //Payload Check
            Assert.Equal(typeof(ResponseCameraStreamsPayload), responseFromString.GetPayloadType());
            ResponseCameraStreamsPayload payload = responseFromString.Event.Payload as ResponseCameraStreamsPayload;

            Assert.NotNull(payload.CameraStreams);
            Assert.Equal(2, payload.CameraStreams.Count);
            TestResponseCameraStream(payload.CameraStreams[0], "rtsp://*****:*****@link.to.video:443/feed1.mp4",
                                     DateTime.Parse("2017-09-27T20:30:30.45Z"), 30, CameraProtocols.RTSP, 1920, 1080, CameraAuthorizationTypes.BASIC, VideoCodecs.H264, AudioCodecs.AAC);
            TestResponseCameraStream(payload.CameraStreams[1], "rtsp://*****:*****@link.to.video:443/feed2.mp4",
                                     DateTime.Parse("2017-09-27T20:30:30.45Z"), 60, CameraProtocols.RTSP, 1280, 720, CameraAuthorizationTypes.DIGEST, VideoCodecs.MPEG2, AudioCodecs.G711);
            Assert.Equal("https://*****:*****@link.to.image/image.jpg", payload.ImageURI);
        }
Ejemplo n.º 7
0
        public void ResponseParse_ChannelResponse_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(CHANNEL_RESPONSE);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(2, responseFromString.Context.Properties.Count);
            // Property 1
            TestFunctionsV3.TestContextProperty(responseFromString.Context.Properties[0], PropertyNames.CHANNEL, Namespaces.ALEXA_CHANNELCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null);
            Assert.Equal(typeof(Channel), responseFromString.Context.Properties[0].Value.GetType());
            Channel channel = responseFromString.Context.Properties[0].Value as Channel;

            Assert.Null(channel.Uri);
            Assert.Equal("callsign2", channel.AffiliateCallSign);
            Assert.Equal("callsign1", channel.CallSign);
            Assert.Equal("1234", channel.Number);
            // Property 2
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[1], ConnectivityModes.OK, DateTime.Parse("2017-09-27T18:30:30.45Z"));
            //Event Check
            TestFunctionsV3.TestBasicEventWithEmptyPayload(responseFromString, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
                                                           "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", ScopeTypes.BearerToken,
                                                           "access-token-from-Amazon", "endpoint-001");
        }
Ejemplo n.º 8
0
 private void TestPropertyThermostatMode(Property p, DateTime time, int uncertainty, string customname, ThermostatModes value)
 {
     TestFunctionsV3.TestContextProperty(p, PropertyNames.THERMOSTATMODE, Namespaces.ALEXA_THERMOSTATCONTROLLER, time, uncertainty, customname);
     Assert.Equal(typeof(ThermostatModes), p.Value.GetType());
     Assert.Equal(value, p.Value);
 }