Exemplo n.º 1
0
        public static void SetCommonEventListTest(int commonEventLength, bool isError)
        {
            var instance            = new CommonFileData();
            var changedPropertyList = new List <string>();

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

            var errorOccured = false;

            try
            {
                instance.SetCommonEventList(MakeCommonEventList(commonEventLength));
            }
            catch (Exception ex)
            {
                logger.Exception(ex);
                errorOccured = true;
            }

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

            // 意図したとおりプロパティ変更通知が発火していること
            if (isError)
            {
                Assert.AreEqual(changedPropertyList.Count, 0);
            }
            else
            {
                Assert.AreEqual(changedPropertyList.Count, 1);
                Assert.IsTrue(changedPropertyList[0].Equals(nameof(CommonFileData.CommonEventList)));
            }
        }
Exemplo n.º 2
0
        public static void GetAllCommonEventTest(int commonEventLength)
        {
            var instance = new CommonFileData();

            instance.SetCommonEventList(MakeCommonEventList(commonEventLength));
            var changedPropertyList = new List <string>();

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

            var errorOccured = false;

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

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

            // 取得件数が意図した値と一致すること
            var eventsLength = instance.GetAllCommonEvent().Count();

            Assert.AreEqual(eventsLength, commonEventLength);

            // プロパティ変更通知が発火していないこと
            Assert.AreEqual(changedPropertyList.Count, 0);
        }
        /** ========================================
         *  マップデータオブジェクト作成
         *  ======================================== */

        public static CommonFileData GenerateCommon000Data()
        {
            var commonEventList = new List <CommonEvent>
            {
                CommonEventDataFileTestItemGenerator.CommonEvent00Data.GenerateCommonEvent000(),
            };

            var result = new CommonFileData();

            result.SetCommonEventList(commonEventList);

            return(result);
        }
Exemplo n.º 4
0
        public static void SerializeTest()
        {
            var target = new CommonFileData();

            target.SetCommonEventList(MakeCommonEventList(1));
            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);
        }