Beispiel #1
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);
        }
Beispiel #2
0
        public void TestRequestedSetpointErrorResponse()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(ERROR_RESPONSE_SETPOINTS_TOO_CLOSE);

            //Context check
            Assert.Null(responseFromString.Context);
            //Event Check
            Assert.Equal(typeof(Event), responseFromString.Event.GetType());
            Event e = responseFromString.Event as Event;

            TestFunctionsV3.TestHeaderV3(e.Header, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4", Namespaces.ALEXA_THERMOSTATCONTROLLER, HeaderNames.ERROR_RESPONSE);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", e.Header.CorrelationToken);
            //Endpoint
            TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
            //Payload
            Assert.Equal(typeof(RequestedSetpointsTooCloseErrorPayload), responseFromString.GetPayloadType());
            RequestedSetpointsTooCloseErrorPayload p = e.Payload as RequestedSetpointsTooCloseErrorPayload;

            Assert.Equal(ErrorTypes.REQUESTED_SETPOINTS_TOO_CLOSE, p.Type);
            Assert.Equal("The requested temperature results in setpoints too close", p.Message);
            Assert.NotNull(p.MinimumTemperatureDelta);
            Assert.Equal(2.0, p.MinimumTemperatureDelta.Value);
            Assert.Equal(Scale.CELSIUS, p.MinimumTemperatureDelta.Scale);
        }
Beispiel #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);
        }
 public void TestTempValueOORResponse()
 {
     SmartHomeResponse responseFromString = JsonConvert.DeserializeObject<SmartHomeResponse>(TEMPVALUE_OOR);
     //Context check
     Assert.Null(responseFromString.Context);
     //Event Check
     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.ERROR_RESPONSE);
     Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", e.Header.CorrelationToken);
     //Endpoint
     TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
     TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
     //Payload
     Assert.Equal(typeof(TemperatureOutOfRangeErrorPayload), responseFromString.GetPayloadType());
     TemperatureOutOfRangeErrorPayload p = e.Payload as TemperatureOutOfRangeErrorPayload;
     Assert.Equal(ErrorTypes.TEMPERATURE_VALUE_OUT_OF_RANGE, p.Type);
     Assert.Equal("The requested temperature of -15 is out of range", p.Message);
     Assert.NotNull(p.ValidRange);
     Assert.NotNull(p.ValidRange.MaximumValue);
     Assert.Equal(30.0, p.ValidRange.MaximumValue.Value);
     Assert.Equal(Scale.CELSIUS, p.ValidRange.MaximumValue.Scale);
     Assert.NotNull(p.ValidRange.MinimumValue);
     Assert.Equal(15.0, p.ValidRange.MinimumValue.Value);
     Assert.Equal(Scale.CELSIUS, p.ValidRange.MinimumValue.Scale);
 }
        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());
        }
Beispiel #6
0
        public void RequestCreation_ChangeChannel_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(CHANGE_CHANNEL);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_CHANNELCONTROLLER, HeaderNames.CHANGE_CHANNEL);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(ChangeChannelRequestPayload), requestFromString.GetPayloadType());
            ChangeChannelRequestPayload payload = (requestFromString.Directive.Payload as ChangeChannelRequestPayload);

            //Channel
            Assert.NotNull(payload.Channel);
            Assert.Equal("1234", payload.Channel.Number);
            Assert.Equal("KSTATION1", payload.Channel.CallSign);
            Assert.Equal("KSTATION2", payload.Channel.AffiliateCallSign);
            Assert.Equal("someUrl", payload.Channel.Uri);
            //ChannelMetaData
            Assert.NotNull(payload.ChannelMetaData);
            Assert.Equal("Alternate Channel Name", payload.ChannelMetaData.Name);
            Assert.Equal("urlToImage", payload.ChannelMetaData.Image);
        }
