public void Read_WhenInvalidJson_Throws() { var filePath = "ReadsOneParameter.txt"; var content = "{abc}"; CreateFile(filePath, content); try { var reader = new StackParameterReader(filePath); Assert.Throws<JsonReaderException>(() => reader.Read()); } finally { DeleteFile(filePath); } }
public void Read_WhenFileEmpty_ReturnsEmptyList() { var filePath = "ReadsOneParameter.txt"; var content = ""; CreateFile(filePath, content); try { var reader = new StackParameterReader(filePath); List<Parameter> parameters = reader.Read(); Assert.IsNotNull(parameters); Assert.AreEqual(0, parameters.Count); } finally { DeleteFile(filePath); } }
public void Read_WhenMultipmePatameters_ReturnsThemAll() { var filePath = "ReadsOneParameter.txt"; var content = @"{ ""key1"" : ""value1"", ""key2"" : ""value2"" }"; CreateFile(filePath, content); try { var reader = new StackParameterReader(filePath); List<Parameter> parameters = reader.Read(); Assert.AreEqual(2, parameters.Count); Assert.AreEqual("key1", parameters[0].ParameterKey); Assert.AreEqual("value1", parameters[0].ParameterValue); Assert.AreEqual("key2", parameters[1].ParameterKey); Assert.AreEqual("value2", parameters[1].ParameterValue); } finally { DeleteFile(filePath); } }