public void Should_return_setting_with_specified_type_and_setting_name(Type settingType, string settingName) { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = "CommonProvider.Data.PipeDelimitedDataParser, CommonProvider"; var settingsAsDictionary = new Dictionary <string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); if (settingType == typeof(string)) { Assert.That(settings.Get <string>(settingName), Is.EqualTo(website)); } else { var user = settings.Get <User>(settingName); Assert.That(user.Id, Is.EqualTo(userId)); Assert.That(user.Name, Is.EqualTo(userFullname)); } }
public void Should_not_throw_exception_when_data_parser_type_not_specified() { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = ""; var settingsAsDictionary = new Dictionary<string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); Assert.That(settings.Get<string>("website"), Is.EqualTo(website)); }
public void Should_return_default_generic_type_when_setting_name_is_null_or_empty_or_doesnt_exist(string settingName) { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = "CommonProvider.Data.PipeDelimitedDataParser, CommonProvider"; var settingsAsDictionary = new Dictionary <string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); settings.Get <string>(settingName); }
public void Should_not_throw_exception_when_data_parser_type_not_specified() { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = ""; var settingsAsDictionary = new Dictionary <string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); Assert.That(settings.Get <string>("website"), Is.EqualTo(website)); }
public void Should_throw_exception_if_generic_type_is_interface() { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = "CommonProvider.Data.PipeDelimitedDataParser, CommonProvider"; var settingsAsDictionary = new Dictionary <string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); var user = settings.Get <IUser>("user"); }
public void Should_for_complex_types_use_default_parser_which_is_the_pipe_data_parser_when_data_parser_not_specified() { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = ""; var settingsAsDictionary = new Dictionary <string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); var user = settings.Get <User>("user"); Assert.That(user.Id, Is.EqualTo(userId)); Assert.That(user.Name, Is.EqualTo(userFullname)); }
public void Should_throw_exception_if_generic_type_is_interface() { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = "CommonProvider.Data.PipeDelimitedDataParser, CommonProvider"; var settingsAsDictionary = new Dictionary<string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); var user = settings.Get<IUser>("user"); }
public void Should_return_setting_with_specified_type_and_setting_name(Type settingType, string settingName) { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = "CommonProvider.Data.PipeDelimitedDataParser, CommonProvider"; var settingsAsDictionary = new Dictionary<string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); if (settingType == typeof(string)) { Assert.That(settings.Get<string>(settingName), Is.EqualTo(website)); } else { var user = settings.Get<User>(settingName); Assert.That(user.Id, Is.EqualTo(userId)); Assert.That(user.Name, Is.EqualTo(userFullname)); } }
public void Should_return_default_generic_type_when_setting_name_is_null_or_empty_or_doesnt_exist(string settingName) { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = "CommonProvider.Data.PipeDelimitedDataParser, CommonProvider"; var settingsAsDictionary = new Dictionary<string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); settings.Get<string>(settingName); }
public void Should_for_complex_types_use_default_parser_which_is_the_pipe_data_parser_when_data_parser_not_specified() { string website = "http://www.johndoe.com"; int userId = 1; string userFullname = "John Doe"; string dataParserType = ""; var settingsAsDictionary = new Dictionary<string, string>(); settingsAsDictionary.Add("website", website); settingsAsDictionary.Add("user", string.Format("id:{0}|name:{1}", userId, userFullname)); var settings = new ProviderSettings(settingsAsDictionary, dataParserType); var user = settings.Get<User>("user"); Assert.That(user.Id, Is.EqualTo(userId)); Assert.That(user.Name, Is.EqualTo(userFullname)); }