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(); }; }
public Task <ICommandResponse> KeyDownAsync(CommandKeys key) { return(SendKeyDownAsync(key.ToRouteValue())); }
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(); }; }