Beispiel #7
0
        public void BearerTokenDeserialization()
        {
            Scope scope = JsonConvert.DeserializeObject <Scope>(BEARERTOKEN);

            //Directive Check
            Assert.NotNull(scope);
            TestFunctionsV3.TestBearerTokenV3(scope, "access-token-from-Amazon");
        }
        public void RequestCreation_Unlock_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(UNLOCK_REQUEST);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_LOCKCONTROLLER, HeaderNames.UNLOCK);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(Payload), requestFromString.GetPayloadType());
        }
Beispiel #9
0
        public void RequestCreation_AdjustBrightness_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(ADJUST_BRIGHTNESS_REQUEST);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_BRIGHTNESSCONTROLLER, HeaderNames.ADJUST_BRIGHTNESS);
            Assert.Equal(requestFromString.Directive.Header.CorrelationToken, "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==");
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(AdjustBrightnessRequestPayload), requestFromString.GetPayloadType());
            Assert.Equal(-25, (requestFromString.Directive.Payload as AdjustBrightnessRequestPayload).BrightnessDelta);
        }
        public void RequestCreation_IncreaseColorTemperature_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(INCREASE_COLORTEMPERATURE);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_COLORTEMPERATURECONTROLLER, HeaderNames.INCREASE_COLORTEMPERATURE);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(Payload), requestFromString.GetPayloadType());
            Payload payload = (requestFromString.Directive.Payload as Payload);

            Assert.NotNull(payload);
        }
 public void TestGeneralErrorResponse()
 {
     SmartHomeResponse responseFromString = JsonConvert.DeserializeObject<SmartHomeResponse>(GENERAL_ERROR);
     //Context check
     Assert.Null(responseFromString.Context);
     //Event Check
     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.ERROR_RESPONSE);
     Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", e.Header.CorrelationToken);
     //Endpoint
     TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
     TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
     //Payload
     Assert.Equal(typeof(ErrorPayload), responseFromString.GetPayloadType());
     ErrorPayload p = e.Payload as ErrorPayload;
     Assert.Equal(ErrorTypes.ENDPOINT_UNREACHABLE, p.Type);
     Assert.Equal("Unable to reach endpoint-001 because it appears to be offline", p.Message);
 }
 public void TestEndpointLowPowerResponse()
 {
     SmartHomeResponse responseFromString = JsonConvert.DeserializeObject<SmartHomeResponse>(ENDPOINT_LOW_POWER);
     //Context check
     Assert.Null(responseFromString.Context);
     //Event Check
     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.ERROR_RESPONSE);
     Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", e.Header.CorrelationToken);
     //Endpoint
     TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
     TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
     //Payload
     Assert.Equal(typeof(EndpointLowPowerErrorPayload), responseFromString.GetPayloadType());
     EndpointLowPowerErrorPayload p = e.Payload as EndpointLowPowerErrorPayload;
     Assert.Equal(ErrorTypes.ENDPOINT_LOW_POWER, p.Type);
     Assert.Equal("The lock battery is low", p.Message);
     Assert.Equal(5, p.PercentageState);
 }
Beispiel #13
0
        public void RequestCreation_AdjustPercentage_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(ADJUST_PERCENTAGE);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_PERCENTAGECONTROLLER, HeaderNames.ADJUST_PERCENTAGE);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(AdjustPercentageRequestPayload), requestFromString.GetPayloadType());
            AdjustPercentageRequestPayload payload = (requestFromString.Directive.Payload as AdjustPercentageRequestPayload);

            //Channel
            Assert.NotNull(payload);
            Assert.Equal(-20, payload.PercentageDelta);
        }
