示例#1
0
        public void fetch_a_simple_object()
        {
            // This data is pulled from the FubuMVC.Tests.dll.config file
            var settings = provider.SettingsFor <FakeSettings>();

            settings.Name.ShouldEqual("Max");
            settings.Age.ShouldEqual(6);
            settings.Active.ShouldBeTrue();
        }
        public void should_bind_settings_for_simple_setting()
        {
            var appSettingsProvider = new AppSettingsProvider();
            var fakeSettingResult = appSettingsProvider.SettingsFor<FakeSettings>();

            fakeSettingResult.Name.ShouldEqual("Cedric");
            fakeSettingResult.Age.ShouldEqual(21);
            fakeSettingResult.Active.ShouldBeTrue();
            fakeSettingResult.DateOfBirth.ShouldEqual(new DateTime(1978,2, 10));
            fakeSettingResult.DefaultString.ShouldEqual("defaultString");
        }
示例#3
0
        public void should_bind_settings_for_simple_setting()
        {
            var appSettingsProvider = new AppSettingsProvider();
            var fakeSettingResult = appSettingsProvider.SettingsFor<FakeSettings>();

            fakeSettingResult.Name.ShouldEqual("Cedric");
            fakeSettingResult.Age.ShouldEqual(21);
            fakeSettingResult.Active.ShouldBeTrue();
            fakeSettingResult.DateOfBirth.ShouldEqual(new DateTime(1978,2, 10));
            fakeSettingResult.DefaultString.ShouldEqual("defaultString");
        }
示例#4
0
        private static object buildDefault(Type type)
        {
            if (type.IsValueType)
            {
                return(typeof(DefaultMaker <>).CloseAndBuildAs <IDefaultMaker>(type).Default());
            }

            if (type.IsConcreteWithDefaultCtor())
            {
                var provider = new AppSettingsProvider(ObjectResolver.Basic());
                return(provider.SettingsFor(type));
            }

            throw new ArgumentOutOfRangeException("Can only build default values for concrete classes with a default constructor and value types");
        }