public void RequestCreation_Activate_Test() { SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(ACTIVATE); //Directive Check Assert.NotNull(requestFromString.Directive); //Header Check TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_SCENECONTROLLER, HeaderNames.ACTIVATE); 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()); }
public void RequestCreation_AdjustPowerLevel_Test() { SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(REPORT_STATE); //Directive Check Assert.NotNull(requestFromString.Directive); //Header Check TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4", Namespaces.ALEXA, HeaderNames.REPORT_STATE); Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", requestFromString.Directive.Header.CorrelationToken); //Endpoint Check TestFunctionsV3.TestEndpointV3(requestFromString.Directive.Endpoint, "appliance-001"); TestFunctionsV3.TestBearerTokenWithPartitionV3(requestFromString.Directive.Endpoint.Scope, "some-access-token", "Room101", "some-user-id"); //Payload Check Assert.NotNull(requestFromString.Directive.Payload); Assert.Equal(typeof(Payload), requestFromString.GetPayloadType()); }
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 ResponseParse_DefferedResponse_Test() { SmartHomeResponse responseFromString = JsonConvert.DeserializeObject <SmartHomeResponse>(DEFFERED); //Context check Assert.Null(responseFromString.Context); //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.DEFFERED_RESPONSE); Assert.Equal("dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==", e.Header.CorrelationToken); Assert.NotNull(e.Payload); Assert.Equal(typeof(DefferedResponsePayload), e.Payload.GetType()); DefferedResponsePayload p = e.Payload as DefferedResponsePayload; Assert.Equal(20, p.EstimatedDeferralInSeconds); }
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 RequestCreation_SetColorTemperature_Test() { SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(SET_COLORTEMPERATURE); //Directive Check Assert.NotNull(requestFromString.Directive); //Header Check TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_COLORTEMPERATURECONTROLLER, HeaderNames.SET_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(SetColorTemperatureRequestPayload), requestFromString.GetPayloadType()); SetColorTemperatureRequestPayload payload = (requestFromString.Directive.Payload as SetColorTemperatureRequestPayload); Assert.NotNull(payload); Assert.Equal(5000, payload.ColorTemperatureInKelvin); }
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); }
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_AdjustVolume_Test() { SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(ADJUST_VOLUME_REQUEST); //Directive Check Assert.NotNull(requestFromString.Directive); //Header Check TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_STEPSPEAKER, HeaderNames.ADJUST_VOLUME); 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(StepSpeakerAdjustVolumeRequestPayload), requestFromString.GetPayloadType()); StepSpeakerAdjustVolumeRequestPayload payload = (requestFromString.Directive.Payload as StepSpeakerAdjustVolumeRequestPayload); //Channel Assert.NotNull(payload); Assert.Equal(-20, payload.VolumeSteps); }
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_AdjustPowerLevel_Test() { SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(ADJUST_POWER_LEVEL); //Directive Check Assert.NotNull(requestFromString.Directive); //Header Check TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_POWERLEVELCONTROLLER, HeaderNames.ADJUST_POWER_LEVEL); 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(AdjustPowerLevelRequestPayload), requestFromString.GetPayloadType()); AdjustPowerLevelRequestPayload payload = (requestFromString.Directive.Payload as AdjustPowerLevelRequestPayload); //Channel Assert.NotNull(payload); Assert.Equal(3, payload.PowerLevelDelta); }
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); }
public void RequestCreation_Lock_Test() { SmartHomeRequest requestFromString = JsonConvert.DeserializeObject <SmartHomeRequest>(LOCK_REQUEST); //Directive Check Assert.NotNull(requestFromString.Directive); //Header Check TestFunctionsV3.TestHeaderV3(requestFromString.Directive.Header, "1bd5d003-31b9-476f-ad03-71d471922820", Namespaces.ALEXA_LOCKCONTROLLER, HeaderNames.LOCK); 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()); /* * Assert.True(requestFromString.GetPayloadType() == typeof(TurnOnOffRequestPayload)); * TurnOnOffRequestPayload payload = requestFromString.Payload as TurnOnOffRequestPayload; * TestFunctionsV3.TestRequestApplianceAndAccessToken(payload, "accessToken", "appId", null); */ }
public void TestValueOORResponse() { SmartHomeResponse responseFromString = JsonConvert.DeserializeObject<SmartHomeResponse>(VALUE_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(ValueOutRangeErrorPayload), responseFromString.GetPayloadType()); ValueOutRangeErrorPayload p = e.Payload as ValueOutRangeErrorPayload; Assert.Equal(ErrorTypes.VALUE_OUT_OF_RANGE, p.Type); Assert.Equal("The color temperature cannot be set to 500", p.Message); Assert.NotNull(p.ValidRange); Assert.Equal(1000, p.ValidRange.MinimumValue); Assert.Equal(10000, p.ValidRange.MaximumValue); }
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); }
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); }