public void ReportHandler_ReportingTest() { CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator<string>.ReportOut reportHandler = handlerClass.HandleReport; CombinatorialTier<string> resultTier = null; List<string> expectedCombinatorials = CombinatorialGenerator_TestClass.Get_CountThree_TierThree_NoDegenerates(); testGenerator.ReportingHandler = reportHandler; testGenerator.Elements = CombinatorialGenerator_TestClass.GetCountThreeList(); bool getResult = testGenerator.GetCombinatorials(3); resultTier = testGenerator.GetTier(3); Assert.IsTrue(getResult); Assert.Greater(handlerClass.Combinatorials.Count, 0); Assert.IsNotNull(handlerClass.Tier); Assert.Greater(handlerClass.Tier.Tier.Count, 0); List<string> internalTierList = CombinatorialGenerator_TestClass.ConvertCombinatorialsToStringList(resultTier); List<string> externalTierList = CombinatorialGenerator_TestClass.ConvertCombinatorialsToStringList(handlerClass.Tier); List<string> externalCombinatorialList = CombinatorialGenerator_TestClass.ConvertCombinatorialsToStringList(handlerClass.Combinatorials); CollectionAssert.AreEquivalent(internalTierList, externalTierList); CollectionAssert.AreEquivalent(internalTierList, externalCombinatorialList); }
public void GetTier_ElementsCountOne_PassTwo() { CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string>.ErrorOut errorHandler = handlerClass.HandleError; CombinatorialTier<string> resultTier = null; testGenerator.ErrorHandler = errorHandler; testGenerator.Elements = CombinatorialGenerator_TestClass.GetCountOneList(); bool getResult = testGenerator.GetCombinatorials(); resultTier = testGenerator.GetTier(2); Assert.IsTrue(getResult); Assert.AreEqual(1, handlerClass.Errors.Count, "Errors.Count"); Assert.IsTrue(handlerClass.ContainsError("TryGetTierPassedFailed"), "TryGetTierPassedFailed"); }
public void HandlersPassed_ReportHandlerAssignment() { CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator<string>.ReportOut reportHandler = handlerClass.HandleReport; testGenerator.ReportingHandler = reportHandler; Assert.IsTrue(testGenerator.ReportingOn); }
public void ErrorHandler_GetCombinatorials_TierMaxGreaterThanElementsCount() { CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator<string>.ErrorOut errorHandler = handlerClass.HandleError; testGenerator.ErrorHandler = errorHandler; testGenerator.Elements = CombinatorialGenerator_TestClass.GetCountTwoList(); bool getResult = testGenerator.GetCombinatorials(1, 3); Assert.IsFalse(getResult, "Get Result"); Assert.AreEqual(1, handlerClass.Errors.Count, "Errors.Count"); Assert.IsTrue(handlerClass.ContainsError("TierMaxMoreThanElementsCount"), "Contains TierMaxMoreThanElementsCount"); }
public void ErrorHandler_GetCombinatorials_TierMaxLessThanTierMin() { CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator<string>.ErrorOut errorHandler = handlerClass.HandleError; testGenerator.ErrorHandler = errorHandler; testGenerator.Elements = CombinatorialGenerator_TestClass.GetCountTwoList(); bool getResult = testGenerator.GetCombinatorials(2, 1); Assert.IsFalse(getResult); Assert.AreEqual(1, handlerClass.Errors.Count); Assert.IsTrue(handlerClass.ContainsError("TierMaxLessThanTierMin")); }
public void ErrorHandler_GetCombinatorials_ElementsIsEmpty() { CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator<string>.ErrorOut errorHandler = handlerClass.HandleError; testGenerator.ErrorHandler = errorHandler; bool getResult = testGenerator.GetCombinatorials(); Assert.IsFalse(getResult); Assert.AreEqual(1, handlerClass.Errors.Count); Assert.IsTrue(handlerClass.ContainsError("ElementsIsEmpty")); }
public void ErrorHandler_ElementsIsNull() { CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator<string>.ErrorOut errorHandler = handlerClass.HandleError; testGenerator.ErrorHandler = errorHandler; testGenerator.Elements = null; Assert.AreEqual(1, handlerClass.Errors.Count); Assert.IsTrue(handlerClass.ContainsError("ElementsIsNull")); }
public void ErrorHandler_Assignment() { CombinatorialGenerator_TestClass handlerClass = new CombinatorialGenerator_TestClass(); CombinatorialGenerator<string> testGenerator = new CombinatorialGenerator<string>(); CombinatorialGenerator<string>.ErrorOut errorHandler = handlerClass.HandleError; testGenerator.ErrorHandler = errorHandler; Assert.IsTrue(testGenerator.ErrorsOn); }