public void AddedSources_Are_Deterministic() { // a few manual simple ones AdditionalSourcesCollection asc = new AdditionalSourcesCollection(".cs"); asc.Add("file3.cs", SourceText.From("", Encoding.UTF8)); asc.Add("file1.cs", SourceText.From("", Encoding.UTF8)); asc.Add("file2.cs", SourceText.From("", Encoding.UTF8)); asc.Add("file5.cs", SourceText.From("", Encoding.UTF8)); asc.Add("file4.cs", SourceText.From("", Encoding.UTF8)); var sources = asc.ToImmutableAndFree(); var hintNames = sources.Select(s => s.HintName).ToArray(); Assert.Equal( new[] { "file3.cs", "file1.cs", "file2.cs", "file5.cs", "file4.cs" }, hintNames ); // generate a long random list, remembering the order we added them Random r = new Random(); string[] names = new string[1000]; asc = new AdditionalSourcesCollection(".cs"); for (int i = 0; i < 1000; i++) { names[i] = CSharpTestBase.GetUniqueName() + ".cs"; asc.Add(names[i], SourceText.From("", Encoding.UTF8)); } sources = asc.ToImmutableAndFree(); hintNames = sources.Select(s => s.HintName).ToArray(); Assert.Equal(names, hintNames); }