public void DoesNotThrowForUnexpectedResponse() { var options = new StuntmanOptions(stuntmanOptionsRetriever: new TestStuntmanOptionsRetriever( webClientStringToReturn: "some_error")); options.TryAddConfigurationFromServer("https://example.com"); }
public void InvokesonExceptionWhenExceptionThrown() { var options = new StuntmanOptions(stuntmanOptionsRetriever: new TestStuntmanOptionsRetriever( webClientStringToReturn: "error")); Exception actualException = null; options.TryAddConfigurationFromServer( "https://example.com", (ex) => { actualException = ex; }); Assert.NotNull(actualException); Assert.Equal( "Unexpected character encountered while parsing value: " + "e. Path '', line 0, position 0.", actualException.Message); }
public void SetsSourceToserverBaseUrl() { const string ServerBaseUrl = "https://example.com"; var stuntmanServerResponse = new StuntmanServerResponse { Users = new[] { new StuntmanUser("user-1", "User 1") } }; var json = JsonConvert.SerializeObject(stuntmanServerResponse); var options = new StuntmanOptions(stuntmanOptionsRetriever: new TestStuntmanOptionsRetriever( webClientStringToReturn: json)); options.TryAddConfigurationFromServer(ServerBaseUrl); Assert.Equal(ServerBaseUrl, options.Users.Single().Source); }
public void ProcessesStuntmanServerResponse() { const string Id1 = "user-1"; var stuntmanServerResponse = new StuntmanServerResponse { Users = new[] { new StuntmanUser(Id1, "User 1") } }; var json = JsonConvert.SerializeObject(stuntmanServerResponse); var options = new StuntmanOptions(stuntmanOptionsRetriever: new TestStuntmanOptionsRetriever( webClientStringToReturn: json)); options.TryAddConfigurationFromServer("https://example.com"); Assert.Equal(Id1, options.Users.Single().Id); }