Exemplo n.º 1
0
        public static void CanSetItemTypeTest(DBItemType type, bool isError, bool answer)
        {
            var instance            = new DBItemSettingDescNormal();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            bool result = false;

            var errorOccured = false;

            try
            {
                result = instance.CanSetItemType(type);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーフラグが一致すること
            Assert.AreEqual(errorOccured, isError);

            if (errorOccured)
            {
                // 結果が意図した値と一致すること
                Assert.AreEqual(result, answer);
            }

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
        public static void DatabaseDbTypeIdGetterTest()
        {
            var instance            = new DBItemSettingDescNormal();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            var errorOccured = false;

            try
            {
                var _ = instance.DatabaseDbTypeId;
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生すること
            Assert.IsTrue(errorOccured);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
Exemplo n.º 3
0
        public static void ClearSpecialCaseTest()
        {
            var instance            = new DBItemSettingDescNormal();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };
            var changedArgCaseList = new List <string>();

            instance.ArgCaseList.PropertyChanged += (sender, args) => { changedArgCaseList.Add(args.PropertyName); };
            var changedArgCaseCollection = new List <NotifyCollectionChangedEventArgs>();

            instance.ArgCaseList.CollectionChanged += (sender, args) => { changedArgCaseCollection.Add(args); };

            var errorOccured = false;

            try
            {
                instance.ClearSpecialCase();
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生すること
            Assert.IsTrue(errorOccured);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
            Assert.AreEqual(changedArgCaseList.Count, 0);
            Assert.AreEqual(changedArgCaseCollection.Count, 0);
        }
Exemplo n.º 4
0
        public static void Equals(string settingDescCode, bool answer)
        {
            var instance            = new DBItemSettingDescNormal();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            IDBItemSettingDesc desc = null;

            switch (settingDescCode)
            {
            case nameof(DBItemSettingDescLoadFile):
                desc = new DBItemSettingDescLoadFile();
                break;

            case nameof(DBItemSettingDescDatabase):
                desc = new DBItemSettingDescDatabase();
                break;

            case nameof(DBItemSettingDescManual):
                desc = new DBItemSettingDescManual();
                break;

            case null:
                break;

            default:
                desc = new DBItemSettingDescNormal();
                break;
            }

            bool result = false;

            var errorOccured = false;

            try
            {
                result = instance.Equals(desc);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生しないこと
            Assert.IsFalse(errorOccured);

            // 結果が意図した値と一致すること
            Assert.AreEqual(result, answer);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
Exemplo n.º 5
0
        public static void SettingTypeTest()
        {
            var instance            = new DBItemSettingDescNormal();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            // プロパティが意図した値と一致すること
            Assert.AreEqual(instance.SettingType, DBItemSpecialSettingType.Normal);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
Exemplo n.º 6
0
        public static void SerializeTest()
        {
            var target = new DBItemSettingDescNormal();
            var changedPropertyList = new List <string>();

            target.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            var clone = DeepCloner.DeepClone(target);

            Assert.IsTrue(clone.Equals(target));

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
Exemplo n.º 7
0
        public static void ConstructorTest()
        {
            DBItemSettingDescNormal instance = null;

            var errorOccured = false;

            try
            {
                instance = new DBItemSettingDescNormal();
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生しないこと
            Assert.IsFalse(errorOccured);

            // 選択肢が0であること
            Assert.AreEqual(instance.GetAllSpecialCase().Count, 0);
        }
Exemplo n.º 8
0
        public static void GetAllSpecialCaseDescriptionTest()
        {
            var instance            = new DBItemSettingDescNormal();
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };
            var changedArgCaseList = new List <string>();

            instance.ArgCaseList.PropertyChanged += (sender, args) => { changedArgCaseList.Add(args.PropertyName); };
            var changedArgCaseCollection = new List <NotifyCollectionChangedEventArgs>();

            instance.ArgCaseList.CollectionChanged += (sender, args) => { changedArgCaseCollection.Add(args); };

            List <DatabaseValueCaseDescription> result = null;

            var errorOccured = false;

            try
            {
                result = instance.GetAllSpecialCaseDescription();
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生しないこと
            Assert.IsFalse(errorOccured);

            // 取得した要素数が0であること
            Assert.AreEqual(result.Count, 0);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
            Assert.AreEqual(changedArgCaseList.Count, 0);
            Assert.AreEqual(changedArgCaseCollection.Count, 0);
        }
Exemplo n.º 9
0
        public static void Equals(string settingDescCode, bool answer)
        {
            var instance = new DBItemSettingDescDatabase
            {
                DatabaseReferKind = DBReferType.Changeable,
                DatabaseDbTypeId  = 3,
                DatabaseUseAdditionalItemsFlag = false,
            };
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            IDBItemSettingDesc desc = null;

            switch (settingDescCode)
            {
            case nameof(DBItemSettingDescNormal):
                desc = new DBItemSettingDescNormal();
                break;

            case nameof(DBItemSettingDescLoadFile):
                desc = new DBItemSettingDescLoadFile();
                break;

            case nameof(DBItemSettingDescManual):
                desc = new DBItemSettingDescManual();
                break;

            case null:
                break;

            default:
                var settings = settingDescCode.Split('_');
                var dbDesc   = new DBItemSettingDescDatabase();
                switch (settings[1])
                {
                case nameof(DBReferType.Changeable):
                    dbDesc.DatabaseReferKind = DBReferType.Changeable;
                    break;

                case nameof(DBReferType.User):
                    dbDesc.DatabaseReferKind = DBReferType.User;
                    break;

                case nameof(DBReferType.System):
                    dbDesc.DatabaseReferKind = DBReferType.System;
                    break;

                default:
                    Assert.Fail();
                    break;
                }

                dbDesc.DatabaseDbTypeId = int.Parse(settings[2]);
                dbDesc.DatabaseUseAdditionalItemsFlag = bool.Parse(settings[3]);
                desc = dbDesc;
                break;
            }

            bool result = false;

            var errorOccured = false;

            try
            {
                result = instance.Equals(desc);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生しないこと
            Assert.IsFalse(errorOccured);

            // 結果が意図した値と一致すること
            Assert.AreEqual(result, answer);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
Exemplo n.º 10
0
        public static void Equals(string settingDescCode, bool answer)
        {
            var instance = new DBItemSettingDescManual();

            instance.AddSpecialCase(new DatabaseValueCase(2, "sentence"));
            instance.AddSpecialCase(new DatabaseValueCase(4, "wolf"));
            var changedPropertyList = new List <string>();

            instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); };

            IDBItemSettingDesc desc = null;

            switch (settingDescCode)
            {
            case nameof(DBItemSettingDescNormal):
                desc = new DBItemSettingDescNormal();
                break;

            case nameof(DBItemSettingDescLoadFile):
                desc = new DBItemSettingDescLoadFile();
                break;

            case nameof(DBItemSettingDescDatabase):
                desc = new DBItemSettingDescDatabase();
                break;

            case null:
                break;

            default:
                var settings     = settingDescCode.Split('_');
                var maDesc       = new DBItemSettingDescManual();
                var argDescsCode = settings[1].Split(',');
                foreach (var argDescs in argDescsCode)
                {
                    var argDescSettings = argDescs.Split('-');
                    maDesc.AddSpecialCase(new DatabaseValueCase(int.Parse(argDescSettings[0]), argDescSettings[1]));
                }

                desc = maDesc;
                break;
            }

            bool result = false;

            var errorOccured = false;

            try
            {
                result = instance.Equals(desc);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

            // エラーが発生しないこと
            Assert.IsFalse(errorOccured);

            // 結果が意図した値と一致すること
            Assert.AreEqual(result, answer);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }