Example #1
0
        public static void GetAllSpecialCaseNumberTest(DBKind dbKind, int dbTypeId, bool isUseAddition,
                                                       int answerCaseNumberLength, int answerDbTypeCode, int answerUseAdditionValue)
        {
            var instance = new CommonEventSpecialNumberArgDesc.InnerDescDatabase();

            instance.SetDatabaseRefer(dbKind, dbTypeId);
            instance.SetDatabaseUseAdditionalItemsFlag(isUseAddition);
            var changedDescPropertyList = new List <string>();

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

            instance.SpecialArgCaseList.PropertyChanged += (sender, args) =>
            {
                changedSpecialArgCaseListPropertyList.Add(args.PropertyName);
            };
            var changedSpecialArgCaseListCollectionArgList = new List <NotifyCollectionChangedEventArgs>();

            instance.SpecialArgCaseList.CollectionChanged += (sender, args) =>
            {
                changedSpecialArgCaseListCollectionArgList.Add(args);
            };

            var errorOccured = false;

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

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

            // 意図した値が取得できること
            var caseNumberList = instance.GetAllSpecialCaseNumber();

            Assert.AreEqual(caseNumberList.Count, answerCaseNumberLength);

            Assert.AreEqual(caseNumberList[0], answerDbTypeCode);
            Assert.AreEqual(caseNumberList[1], dbTypeId);
            Assert.AreEqual(caseNumberList[2], answerUseAdditionValue);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedDescPropertyList.Count, 0);
            Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 0);
            Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 0);
        }
Example #2
0
        public static void SerializeTest()
        {
            var target = new CommonEventSpecialNumberArgDesc.InnerDescDatabase();

            target.SetDatabaseRefer(DBKind.System, 20);
            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);
        }
Example #3
0
        public static void SetDatabaseReferTest(DBKind dbKind, int dbTypeId, bool isError)
        {
            var typeId = (TypeId)dbTypeId;

            var instance            = new CommonEventSpecialNumberArgDesc.InnerDescDatabase();
            var changedPropertyList = new List <string>();

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

            var errorOccured = false;

            try
            {
                instance.SetDatabaseRefer(dbKind, typeId);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

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

            // 意図したとおりプロパティ変更通知が発火していること
            if (isError)
            {
                Assert.AreEqual(changedPropertyList.Count, 0);
            }
            else
            {
                Assert.AreEqual(changedPropertyList.Count, 2);
                Assert.IsTrue(changedPropertyList[0]
                              .Equals(nameof(CommonEventSpecialNumberArgDesc.InnerDescDatabase.DatabaseUseDbKind)));
                Assert.IsTrue(changedPropertyList[1]
                              .Equals(nameof(CommonEventSpecialNumberArgDesc.InnerDescDatabase.DatabaseDbTypeId)));
            }
        }