internal AppIcon(int appId, string contentType, byte[] image, IRokuResponse rokuResponse) : this(rokuResponse) { this.AppId = appId; this.ContentType = contentType; this.Image = image; }
void SearchAsync_method() { ICommandResponse result = null; string keyword = "Attack of the Amazons"; RokuInfo info = null; IRokuResponse rokuResponse = null; context["when the device doesn't support search"] = () => { it["should throw InvalidOperationException"] = () => { info.IsSearchEnabled = false; var call = new Func <Task>(() => subject.SearchAsync(keyword)); call.ShouldThrow <InvalidOperationException>(); }; before = () => rokuResponse = TestHelper.BuildRokuResponse(); }; describe["when the request succeeds"] = () => { it["should indicate a success"] = () => { result.IsSuccess.Should().BeTrue(); }; before = () => rokuResponse = TestHelper.BuildRokuResponse(); }; describe["when the request fails"] = () => { it["should indicate a failure"] = () => { result.IsSuccess.Should().BeFalse(); }; before = () => rokuResponse = TestHelper.BuildRokuResponse(statusCode: HttpStatusCode.NotFound); }; before = () => { info = new RokuInfo { IsSearchEnabled = true }; InitializeMocks(); rokuRequest.Setup(m => m.GetResponseAsync(It.IsAny <string>(), "POST")) .ReturnsAsync(() => rokuResponse); }; actAsync = async() => { InitializeSubject(); subject.Info = info; result = await subject.SearchAsync(keyword); }; }
internal AppIcon(IRokuResponse rokuResponse) { IsSuccess = rokuResponse.StatusCode == HttpStatusCode.OK; StatusCode = rokuResponse.StatusCode; StatusDescription = rokuResponse.StatusDescription; }
internal CommandResponse(IRokuResponse rokuResponse) { IsSuccess = rokuResponse.StatusCode == HttpStatusCode.OK; StatusCode = rokuResponse.StatusCode; StatusDescription = rokuResponse.StatusDescription; }
void KeypressAsync_method() { ICommandResponse result = null; string resultUrl = null; Func <Task> subjectAction = null; IRokuResponse rokuResponse = null; describe["when the request succeeds"] = () => { it["should indicate a success"] = () => { result.IsSuccess.Should().BeTrue(); }; before = () => { rokuResponse = TestHelper.BuildRokuResponse(); subjectAction = async() => result = await subject.KeypressAsync('z'); }; describe["when a command key is sent"] = () => { CommandKeys commandKey = CommandKeys.Home; it["should convert the key sent to it's querystring equivelant"] = () => { resultUrl.Should().Contain(commandKey.ToRouteValue()); }; before = () => subjectAction = async() => result = await subject.KeypressAsync(commandKey); }; describe["when a character key is sent"] = () => { char charKey = '"'; it["should convert the key sent to it's querystring equivelant"] = () => { resultUrl.Should().Contain(charKey.ToRouteValue()); }; before = () => subjectAction = async() => result = await subject.KeypressAsync(charKey); }; }; describe["when the request fails"] = () => { it["should indicatate a failure"] = () => { result.IsSuccess.Should().BeFalse(); }; before = () => { rokuResponse = TestHelper.BuildRokuResponse(statusCode: HttpStatusCode.ServiceUnavailable); subjectAction = async() => result = await subject.KeypressAsync('z'); }; }; before = () => { InitializeMocks(); rokuRequest.Setup(m => m.GetResponseAsync(UrlUtils.KeyPressUrlFor(rokuUri, It.IsAny <string>()), "POST")) .ReturnsAsync((string url, string keyString) => { resultUrl = url; return(rokuResponse); }); }; actAsync = async() => { InitializeSubject(); await subjectAction(); }; }
void KeyUpAsync_method() { context["when a key-down command was not previously sent"] = () => { it["should throw an InvalidOperationException"] = () => { var call = new Func <Task>(() => subject.KeyUpAsync()); call.ShouldThrow <InvalidOperationException>(); }; before = () => subject._lastKeyPressed = null; }; context["when a key-down command has been previously set"] = () => { ICommandResponse result = null; IRokuResponse rokuResponse = null; describe["when the request succeeds"] = () => { it["should indicate a success"] = () => { result.IsSuccess.Should().BeTrue(); }; before = () => rokuResponse = TestHelper.BuildRokuResponse(); }; describe["when the request fails"] = () => { it["should indicate a failure"] = () => { result.IsSuccess.Should().BeFalse(); }; before = () => rokuResponse = TestHelper.BuildRokuResponse(statusCode: HttpStatusCode.UnsupportedMediaType); }; before = () => { rokuRequest.Setup(m => m.GetResponseAsync(UrlUtils.KeyUpUrlFor(rokuUri, CommandKeys.Backspace.ToRouteValue()), "POST")) .ReturnsAsync(() => rokuResponse); }; actAsync = async() => { subject._lastKeyPressed = CommandKeys.Backspace.ToRouteValue(); result = await subject.KeyUpAsync(); }; }; before = () => { InitializeMocks(); }; act = () => { InitializeSubject(); //result = await subject.KeyDownAsync(key); }; }
void KeyDownAsync_method() { ICommandResponse result = null; Func <Task> commandAction = null; IRokuResponse rokuResponse = null; describe["when the request succeeds"] = () => { string expectedLastKeyPressed = null; it["should indicate a success"] = () => { result.IsSuccess.Should().BeTrue(); }; it["should keep the last key sent"] = () => { subject._lastKeyPressed.Should().NotBeNull(); }; before = () => rokuResponse = TestHelper.BuildRokuResponse(); describe["when a command key is sent"] = () => { CommandKeys commandKey = CommandKeys.Home; it["should convert the key sent to it's querystring equivelant"] = () => { subject._lastKeyPressed.Should().Be(expectedLastKeyPressed); }; before = () => { expectedLastKeyPressed = commandKey.ToRouteValue(); commandAction = async() => result = await subject.KeyDownAsync(commandKey); }; }; describe["when a character key is sent"] = () => { char charKey = ' '; it["should convert the key sent to it's querystring equivelant"] = () => { subject._lastKeyPressed.Should().Be(charKey.ToRouteValue()); }; before = () => commandAction = async() => result = await subject.KeyDownAsync(charKey); }; }; describe["when the request fails"] = () => { it["should indicate a failure"] = () => { result.IsSuccess.Should().BeFalse(); }; before = () => rokuResponse = TestHelper.BuildRokuResponse(statusCode: HttpStatusCode.Forbidden); }; before = () => { commandAction = async() => result = await subject.KeyDownAsync('A'); InitializeMocks(); rokuRequest.Setup(m => m.GetResponseAsync(UrlUtils.KeyDownUrlFor(rokuUri, It.IsAny <string>()), "POST")) .ReturnsAsync(() => rokuResponse); }; actAsync = async() => { InitializeSubject(); await commandAction(); }; }