public void Should_Throw_For_Unsupported_Conversion() { var settingsMerger = new SettingsMerger(new Mock <ILogger>().Object); var settingsElement = XElement.Parse($"<Root><PropertyType/></Root>"); var unsupported = typeof(PropertyInfo).GetProperty(nameof(PropertyInfo.PropertyType)); var expectedMessage = $"Cannot handle 'PropertyType' yet"; Assert.Throws <Exception>(() => settingsMerger.GetValueFromXml(settingsElement, unsupported), expectedMessage); }
public void Should_Convert_Xml_Value_Correctly(string propertyElement, string propertyName, object expectedConversion, bool expectedException) { var settingsMerger = new SettingsMerger(new Mock <ILogger>().Object); var settingsElement = XElement.Parse($"<Root>{propertyElement}</Root>"); var property = typeof(IAppOptions).GetPublicProperties().First(p => p.Name == propertyName); var value = settingsMerger.GetValueFromXml(settingsElement, property); Assert.AreEqual(expectedConversion, value); }