public IEnumerable <ItemList> Generate(int size) { double percent20Size = 0.2 * size; ProblematicElements problematicElements = new ProblematicElements(); SortedSet <int> problematicSet = problematicElements.CreateSetFromPercentage(size, (int)percent20Size); ItemList item; for (int i = 1; i <= size; i++) { if (problematicSet.Contains(i)) { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 2 }; } else { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 0 }; } ExpectedString.StringWithNoSpecialChar(item); yield return(item); } }
public IEnumerable <ItemList> Generate(int size) { double percent20SizeFail = 0.2 * size; double percent10SizeSlow = 0.1 * size; ProblematicElements problematicElements = new ProblematicElements(); SortedSet <int> problematicSetFail = problematicElements.CreateSetFromPercentage(size, (int)percent20SizeFail); SortedSet <int> problematicSetSlow = problematicElements.CreateSetFromPercentage(size, (int)percent10SizeSlow); ItemList item; for (int i = 1; i <= size; i++) { // The percentage of the elements that are both slow and fail is random, means we cannot test that if (problematicSetFail.Contains(i) && problematicSetSlow.Contains(i)) { Thread.Sleep(1); item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 3 }; } else if (problematicSetFail.Contains(i)) { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 2 }; } else if (problematicSetSlow.Contains(i)) { Thread.Sleep(1); item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 1 }; } else { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 0 }; } ExpectedString.StringWithNoSpecialChar(item); yield return(item); } }
public IEnumerable <ItemList> Generate(int size) { double percentSizeSlow = _slowPercentage * 0.01 * size; double percentSizeFail = _failPercentage * 0.01 * size; ProblematicElements problematicElements = new ProblematicElements(); SortedSet <int> problematicSetSlow = problematicElements.CreateSetFromPercentage(size, (int)percentSizeSlow); SortedSet <int> problematicSetFail = problematicElements.CreateSetFromPercentage(size, (int)percentSizeFail); ItemList item; for (int i = 1; i <= size; i++) { if (problematicSetFail.Contains(i) && problematicSetSlow.Contains(i)) { Thread.Sleep(1); item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 3 }; } else if (problematicSetFail.Contains(i)) { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 2 }; } else if (problematicSetSlow.Contains(i)) { Thread.Sleep(1); item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 1 }; } else { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 0 }; } ExpectedString.StringWithNoSpecialChar(item); yield return(item); } }
public IEnumerable <ItemList> Generate(int size) { int total_percentage = _percentageTimeout + _percentageFail; double percentSize = total_percentage * 0.01 * size; double percentSizeFail = _percentageFail * 0.01 * size; ProblematicElements problematicElements = new ProblematicElements(); SortedSet <int> problematicSet = problematicElements.CreateSetFromPercentage(size, (int)percentSize); SortedSet <int> problematicSetFail = problematicElements.CreateSetFromPercentage((int)percentSize, (int)percentSizeFail); ItemList item; int j = 1; for (int i = 1; i <= size; i++) { if (problematicSet.Contains(i)) { if (problematicSetFail.Contains(j)) { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 2 }; } else { Thread.Sleep(1); item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 1 }; } j += 1; } else { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 0 }; } ExpectedString.StringWithNoSpecialChar(item); yield return(item); } }
public IEnumerable <ItemList> Generate(int size) { double percentSize = 0.3 * size; double percentSizeFail = 0.2 * size; ProblematicElements problematicElements = new ProblematicElements(); SortedSet <int> problematicSet = problematicElements.CreateSetFromPercentage(size, (int)percentSize); SortedSet <int> problematicSetFail = problematicElements.CreateSetFromPercentage((int)percentSize, (int)percentSizeFail); ItemList item; int j = 0; for (int i = 1; i <= size; i++) { if (problematicSet.Contains(i)) { if (problematicSetFail.Contains(j)) { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 2 }; } else { Thread.Sleep(1); // Make sure the time out process is slower than fail item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomStringSpecialChar(), AFlag = 3 }; } j += 1; } else { item = new ItemList() { AnIndex = i, AString = RandomUtil.GetRandomString(), AFlag = 0 }; } ExpectedString.StringWithNoSpecialChar(item); yield return(item); } }