Example #1
0
            public override bool Equals(object obj)
            {
                SettingBlobProperties setting = obj as SettingBlobProperties;

                if (setting == null)
                {
                    return(false);
                }

                return(CompareBlobs(Blob1Property, setting.Blob1Property) &&
                       CompareBlobs(Blob2Property, setting.Blob2Property) &&
                       CompareBlobs(Blob3Property, setting.Blob3Property));
            }
Example #2
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");
            }
        }
Example #3
0
        public void TestSaveLoadBlobProperty()
        {
            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);

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

                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 (blob types).");
            }
        }