public static void SetDatabaseUseAdditionalItemsFlagTest(bool flag) { var instance = new CommonEventSpecialNumberArgDesc.InnerDescDatabase(); var changedPropertyList = new List <string>(); instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); }; var errorOccured = false; try { instance.SetDatabaseUseAdditionalItemsFlag(flag); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーが発生しないこと Assert.IsFalse(errorOccured); // 意図したとおりプロパティ変更通知が発火していること Assert.AreEqual(changedPropertyList.Count, 1); Assert.IsTrue(changedPropertyList[0] .Equals(nameof(CommonEventSpecialNumberArgDesc.InnerDescDatabase.DatabaseUseAdditionalItemsFlag))); }
public static void UpdateDatabaseSpecialCaseTest(bool isUseAddition, int caseNumber, string description, bool isError) { var instance = new CommonEventSpecialNumberArgDesc.InnerDescDatabase(); 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.UpdateDatabaseSpecialCase(caseNumber, description); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーフラグが一致すること Assert.AreEqual(errorOccured, isError); // 意図したとおりプロパティ変更通知が発火していること if (isError) { Assert.AreEqual(changedDescPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 0); } else { Assert.AreEqual(changedDescPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 1); Assert.IsTrue(changedSpecialArgCaseListPropertyList[0] .Equals(ListConstant.IndexerName)); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 1); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList[0].Action, NotifyCollectionChangedAction.Replace); } }
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); }
public static void GetSpecialCaseTest(bool flag, int answerLength) { var instance = new CommonEventSpecialNumberArgDesc.InnerDescDatabase(); instance.SetDatabaseUseAdditionalItemsFlag(flag); 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.GetAllSpecialCase(); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーが発生しないこと Assert.IsFalse(errorOccured); // 取得した配列数が意図した値と一致すること var argCaseLength = instance.GetAllSpecialCase().Count; Assert.AreEqual(argCaseLength, answerLength); // プロパティ変更通知が発火していないこと Assert.AreEqual(changedDescPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 0); }
public static void GetAllSpecialCaseDescriptionTest(bool isUseAddition, string strMinus1, string strMinus2, string strMinus3, int resultLength) { var instance = new CommonEventSpecialNumberArgDesc.InnerDescDatabase(); instance.SetDatabaseUseAdditionalItemsFlag(isUseAddition); if (strMinus1 != null) { instance.UpdateDatabaseSpecialCase(-1, strMinus1); } if (strMinus2 != null) { instance.UpdateDatabaseSpecialCase(-2, strMinus2); } if (strMinus3 != null) { instance.UpdateDatabaseSpecialCase(-3, strMinus3); } 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.GetAllSpecialCaseDescription(); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーが発生しないこと Assert.IsFalse(errorOccured); // 意図した値が取得できること var caseDescList = instance.GetAllSpecialCaseDescription(); var caseDescListCount = caseDescList.Count; Assert.AreEqual(caseDescListCount, resultLength); if (caseDescListCount == 3) { Assert.AreEqual(caseDescList[0], strMinus1 ?? string.Empty); Assert.AreEqual(caseDescList[1], strMinus2 ?? string.Empty); Assert.AreEqual(caseDescList[2], strMinus3 ?? string.Empty); } // プロパティ変更通知が発火していないこと Assert.AreEqual(changedDescPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 0); }