コード例 #1
0
        public void TestNullNotChanged()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithNullNotChangedAttributeProperties setting = new SettingWithNullNotChangedAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);

                OraCommand command = new OraCommand("delete from test_setting");
                command.CommandType = System.Data.CommandType.Text;
                using (DbTransaction tr = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    tr.Success = true;
                }

                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.String1Property == "str", "String1Property is changed");
                Debug.Assert(setting.PointProperty == new Point(11, 22), "PointProperty is changed");
                Debug.Assert(SettingListProperties.CompareLists <string>(setting.StringListProperty, new List <string>()
                {
                    "1", "2"
                }), "StringListProperty is changed");
            }
        }
コード例 #2
0
        public void TestNullToEmptyAttribute()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithNullToEmptyAttributeProperties setting = new SettingWithNullToEmptyAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);

                OraCommand command = new OraCommand("delete from test_setting");
                command.CommandType = System.Data.CommandType.Text;
                using (DbTransaction tr = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    tr.Success = true;
                }

                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.String1Property != null, "Null string property");
                Debug.Assert(setting.PointProperty == Point.Empty, "Not empty Point property");
                Debug.Assert(setting.StringListProperty != null, "String list property is null");
                Debug.Assert(setting.BlobProperty != null, "Blob list property is null");
                Debug.Assert(setting.FontProperty != null, "Font list property is null");
            }
        }
コード例 #3
0
        public void TesIgnoreAttribute()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithIgnoreAttributeProperties setting = new SettingWithIgnoreAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);
                setting.PointProperty      = new Point(33, 44);
                setting.String1Property    = "after";
                setting.StringListProperty = new List <string>()
                {
                    "22", "33"
                };
                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.String1Property == "after", "String1Property not ignored");
                Debug.Assert(setting.PointProperty == new Point(33, 44), "PointProperty not ignored");
                Debug.Assert(SettingListProperties.CompareLists <string>(setting.StringListProperty, new List <string>()
                {
                    "22", "33"
                }), "StringListProperty not ignored");
            }
        }
コード例 #4
0
        public void TestNullToDefault()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithNullToDefaultAttributeProperties setting = new SettingWithNullToDefaultAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);

                OraCommand command = new OraCommand("delete from test_setting");
                command.CommandType = System.Data.CommandType.Text;
                using (DbTransaction tr = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    tr.Success = true;
                }

                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.BoolProperty == false, "BoolProperty not equal to default");
                Debug.Assert(setting.String1Property == "default", "String1Property not equal to default");
                Debug.Assert(setting.PointProperty == new Point(55, 77), "PointProperty not equal to default");
                Debug.Assert(setting.SizeProperty == new Size(88, 99), "SizeProperty not equal to default");
                Debug.Assert(setting.DateTimeProperty == new DateTime(1111, 11, 11, 11, 11, 11), "DateTime not equal to default");
                Debug.Assert(setting.DateTime2Property == new DateTime(1111, 11, 11, 11, 11, 11), "DateTime2 not equal to default");
                Debug.Assert(setting.DateTime3Property == null, "DateTime3 not equal to default");
                Debug.Assert(SettingBlobProperties.CompareBlobs(setting.BlobProperty, new byte[] { 1, 2, 3, 4 }), "BlobProperty not equal to default");
                Debug.Assert(SettingListProperties.CompareLists <string>(setting.StringListProperty, new List <string>()
                {
                    "1", "2", "3", "4"
                }), "StringListProperty not equal to default");

                /*Debug.Assert(SettingListProperties.CompareLists<Font>(setting.FontListProperty, new List<Font>() {new Font("Arial", 10, FontStyle.Bold),
                 *                                                                                                new Font("Arial", 10, FontStyle.Bold),
                 *                                                                                                new Font("Arial", 10, FontStyle.Bold)}), "FontListProperty not equal to default");
                 * Debug.Assert(Font.Equals(setting.FontProperty, new Font("Arial", 10, FontStyle.Bold)), "FontProperty not equal to default");*/
                Debug.Assert(setting.TestEnumProperty == TestEnum.Unknown, "TestEnumProperty not equal to default");
                Debug.Assert(setting.TestEnumFlagProperty == (TestEnumFlag.First | TestEnumFlag.Second), "TestEnumFlagProperty not equal to default");
            }
        }
コード例 #5
0
        public void TestSaveLoadListProperty()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingListProperties setting = new SettingListProperties();
                setting.Init();
                SettingListProperties setting2 = new SettingListProperties();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);
                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting2);

                Debug.Assert(setting.Equals(setting2), "2. Saved and loaded settings are not equal (List types).");
            }
        }