Beispiel #14
0
        public void RequestCreation_AdjustTemperature_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(ADJUST_T_TEMPERATURE);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_THERMOSTATCONTROLLER, HeaderNames.ADJUSTTARGETTEMPERATURE);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(AdjustTargetTemperatureRequestPayload), requestFromString.GetPayloadType());
            AdjustTargetTemperatureRequestPayload payload = (requestFromString.Directive.Payload as AdjustTargetTemperatureRequestPayload);

            //Channel
            Assert.NotNull(payload);
            TestSetpoint(payload.TargetSetpointDelta, -2.0, Scale.FAHRENHEIT);
        }
        public void RequestCreation_SelectInput_Request_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(SELECT_INPUT_REQUEST);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_INPUTCONTROLLER, HeaderNames.SELECT_INPUT);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(SelectInputRequestPayload), requestFromString.GetPayloadType());
            SelectInputRequestPayload payload = (requestFromString.Directive.Payload as SelectInputRequestPayload);

            //Channel
            Assert.NotNull(payload);
            Assert.Equal("HDMI1", payload.Input);
        }
        public void RequestCreation_SetColor_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(SET_COLOR_REQUEST);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_COLORCONTROLLER, HeaderNames.SET_COLOR);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(SetColorRequestPayload), requestFromString.GetPayloadType());
            SetColorRequestPayload payload = (requestFromString.Directive.Payload as SetColorRequestPayload);

            Assert.NotNull(payload.Color);
            Assert.Equal(350.5, payload.Color.Hue);
            Assert.Equal(0.7138, payload.Color.Saturation);
            Assert.Equal(0.6524, payload.Color.Brightness);
        }
        public void RequestCreation_CameraStream_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(INIT_CAMERA_STREAMS_REQUEST);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_CAMERASTREAMCONTROLLER, HeaderNames.INIT_CAMERA_STREAMS);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(InitializeCameraRequestPayload), requestFromString.GetPayloadType());
            InitializeCameraRequestPayload payload = (requestFromString.Directive.Payload as InitializeCameraRequestPayload);

            Assert.NotNull(payload.CameraStreams);
            Assert.Equal(2, payload.CameraStreams.Count);
            TestRequestCameraStream(payload.CameraStreams[0], CameraProtocols.RTSP, 1920, 1080, CameraAuthorizationTypes.BEARER, VideoCodecs.H264, AudioCodecs.AAC);
            TestRequestCameraStream(payload.CameraStreams[1], CameraProtocols.RTSP, 1280, 720, CameraAuthorizationTypes.BEARER, VideoCodecs.MPEG2, AudioCodecs.G711);
        }
Beispiel #18
0
        public void TestGeneralErrorResponse()
        {
            SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(GENERAL_ERROR);

            //Context check
            Assert.Null(responseFromString.Context);
            //Event Check
            Assert.Equal(typeof(Event), responseFromString.Event.GetType());
            Event e = responseFromString.Event as Event;

            TestFunctionsV3.TestHeaderV3(e.Header, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4", Namespaces.ALEXA_THERMOSTATCONTROLLER, HeaderNames.ERROR_RESPONSE);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", e.Header.CorrelationToken);
            //Endpoint
            TestFunctionsV3.TestEndpointV3(e.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(e.Endpoint.Scope, "access-token-from-Amazon");
            //Payload
            Assert.Equal(typeof(ErrorPayload), responseFromString.GetPayloadType());
            ErrorPayload p = e.Payload as ErrorPayload;

            Assert.Equal(ErrorTypes.THERMOSTAT_IS_OFF, p.Type);
            Assert.Equal("The thermostat is off, cannot turn on due to safety reasons", p.Message);
        }
Beispiel #19
0
        public void RequestCreation_SetThermostatmode_Test()
        {
            SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(SET_THERMOSTATMODE_REQUEST);

            //Directive Check
            Assert.NotNull(requestFromString.Directive);
            //Header Check
            TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_THERMOSTATCONTROLLER,
                                         HeaderNames.SET_THERMOSTATMODE);
            Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken);
            //Endpoint Check
            TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "endpoint-001");
            TestFunctionsV3.TestBearerTokenV3(requestFromString.Directive.Endpoint.Scope, "access-token-from-skill");
            //Payload Check
            Assert.Equal(typeof(SetThermostadModeRequestPayload), requestFromString.GetPayloadType());
            SetThermostadModeRequestPayload payload = (requestFromString.Directive.Payload as SetThermostadModeRequestPayload);

            //Channel
            Assert.NotNull(payload);
            Assert.NotNull(payload.ThermostatMode);
            Assert.Equal(ThermostatModes.COOL, payload.ThermostatMode.Value);
            Assert.Null(payload.ThermostatMode.CustomName);
        }
        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);
        }