public async Task GivenAJsonStringWithAPromptWithAWhenArray_WhenGetPromptsFromFileIsCalled_ThenTheResultPromptWillHaveTheGivenWhenArray(object value, string jsonValue) { //arrange var expectedWhen = new PromptWhen { Id = "question", Is = value }; var expectedPrompt = new TemplatePrompt { Id = "BooleanPromptId", Message = "Boolean Prompt Message", DefaultValue = false, When = new List <PromptWhen> { expectedWhen } }; var jsonString = @" [ { ""promptType"": ""Boolean"", ""id"": ""BooleanPromptId"", ""message"": ""Boolean Prompt Message"", ""when"": [{ ""id"": ""question"", ""is"": " + jsonValue + @" }] } ]"; await File.WriteAllTextAsync(TempFile, jsonString).ConfigureAwait(false); //act var result = await PromptReader.GetPromptsFromFile(TempPath).ConfigureAwait(false); //assert Assert.Single(result); var actualPrompt = result.First(); Assert.Equal(expectedPrompt.When.Count, actualPrompt.When.Count); var actualWhen = actualPrompt.When[0]; Assert.Equal(expectedWhen.Id, actualWhen.Id); Assert.Equal(expectedWhen.Is, actualWhen.Is); }
public void GivenAJsonStringWithAPromptWithAWhenArray_WhenGetPromptsFromStringIsCalled_ThenTheResultPromptWillHaveTheGivenWhenArray() { //arrange var expectedWhen = new PromptWhen { Id = "question", Is = "123" }; var expectedPrompt = new TemplatePrompt { Id = "BooleanPromptId", Message = "Boolean Prompt Message", DefaultValue = false, When = new List <PromptWhen> { expectedWhen } }; const string jsonString = @" [ { ""promptType"": ""Boolean"", ""id"": ""BooleanPromptId"", ""message"": ""Boolean Prompt Message"", ""when"": [{ ""id"": ""question"", ""is"": ""123"" }] } ]"; //act var result = PromptReader.GetPromptsFromString(jsonString); //assert Assert.Single(result); var actualPrompt = result.First(); Assert.Equal(expectedPrompt.When.Count, actualPrompt.When.Count); var actualWhen = actualPrompt.When[0]; Assert.Equal(expectedWhen.Id, actualWhen.Id); Assert.Equal(expectedWhen.Is, actualWhen.Is); }