public void IncorrectFootStringIsNotTransformedIntoDomainObjects() { IFootConverter converter = new FootConverter(); FootValue retValue = (FootValue)converter.Convert("Stupid name that doesn't exist in the file"); Assert.IsFalse(retValue.Value.HasValue, $"Value should have been null because the supplied name doesn't exist."); retValue = (FootValue)converter.Convert(null); Assert.IsFalse(retValue.Value.HasValue, $"Value should have been null because null was supplied as the value to translate."); }
public void FootStringsAreCorrectlyTransformedIntoDomainObjects() { IFootConverter converter; foreach (var language in languages) { converter = (IFootConverter)Activator.CreateInstance(language.Value); string json = File.ReadAllText($@"{SettingsFolderPath}\{language.Key}\{SettingsFile}"); var definition = new { Language = default(string), Set = new[] { new { Name = default(string), DO = default(string) } } }; var deserializedJSON = JsonConvert.DeserializeAnonymousType(json, definition); foreach (var item in deserializedJSON.Set) { FootValue retValue = (FootValue)converter.Convert(item.Name); Assert.IsTrue(retValue.Value.HasValue, $"The Foot string \"{item.Name}\" didn't translate into a Foot type domain object."); } } }