public void ShrinkingOscillatingWindowTest() { const int cl = 4; IEnumerable <Window> windows = AstMatchHelper.OscillateWindows(cl); CollectionAssert.Contains(windows, new Window(0, 0)); CollectionAssert.Contains(windows, new Window(0, 1)); CollectionAssert.Contains(windows, new Window(0, 2)); CollectionAssert.Contains(windows, new Window(0, 3), "This would be the entire function body."); CollectionAssert.Contains(windows, new Window(1, 1)); CollectionAssert.Contains(windows, new Window(1, 2)); CollectionAssert.Contains(windows, new Window(1, 3)); CollectionAssert.Contains(windows, new Window(2, 2)); CollectionAssert.Contains(windows, new Window(2, 3)); CollectionAssert.Contains(windows, new Window(3, 3)); Assert.AreEqual(10, windows.Count(), "There are more than expected."); Assert.AreEqual(5, new Window(0, 4).Size, "Size is determined inclusive with the end points."); Assert.Throws <ArgumentException>(() => { new Window(1, 0); }, "size parameters are out of order"); Assert.Throws <ArgumentException>(() => { new Window(-2, 3); }, "zero is the minimum"); Assert.Throws <ArgumentException>(() => { new Window(0, -3); }, "zero is the minimum"); }
public int CountAllExtractedMethods(MethodDeclaration right, int targetChildCount) { List <INode> children = right.Body.Children; var windows = AstMatchHelper.OscillateWindows(children.Count); return(ProcessChildren(right, children, windows, targetChildCount)); }
public IEnumerable <CloneDesc> GetAllPossibleExtractedMethods(MethodDeclaration right, int targetChildCount) { List <INode> children = right.Body.Children; var windows = AstMatchHelper.OscillateWindows(children.Count); return(ProcessChildren(right, children, windows, targetChildCount)); }
public void TestOrder() { const int MaxSize = 2; var windows = AstMatchHelper.OscillateWindows(MaxSize); var last_size = MaxSize; foreach (var window in windows) { Assert.LessOrEqual(window.Size, last_size); last_size = window.Size; } }
private int ProcessChild(MethodDeclaration right, INode child, int targetChildCount) { var children1 = OscillatingExtractMethodRefactoringExpansion.GetExtractableChildren(child); return(ProcessChildren(right, children1, AstMatchHelper.OscillateWindows(children1.Count), targetChildCount)); }
private IEnumerable <CloneDesc> ProcessChild(MethodDeclaration right, INode child, int targetChildCount) { var children1 = GetExtractableChildren(child); return(ProcessChildren(right, children1, AstMatchHelper.OscillateWindows(children1.Count), targetChildCount)); }