コード例 #1
0
            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));
                }
            }
コード例 #2
0
            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));
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            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));
            }
コード例 #5
0
            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");
            }
コード例 #6
0
            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));
            }
コード例 #7
0
            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");
            }
コード例 #8
0
            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));
                }
            }
コード例 #9
0
            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);
            }
コード例 #10
0
            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));
            }