[TestCase(2100000, false)] // SpareNumberVariableAddress
        public static void LeftSideTest(int leftSide, bool isError)
        {
            var instance            = new CommonEventBootCondition();
            var changedPropertyList = new List <string>();

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

            var errorOccured = false;

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

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

            if (!errorOccured)
            {
                var getValue = instance.LeftSide;

                // セットした値と取得した値が一致すること
                Assert.IsTrue(getValue == leftSide);
            }

            // 意図したとおりプロパティ変更通知が発火していること
            Assert.AreEqual(changedPropertyList.Count, 1);
            Assert.IsTrue(changedPropertyList[0].Equals(nameof(CommonEventBootCondition.LeftSide)));
        }
        public static void RightSideTest()
        {
            var instance            = new CommonEventBootCondition();
            var changedPropertyList = new List <string>();

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

            var rightSide = (ConditionRight)100;

            var errorOccured = false;

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

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

            var getValue = instance.RightSide;

            // セットした値と取得した値が一致すること
            Assert.IsTrue(getValue == rightSide);

            // 意図したとおりプロパティ変更通知が発火していること
            Assert.AreEqual(changedPropertyList.Count, 1);
            Assert.IsTrue(changedPropertyList[0].Equals(nameof(CommonEventBootCondition.RightSide)));
        }
        /// <summary>
        /// 起動条件比較演算子 &amp; 起動条件
        /// </summary>
        /// <param name="readStatus">読み込み経過状態</param>
        /// <param name="condition">結果格納インスタンス</param>
        private void ReadBootConditionOperationAndType(BinaryReadStatus readStatus,
                                                       CommonEventBootCondition condition)
        {
            var b = readStatus.ReadByte();

            readStatus.IncreaseByteOffset();
            condition.Operation           = CriteriaOperator.FromByte((byte)(b & 0xF0));
            condition.CommonEventBootType = CommonEventBootType.FromByte((byte)(b & 0x0F));
        }
        /// <summary>
        /// 起動条件右辺
        /// </summary>
        /// <param name="status">読み込み経過状態</param>
        /// <param name="condition">結果格納インスタンス</param>
        private void ReadBootConditionRightSide(FileReadStatus status,
                                                CommonEventBootCondition condition)
        {
            condition.RightSide = status.ReadInt();
            status.IncreaseIntOffset();

            Logger.Debug(FileIOMessage.SuccessRead(typeof(CommonEventReader),
                                                   "起動条件右辺", condition.RightSide));
        }
        /// <summary>
        /// 起動条件比較演算子 &amp; 起動条件
        /// </summary>
        /// <param name="status">読み込み経過状態</param>
        /// <param name="condition">結果格納インスタンス</param>
        private void ReadBootConditionOperationAndType(FileReadStatus status,
                                                       CommonEventBootCondition condition)
        {
            var b = status.ReadByte();

            status.IncreaseByteOffset();
            condition.Operation           = CriteriaOperator.FromByte((byte)(b & 0xF0));
            condition.CommonEventBootType = CommonEventBootType.FromByte((byte)(b & 0x0F));

            Logger.Debug(FileIOMessage.SuccessRead(typeof(CommonEventReader),
                                                   "起動条件比較演算子", condition.Operation));
            Logger.Debug(FileIOMessage.SuccessRead(typeof(CommonEventReader),
                                                   "起動条件", condition.CommonEventBootType));
        }
        public static void SerializeTest()
        {
            var target = new CommonEventBootCondition
            {
                RightSide = 100,
            };
            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);
        }
Exemple #7
0
        public static void EventBootConditionTest(CommonEventBootCondition bootCondition, bool isError)
        {
            var instance            = new CommonEvent();
            var changedPropertyList = new List <string>();

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

            var errorOccured = false;

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

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

            if (!errorOccured)
            {
                var condition = instance.BootCondition;

                // セットした値と取得した値が一致すること
                Assert.IsTrue(condition == bootCondition);
            }

            // 意図したとおりプロパティ変更通知が発火していること
            if (isError)
            {
                Assert.AreEqual(changedPropertyList.Count, 0);
            }
            else
            {
                Assert.AreEqual(changedPropertyList.Count, 1);
                Assert.IsTrue(changedPropertyList[0].Equals(nameof(CommonEvent.BootCondition)));
            }
        }
 /// <summary>
 /// 起動条件右辺
 /// </summary>
 /// <param name="readStatus">読み込み経過状態</param>
 /// <param name="condition">結果格納インスタンス</param>
 private void ReadBootConditionRightSide(BinaryReadStatus readStatus,
                                         CommonEventBootCondition condition)
 {
     condition.RightSide = readStatus.ReadInt();
     readStatus.IncreaseIntOffset();
 }