public void PopulateData_LoadMode_ChainsToAddElementAndChildrenIntoList_CorrectParameters() { using (ShimsContext.Create()) { const DataContextMode expectedDcMode = DataContextMode.Load; const TreeViewMode expectedTreeViewMode = TreeViewMode.Control; A11yElement expectedElement = new A11yElement(); ElementDataContext dataContext = new ElementDataContext(expectedElement, 1); A11yElement actualElement = null; BoundedCounter actualCounter = null; Dictionary <int, A11yElement> actualDictionary = null; ShimCaptureAction.AddElementAndChildrenIntoListA11yElementDictionaryOfInt32A11yElementBoundedCounter = (e, d, c) => { actualElement = e; actualDictionary = d; actualCounter = c; }; CaptureAction.PopulateData(dataContext, expectedDcMode, expectedTreeViewMode); Assert.AreEqual(expectedDcMode, dataContext.Mode); Assert.AreEqual(expectedTreeViewMode, dataContext.TreeMode); Assert.AreSame(expectedElement, actualElement); Assert.IsNotNull(actualDictionary); Assert.IsFalse(actualDictionary.Any()); Assert.AreSame(dataContext.ElementCounter, actualCounter); Assert.AreSame(dataContext.Elements, actualDictionary); } }
public void PopulateData_TestMode_ChainsToTreeWalkerRefreshTreeData_CorrectParameters() { using (ShimsContext.Create()) { const DataContextMode expectedDcMode = DataContextMode.Test; const TreeViewMode expectedTreeViewMode = TreeViewMode.Content; A11yElement expectedElement = new A11yElement(); List <A11yElement> expectedElements = null; ElementDataContext dataContext = new ElementDataContext(expectedElement, 1); BoundedCounter actualCounter = null; A11yElement actualElement = null; TreeViewMode? actualTreeMode = null; A11yElement rootElement = null; ShimTreeWalkerForTest.ConstructorA11yElementBoundedCounter = (ktw, e, c) => { actualCounter = c; actualElement = e; new ShimTreeWalkerForTest(ktw) { RefreshTreeDataTreeViewMode = (mode) => { actualTreeMode = mode; expectedElements = new List <A11yElement> { expectedElement }; rootElement = expectedElement; Assert.IsTrue(dataContext.ElementCounter.TryIncrement()); }, ElementsGet = () => expectedElements, TopMostElementGet = () => rootElement, }; }; CaptureAction.PopulateData(dataContext, expectedDcMode, expectedTreeViewMode); Assert.AreSame(dataContext.ElementCounter, actualCounter); Assert.AreSame(expectedElement, actualElement); Assert.AreEqual(expectedDcMode, dataContext.Mode); Assert.AreEqual(expectedTreeViewMode, dataContext.TreeMode); Assert.AreSame(expectedElement, dataContext.Elements.Values.First()); Assert.AreSame(expectedElement, dataContext.RootElment); } }