public void MoveUsingsToFileTest() { List <ICodeElement> codeElements = new List <ICodeElement>(); UsingElement using1 = new UsingElement(); using1.Name = "System"; using1.IsMovable = true; codeElements.Add(using1); NamespaceElement namespaceElement = new NamespaceElement(); namespaceElement.Name = "TestNamespace"; codeElements.Add(namespaceElement); // Nested region and groups RegionElement region = new RegionElement(); region.Name = "Region"; namespaceElement.AddChild(region); GroupElement group = new GroupElement(); group.Name = "Group"; region.AddChild(group); UsingElement using2 = new UsingElement(); using2.Name = "System.IO"; using2.IsMovable = true; group.AddChild(using2); UsingElement using3 = new UsingElement(); using3.Name = "System.Collections"; using3.IsMovable = true; namespaceElement.AddChild(using3); TypeElement class1 = new TypeElement(); class1.Name = "Class1"; namespaceElement.AddChild(class1); TypeElement class2 = new TypeElement(); class2.Name = "Class2"; namespaceElement.AddChild(class2); CodeConfiguration configuration = CodeConfiguration.Default.Clone() as CodeConfiguration; CodeArranger arranger; // // Move to file. // configuration.Formatting.Usings.MoveTo = CodeLevel.File; arranger = new CodeArranger(configuration); ReadOnlyCollection <ICodeElement> arranged = arranger.Arrange(codeElements.AsReadOnly()); Assert.AreEqual(2, arranged.Count, "After arranging, an unexpected number of elements were returned."); GroupElement fileGroup = arranged[0] as GroupElement; Assert.IsNotNull(fileGroup); GroupElement innerGroup = fileGroup.Children[0] as GroupElement; Assert.AreEqual("System", innerGroup.Children[0].Name); Assert.AreEqual("System.Collections", innerGroup.Children[1].Name); Assert.AreEqual("System.IO", innerGroup.Children[2].Name); NamespaceElement namespaceElementTest = arranged[1] as NamespaceElement; Assert.IsNotNull(namespaceElementTest, "Expected a namespace element."); Assert.AreEqual(2, namespaceElementTest.Children.Count, "After arranging, an unexpected number of namespace elements were returned."); RegionElement typeRegion = namespaceElementTest.Children[1] as RegionElement; Assert.IsNotNull(typeRegion); Assert.AreEqual("Class1", typeRegion.Children[0].Name); Assert.AreEqual("Class2", typeRegion.Children[1].Name); }