public void ThrowsForUnexpectedResponse() { var options = new StuntmanOptions(stuntmanOptionsRetriever: new TestStuntmanOptionsRetriever( webClientStringToReturn: "some_error")); Assert.Throws <JsonReaderException>( () => options.AddConfigurationFromServer("https://example.com")); }
private static void Main(string[] args) { var baseUrl = GetAppSetting("UsageSample:BaseUrl"); StuntmanOptions .AddConfigurationFromServer(baseUrl); Console.WriteLine("Users:"); Console.WriteLine(string.Join( Environment.NewLine, StuntmanOptions.Users.Select(x => $"- {x.Id}: {x.Name}"))); Console.ReadLine(); }
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.AddConfigurationFromServer(ServerBaseUrl); Assert.Equal(ServerBaseUrl, options.Users.Single().Source); }
public void AddsStuntmanServerResponseUsers() { 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.AddConfigurationFromServer("https://example.com"); Assert.Equal(Id1, options.Users.Single().Id); }
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.AddConfigurationFromServer(ServerBaseUrl); Assert.Equal(ServerBaseUrl, options.Users.Single().Source); }
public void AddsStuntmanServerResponseUsers() { 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.AddConfigurationFromServer("https://example.com"); Assert.Equal(Id1, options.Users.Single().Id); }
public void ThrowsForUnexpectedResponse() { var options = new StuntmanOptions(stuntmanOptionsRetriever: new TestStuntmanOptionsRetriever( webClientStringToReturn: "some_error")); Assert.Throws<JsonReaderException>( () => options.AddConfigurationFromServer("https://example.com")); }