private static DependencyTestDataPoint GenerateValidRandomizedTestDataPoint() { var random = new Random(); DependencyType dependencyType = DependencyTypeTestData.GenerateValidRandomizedDependencyType(); String dependentModName = random.Next(10) == 0 ? "base" : ModTestData.GenerateValidRandomizedModName(); DependencyComparisonType dependencyComparisonType = null; ModVersion dependentModVersion = null; if (random.Next(6) == 0) { dependencyComparisonType = DependencyComparisonTypeTestData.GenerateValidRandomizedDependencyComparisonType(); if (dependentModName == "base" && random.Next(2) == 0) { dependentModVersion = ModVersion.For(FactorioVersionTestData.GenerateValidRandomizedFactorioVersionString() + ".0"); } else { dependentModVersion = ModVersionTestData.GenerateValidRandomizedModVersion(); } } return(CreateTestDataPointFromProperties( DependencyType: dependencyType, DependentModName: dependentModName, DependencyComparisonType: dependencyComparisonType, DependentModVersion: dependentModVersion )); }
public static IEnumerable <object[]> RandomDependencyStringsWithExpectedModVersion(Int32 count = 10) { // Quick Note: This class demonstrates the crazy range of cases we need to cover when parsing dependency strings. var random = new Random(); var resultStringBuilder = new StringBuilder(); for (int i = 0; i < count; i++) { resultStringBuilder.Clear(); ModVersion expectedModVersion = null; if (random.Next(6) == 0) { resultStringBuilder.Append(DependencyTypeTestData.GenerateValidRandomizedDependencyTypeString()); if (resultStringBuilder.Length != 0) { resultStringBuilder.Append(" "); } } String modNameString = random.Next(10) == 0 ? "base" : ModTestData.GenerateValidRandomizedModName(); resultStringBuilder.Append(modNameString); if (random.Next(6) == 0) { if (random.Next(6) == 0) { resultStringBuilder.Append(" "); } resultStringBuilder.Append(DependencyComparisonTypeTestData.GenerateValidRandomizedDependencyComparisonTypeString()); if (random.Next(6) == 0) { resultStringBuilder.Append(" "); } if (modNameString == "base" && random.Next(2) != 0) { String randomFactorioVersionString = FactorioVersionTestData.GenerateValidRandomizedFactorioVersionString(); expectedModVersion = ModVersion.For(randomFactorioVersionString + ".0"); resultStringBuilder.Append(randomFactorioVersionString); } else { String randomModVersionString = ModVersionTestData.GenerateValidRandomizedModVersionString(); expectedModVersion = ModVersion.For(randomModVersionString); resultStringBuilder.Append(randomModVersionString); } } yield return(new object[] { resultStringBuilder.ToString(), expectedModVersion }); } }