Esempio n. 1
0
        public static void InsertSpecialCaseTest()
        {
            var instance            = new DBItemSettingDescDatabase();
            var specialCase         = new DatabaseValueCase(0, "");
            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.InsertSpecialCase(0, specialCase);
            }
            catch (Exception)
            {
                errorOccured = true;
            }

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

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
            Assert.AreEqual(changedArgCaseList.Count, 0);
            Assert.AreEqual(changedArgCaseCollection.Count, 0);
        }
        public static void GetForCaseNumberTest(int caseNumber, int initLength, string resultDescription)
        {
            var initList = MakeInitList(initLength, false);
            var instance = new DatabaseValueCaseList(initList);

            DatabaseValueCase result = null;

            var errorOccured = false;

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

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

            // 取得した値が意図した値であること
            var resultCase = resultDescription == null
                ? null
                : new DatabaseValueCase(caseNumber, resultDescription);

            Assert.AreEqual(result, resultCase);
        }
Esempio n. 3
0
        public static void GetAllSpecialCaseTest(int initItemLength)
        {
            var initList = MakeInitList(initItemLength);

            var instance            = new DBItemSettingDescManual(initList);
            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); };

            IReadOnlyList <DatabaseValueCase> allCase = null;

            var errorOccured = false;

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

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

            // 取得した要素数が意図した値と一致すること
            var answerResultLength = initItemLength != -1
                ? initItemLength
                : 0;

            Assert.AreEqual(allCase.Count, answerResultLength);

            // 取得した要素がそれぞれ意図した値であること
            for (var i = 0; i < answerResultLength; i++)
            {
                var answerCaseValue = new DatabaseValueCase(i, i.ToString());
                Assert.AreEqual(allCase[i], answerCaseValue);
            }

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
            Assert.AreEqual(changedArgCaseList.Count, 0);
            Assert.AreEqual(changedArgCaseCollection.Count, 0);
        }
Esempio n. 4
0
        public static void InsertSpecialCaseTest()
        {
            var instance            = new DBItemSettingDescManual();
            var specialCase         = new DatabaseValueCase(0, "");
            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.InsertSpecialCase(0, specialCase);
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

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

            // 意図したとおりプロパティ変更通知が発火していること
            Assert.AreEqual(changedPropertyList.Count, 0);
            Assert.AreEqual(changedArgCaseList.Count, 2);
            Assert.IsTrue(changedArgCaseList[0].Equals(nameof(instance.ArgCaseList.Count)));
            Assert.IsTrue(changedArgCaseList[1].Equals(ListConstant.IndexerName));
            Assert.AreEqual(changedArgCaseCollection.Count, 1);
            Assert.IsTrue(changedArgCaseCollection[0].Action == NotifyCollectionChangedAction.Add);
        }