public void JsonFileData_JsonFileNotExists() { var wrongPath = "./path/not_exists.json"; var expectedErrorMessage = $"Could not find the JSON file located at: {Directory.GetCurrentDirectory()}/{wrongPath}"; var currentMethod = typeof(JsonDataFileAttributeTests).GetMethods().First(m => m.Name == nameof(JsonFileData_JsonFileNotExists)); var test = new JsonFileDataAttribute(wrongPath); var exception = Assert.Throws <FileNotFoundException>(() => test.GetData(currentMethod)); Assert.Equal(expectedErrorMessage, exception.Message); }
public void UnusedFieldsAreIgnored() { var attribute = new JsonFileDataAttribute("TestData/UnusedFields.json"); var testData = attribute.GetData(methodInfo) .ToList(); testData.Should().NotBeEmpty(); foreach (var testDataLine in testData) { testDataLine.Should() .HaveCount(2, $"Method {nameof(SampleClass.DoSomething)} has exactly two parameters."); foreach (var parameter in testDataLine) { parameter.Should().NotBeNull(); } } }