本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.List.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddRange方法的具体用法?C# List.AddRange怎么用?C# List.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting.List
的用法示例。
在下文中一共展示了List.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileFile
public static CompilerResults CompileFile(string input, string output, params string[] references)
{
CreateOutput(output);
List<string> referencedAssemblies = new List<string>(references.Length + 3);
referencedAssemblies.AddRange(references);
referencedAssemblies.Add("System.dll");
referencedAssemblies.Add(typeof(IModule).Assembly.CodeBase.Replace(@"file:///", ""));
referencedAssemblies.Add(typeof(ModuleAttribute).Assembly.CodeBase.Replace(@"file:///", ""));
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters(referencedAssemblies.ToArray(), output);
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(input))
{
if (stream == null)
{
throw new ArgumentException("input");
}
StreamReader reader = new StreamReader(stream);
string source = reader.ReadToEnd();
CompilerResults results = codeProvider.CompileAssemblyFromSource(cp, source);
ThrowIfCompilerError(results);
return results;
}
}
示例2: GetAllExcelFiles
public static List<string> GetAllExcelFiles()
{
List<string> ExcelFiles = new List<string>();
ExcelFiles.AddRange(GetAllVolExcelFiles());
ExcelFiles.AddRange(GetAllVendExcelFiles());
return ExcelFiles;
}
示例3: FindPathsWithSum
public static IList<IList<int>> FindPathsWithSum(TreeNode root, List<int> path, int search)
{
if (root == null)
{
return new List<IList<int>>();
}
path.Add(root.Value);
List<IList<int>> results = new List<IList<int>>();
for (int i = path.Count - 1; i >= 0; i--)
{
IList<int> currPath = path.GetRange(i, path.Count - i);
int sum = currPath.Aggregate((total, next) => { return total + next; });
if (sum == search)
{
results.Add(currPath);
}
}
results.AddRange(FindPathsWithSum(root.Left, new List<int>(path), search));
results.AddRange(FindPathsWithSum(root.Right, new List<int>(path), search));
return results;
}
示例4: ArticleClassificationIsVulnerabilities
public void ArticleClassificationIsVulnerabilities()
{
var urlList = new List<string>();
//Fetching Parent node Urls
urlList.AddRange(HPFortifyXMLMapping.Select(x => x.ArticleUrl));
//Fetching Child urls
var subcategoryUrl = (from query in HPFortifyXMLMapping
from subcategory in query.SubCategories
select subcategory.ArticleUrl).ToList();
//Merging both Url list to make processing easier
urlList.AddRange(subcategoryUrl);
using (var driver = new OpenQA.Selenium.Firefox.FirefoxDriver())
{
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
foreach (var url in urlList)
{
driver.Url = url;
driver.Navigate();
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(x => x.FindElement(By.Id("GuidanceTypeLabel")).Text.Length>0);
var text = driver.FindElement(By.Id("GuidanceTypeLabel")).Text;
Console.WriteLine(text);
Assert.IsTrue(text == "Vulnerability");
}
}
}
示例5: TestRunningWeightedVarianceDecremental
public void TestRunningWeightedVarianceDecremental()
{
var arr = new List<double[]>();
arr.AddRange(EnumerableExtensions.Create(1, _ => new double[] { 0 }));
arr.AddRange(EnumerableExtensions.Create(1, _ => new double[] { 10 }));
arr.AddRange(EnumerableExtensions.Create(1, _ => new double[] { 0 }));
arr.AddRange(EnumerableExtensions.Create(1, _ => new double[] { 1 }));
double[] w = EnumerableExtensions.Create(arr.Count, _ => (double)1).ToArray();
var variancesDec = new List<double>();
arr.RunningVarianceDecremental
(
(idx, avgInc, varDec) =>
{
variancesDec.Add(varDec);
}
, w
);
Assert.IsTrue(Math.Abs(variancesDec[0] - 20.22) < 1E-2);
Assert.IsTrue(Math.Abs(variancesDec[1] - 0.25) < 1E-2);
Assert.IsTrue(Math.Abs(variancesDec[2] - 0) < 1E-2);
Assert.IsTrue(Double.IsInfinity(variancesDec[3]));
}
示例6: TestBkToCipherTextOnSocket
public void TestBkToCipherTextOnSocket()
{
_bkToCipherText = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var endpt = new IPEndPoint(IPAddress.Loopback, BK_CT_PORT);
_bkToCipherText.Connect(endpt);
var bytesSent = _bkToCipherText.Send(Encoding.UTF8.GetBytes(TEST_INPUT));
var buffer = new List<byte>();
var data = new byte[256];
_bkToCipherText.Receive(data, 0, data.Length, SocketFlags.None);
buffer.AddRange(data.Where(b => b != (byte)'\0'));
while (_bkToCipherText.Available > 0)
{
data = new byte[_bkToCipherText.Available];
_bkToCipherText.Receive(data, 0, data.Length, SocketFlags.None);
buffer.AddRange(data.Where(b => b != (byte)'\0'));
}
_bkToCipherText.Close();
var cipherdata = Encoding.UTF8.GetString(buffer.ToArray());
NoFuture.Shared.CipherText cipherText;
var parseResult = NoFuture.Shared.CipherText.TryParse(cipherdata, out cipherText);
Assert.IsTrue(parseResult);
Console.WriteLine(cipherText.ToString());
}
示例7: GetAllAssemblies
private List<Assembly> GetAllAssemblies(string path)
{
var files = new List<FileInfo>();
var directoryToSearch = new DirectoryInfo(path);
files.AddRange(directoryToSearch.GetFiles("*.dll", SearchOption.AllDirectories));
files.AddRange(directoryToSearch.GetFiles("*.exe", SearchOption.AllDirectories));
return files.ConvertAll(file => Assembly.LoadFile(file.FullName));
}
示例8: GetFileNames
public static IEnumerable<string> GetFileNames()
{
var list = new List<string>();
list.AddRange(Directory.GetFiles(".", "g.*.graphml"));
if (Directory.Exists("graphml"))
list.AddRange(Directory.GetFiles("graphml", "g.*.graphml"));
return list;
}
示例9: TestCtor
public void TestCtor()
{
var testInputAllBoolStrings = new List<string>
{
bool.TrueString,
bool.TrueString,
bool.FalseString,
bool.TrueString,
bool.FalseString,
bool.FalseString
};
var testInputAllBoolMssqlBit = new List<string> {"1", "0", "0", "1", "0", "1"};
var testInputAllDecimal = new List<string> {"0.0", "1.0", "3.4", "6.90", "8.098"};
var testInputAllInt = new List<string> {"2", "138", "56", "85", "-5"};
var testInputAllDate = new List<string>
{
DateTime.Today.ToLongDateString(),
DateTime.Today.ToShortDateString(),
"2015-03-04 09:23:55.554121"
};
var testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputAllBoolStrings.ToArray());
Assert.AreEqual(NoFuture.Sql.Mssql.Md.PsTypeInfo.BOOL, testResult.PsDbType);
testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputAllBoolMssqlBit.ToArray());
Assert.AreEqual(NoFuture.Sql.Mssql.Md.PsTypeInfo.BOOL, testResult.PsDbType);
testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputAllDecimal.ToArray());
Assert.AreEqual(NoFuture.Sql.Mssql.Md.PsTypeInfo.DEC, testResult.PsDbType);
testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputAllInt.ToArray());
Assert.AreEqual(NoFuture.Sql.Mssql.Md.PsTypeInfo.INT, testResult.PsDbType);
testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputAllDate.ToArray());
Assert.AreEqual(NoFuture.Sql.Mssql.Md.PsTypeInfo.DATE, testResult.PsDbType);
var testInputMixed = new List<string>();
testInputMixed.AddRange(testInputAllBoolMssqlBit);
testInputMixed.Add("do you wanna earn more money");
testInputMixed.Add("sure we all do.");
testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputMixed.ToArray());
Assert.IsTrue(testResult.PsDbType.StartsWith(NoFuture.Sql.Mssql.Md.PsTypeInfo.DEFAULT_PS_DB_TYPE));
var testInputAllBoolMixed = new List<string>();
testInputAllBoolMixed.AddRange(testInputAllBoolStrings);
testInputAllBoolMixed.AddRange(testInputAllBoolMssqlBit);
testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputAllBoolMixed.ToArray());
Assert.AreEqual(NoFuture.Sql.Mssql.Md.PsTypeInfo.BOOL, testResult.PsDbType);
var testInputAllIntWithDecPt = new List<string> {"2.0", "138.0", "56.0", "85.0", "-5.0"};
testResult = new NoFuture.Sql.Mssql.Md.PsTypeInfo("test", testInputAllIntWithDecPt.ToArray());
Assert.AreEqual(NoFuture.Sql.Mssql.Md.PsTypeInfo.DEC, testResult.PsDbType);
}
示例10: When_machine_is_fed_with_coins_Then_should_sort_into_two_types
public void When_machine_is_fed_with_coins_Then_should_sort_into_two_types()
{
CoinSortMachine machine = new CoinSortMachine();
List<ICoin> coins = new List<ICoin>();
CoinFactory factory = new CoinFactory();
coins.AddRange(factory.GetPennies(10));
coins.AddRange(factory.GetNickels(10));
machine.FeedCoins(coins);
Assert.AreEqual(10, machine.Pennies.Count);
Assert.AreEqual(10, machine.Nickels.Count);
}
示例11: ShouldParseWhenLastStringHasNoTerminator
public void ShouldParseWhenLastStringHasNoTerminator()
{
var bytes = new List<byte>();
bytes.AddRange(Encoding.ASCII.GetBytes("abc"));
bytes.Add(0);
bytes.AddRange(Encoding.ASCII.GetBytes("def"));
var reader = new DelimitedReader(new StreamReader(new MemoryStream(bytes.ToArray())));
Assert.AreEqual("abc", reader.Read());
Assert.AreEqual("def", reader.Read());
Assert.AreEqual(null, reader.Read());
}
示例12: ParseEndUserSuppliedXriIdentifer
public void ParseEndUserSuppliedXriIdentifer()
{
List<char> symbols = new List<char>(XriIdentifier.GlobalContextSymbols);
symbols.Add('(');
List<string> prefixes = new List<string>();
prefixes.AddRange(symbols.Select(s => s.ToString()));
prefixes.AddRange(symbols.Select(s => "xri://" + s.ToString()));
foreach (string prefix in prefixes) {
var id = Identifier.Parse(prefix + "andrew");
Assert.IsInstanceOfType(id, typeof(XriIdentifier));
}
}
示例13: TestParserManyLines
public void TestParserManyLines()
{
var data = new List<string>();
data.AddRange(TestData.board_init.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
data.AddRange(TestData.events.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
data.AddRange(TestData.interrupt_sam_nvic.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
data.AddRange(TestData.osc8_calib.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
var result = SuFileParser.Parse(data).ToList();
Assert.AreEqual(21, result.Count());
}
示例14: FieldDefinitions_ShouldHave_Correct_Indexed_Property
public void FieldDefinitions_ShouldHave_Correct_Indexed_Property()
{
var fieldDefinitionTypes = new List<Type>();
fieldDefinitionTypes.AddRange(ReflectionUtils.GetTypesFromAssembly<FieldDefinition>(typeof(FieldDefinition).Assembly));
fieldDefinitionTypes.AddRange(ReflectionUtils.GetTypesFromAssembly<FieldDefinition>(typeof(TaxonomyFieldDefinition).Assembly));
foreach (var fieldDefintion in fieldDefinitionTypes)
{
Trace.WriteLine(string.Format("Checking Indexed prop for Indexed def:[{0}]", fieldDefintion.GetType().Name));
var indexedSiteModel = SPMeta2Model.NewSiteModel(m => { });
var indexedSiteField = ModelGeneratorService.GetRandomDefinition(fieldDefintion) as FieldDefinition;
indexedSiteModel.AddField(indexedSiteField);
indexedSiteField.Indexed = true;
// dep lookiup
if (indexedSiteField is DependentLookupFieldDefinition)
{
var primaryLookupField = new LookupFieldDefinitionGenerator().GenerateRandomDefinition() as FieldDefinition;
(indexedSiteField as DependentLookupFieldDefinition).PrimaryLookupFieldId = primaryLookupField.Id;
indexedSiteModel.AddField(primaryLookupField);
}
TestModel(indexedSiteModel);
Trace.WriteLine(string.Format("Checking Indexed prop for non-Indexed def:[{0}]", fieldDefintion.GetType().Name));
var nonIdexedSiteModel = SPMeta2Model.NewSiteModel(m => { });
var nonIndexedSiteField = ModelGeneratorService.GetRandomDefinition(fieldDefintion) as FieldDefinition;
nonIdexedSiteModel.AddField(nonIndexedSiteField);
nonIndexedSiteField.Indexed = false;
// dep lookiup
if (indexedSiteField is DependentLookupFieldDefinition)
{
var primaryLookupField = new LookupFieldDefinitionGenerator().GenerateRandomDefinition() as FieldDefinition;
(nonIndexedSiteField as DependentLookupFieldDefinition).PrimaryLookupFieldId = primaryLookupField.Id;
nonIdexedSiteModel.AddField(primaryLookupField);
}
TestModel(nonIdexedSiteModel);
}
}
示例15: ExpectUpdateAttributes_ShouldHave_Services
public void ExpectUpdateAttributes_ShouldHave_Services()
{
var updateAttrTypes = ReflectionUtils.GetTypesFromAssembly<ExpectUpdate>(typeof(ExpectUpdate).Assembly);
var updateAttrServices = new List<ExpectUpdateValueServiceBase>();
updateAttrServices.AddRange(ReflectionUtils.GetTypesFromAssembly<ExpectUpdateValueServiceBase>(typeof(ExpectUpdateValueServiceBase).Assembly)
.Select(t => Activator.CreateInstance(t) as ExpectUpdateValueServiceBase));
TraceUtils.WithScope(trace =>
{
foreach (var attr in updateAttrTypes)
{
var targetServices = updateAttrServices.FirstOrDefault(s => s.TargetType == attr);
if (targetServices != null)
{
trace.WriteLine(string.Format("ExpectUpdate: [{0}] has service: [{1}]", attr,
targetServices.GetType()));
}
else
{
trace.WriteLine(string.Format("ExpectUpdate: [{0}] misses service impl", attr));
Assert.Fail();
}
}
});
}