예제 #1
0
        public static void GetSpecialStringArgDescTest()
        {
            var instance            = new CommonEvent();
            var changedPropertyList = new List <string>();

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

            instance.NumberArgDescList.PropertyChanged += (sender, args) =>
            {
                changedSpecialNumberArgDescPropertyList.Add(args.PropertyName);
            };
            var changedSpecialNumberArgDescPropertyCollection = new List <NotifyCollectionChangedEventArgs>();

            instance.NumberArgDescList.CollectionChanged += (sender, args) =>
            {
                changedSpecialNumberArgDescPropertyCollection.Add(args);
            };
            var changedSpecialStringArgDescPropertyList = new List <string>();

            instance.StringArgDescList.PropertyChanged += (sender, args) =>
            {
                changedSpecialStringArgDescPropertyList.Add(args.PropertyName);
            };
            var changedSpecialStringArgDescPropertyCollection = new List <NotifyCollectionChangedEventArgs>();

            instance.StringArgDescList.CollectionChanged += (sender, args) =>
            {
                changedSpecialStringArgDescPropertyCollection.Add(args);
            };

            var index = (CommonEventStringArgIndex)1;

            var errorOccured = false;

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

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

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