public static void ConstructorTestB(int initLength, bool hasNullItem, bool isError) { var initItemList = MakeInitList(initLength, hasNullItem); CommonEventSpecialArgCaseList instance = null; var errorOccured = false; try { instance = new CommonEventSpecialArgCaseList(initItemList); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーフラグが一致すること Assert.AreEqual(errorOccured, isError); if (errorOccured) { return; } // 選択肢が意図した数であること var answerResultLength = initLength != -1 ? initLength : 0; Assert.AreEqual(instance.Count, answerResultLength); }
public static void CreateReferDatabaseTest(Dictionary <int, string> argCaseDic, bool isError) { CommonEventSpecialArgCaseList argCaseList; if (argCaseDic == null) { argCaseList = null; } else { var argCases = new List <CommonEventSpecialArgCase>(); foreach (var argCase in argCaseDic) { argCases.Add(new CommonEventSpecialArgCase(argCase.Key, argCase.Value)); } argCaseList = new CommonEventSpecialArgCaseList(argCases.ToArray()); } var errorOccured = false; try { CommonEventSpecialNumberArgDesc.InnerDescFactory.CreateReferDatabase(argCaseList); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーフラグが一致すること Assert.AreEqual(errorOccured, isError); }
public static void UpdateManualSpecialCaseTest(int initCaseLength, int index, bool isNullArgCase, bool isError) { var argCaseList = new CommonEventSpecialArgCaseList(MakeArgCaseList(initCaseLength).ToArray()); var instance = new CommonEventSpecialNumberArgDesc.InnerDescManual(argCaseList); 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 { var argCase = isNullArgCase ? null : new CommonEventSpecialArgCase(0, ""); instance.UpdateManualSpecialCase(index, argCase); } 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 SerializeTest() { var target = new CommonEventSpecialArgCaseList(MakeInitList(3, false)); 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); }
public static void GetMaxCapacityTest() { var instance = new CommonEventSpecialArgCaseList(); var changedPropertyList = new List <string>(); instance.PropertyChanged += (sender, args) => { changedPropertyList.Add(args.PropertyName); }; var maxCapacity = instance.GetMaxCapacity(); // 取得した値が容量最大値と一致すること Assert.AreEqual(maxCapacity, CommonEventSpecialArgCaseList.MaxCapacity); // プロパティ変更通知が発火していないこと Assert.AreEqual(changedPropertyList.Count, 0); }
public static void ClearSpecialCaseTest() { var argCaseList = new CommonEventSpecialArgCaseList(MakeArgCaseList(10).ToArray()); var instance = new CommonEventSpecialNumberArgDesc.InnerDescManual(argCaseList); 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.ClearSpecialCase(); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーが発生しないこと Assert.IsFalse(errorOccured); // 意図したとおりプロパティ変更通知が発火していること Assert.AreEqual(changedDescPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 2); Assert.IsTrue(changedSpecialArgCaseListPropertyList[0] .Equals(nameof(instance.SpecialArgCaseList.Count))); Assert.IsTrue(changedSpecialArgCaseListPropertyList[1] .Equals(ListConstant.IndexerName)); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 1); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList[0].Action, NotifyCollectionChangedAction.Reset); }
public static void GetAllSpecialCaseDescriptionTest(int initCaseLength, int answerLength) { var argCaseList = new CommonEventSpecialArgCaseList(MakeArgCaseList(initCaseLength).ToArray()); var instance = new CommonEventSpecialNumberArgDesc.InnerDescManual(argCaseList); 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 caseLength = instance.GetAllSpecialCase().Count; Assert.AreEqual(caseLength, answerLength); // プロパティ変更通知が発火していないこと Assert.AreEqual(changedDescPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 0); }
public static void UpdateDatabaseSpecialCase() { var argCaseList = new CommonEventSpecialArgCaseList(MakeArgCaseList(10).ToArray()); var instance = new CommonEventSpecialNumberArgDesc.InnerDescManual(argCaseList); 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(0, ""); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーが発生すること Assert.IsTrue(errorOccured); // プロパティ変更通知が発火していないこと Assert.AreEqual(changedDescPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListPropertyList.Count, 0); Assert.AreEqual(changedSpecialArgCaseListCollectionArgList.Count, 0); }
public static void ConstructorTestA() { CommonEventSpecialArgCaseList instance = null; var errorOccured = false; try { instance = new CommonEventSpecialArgCaseList(); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーが発生しないこと Assert.IsFalse(errorOccured); // 件数が0件であること Assert.AreEqual(instance.Count, 0); }