예제 #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());
        }
예제 #2
0
        public void ResponseParse_SetTemperatureTripleMode_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(SET_T_TEMPERATURE_TRIPLEMODE_RESPONSE);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(5, responseFromString.Context.Properties.Count);
            // Property 1
            TestPropertySetpoint(responseFromString.Context.Properties[0], PropertyNames.LOWER_SETPOINT,
                                 Namespaces.ALEXA_THERMOSTATCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null, 68.0, Scale.FAHRENHEIT);
            // Property 2
            TestPropertySetpoint(responseFromString.Context.Properties[1], PropertyNames.TARGET_SETPOINT,
                                 Namespaces.ALEXA_THERMOSTATCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null, 72.0, Scale.FAHRENHEIT);
            // Property 3
            TestPropertySetpoint(responseFromString.Context.Properties[2], PropertyNames.UPPER_SETPOINT,
                                 Namespaces.ALEXA_THERMOSTATCONTROLLER, DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null, 76.0, Scale.FAHRENHEIT);
            // Property 4
            TestPropertyThermostatMode(responseFromString.Context.Properties[3], DateTime.Parse("2017-09-27T18:30:30.45Z"), 200, null, ThermostatModes.AUTO);
            // Property 5
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[4], 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");
        }
예제 #3
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);
        }
예제 #4
0
        public void ResponseParse_ActivationStarted_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(ACTIVATION_STARTED);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(1, responseFromString.Context.Properties.Count);
            // Property 1
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[0], 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_SCENECONTROLLER, HeaderNames.ACTIVATION_STARTED);
            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(SceneStartedResponsePayload), responseFromString.GetPayloadType());
            SceneStartedResponsePayload p = e.Payload as SceneStartedResponsePayload;

            Assert.NotNull(p.Cause);
            Assert.Equal(CauseTypes.VOICE_INTERACTION, p.Cause.Type);
            Assert.Equal(DateTime.Parse("2017-09-27T18:30:30.45Z").ToUniversalTime(), p.Timestamp);
        }
        public void ResponseParse_PlaybackResponse_Test()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(PLAYBACK_RESPONSE);

            //Context check
            Assert.NotNull(responseFromString.Context);
            Assert.NotNull(responseFromString.Context.Properties);
            Assert.Equal(1, responseFromString.Context.Properties.Count);
            // Property 2
            TestFunctionsV3.TestBasicHealthCheckProperty(responseFromString.Context.Properties[0], 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");
        }
예제 #6
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");
        }
예제 #7
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");
        }
예제 #8
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");
        }