Exemplo n.º 1
0
    public void ShiftCallbackTest()
    {
        foreach (var testCase in m_shiftCallbackTestCases)
        {
            var unitGaridManager = new UnitGridManager
                                       (testCase.gridWidth,
                                       testCase.gridHeight,
                                       testCase.horizontalCount,
                                       testCase.verticalCount);
            unitGaridManager.UpdateElementCount(testCase.elementCount);

            foreach (var shiftCallback in testCase.shiftCallbacks)
            {
                var movedIndexes       = new List <int>();
                var dataUpdatedIndexes = new List <int>();
                unitGaridManager.Shift(shiftCallback.scrollValue,
                                       (index, delta) =>
                {
                    movedIndexes.Add(index);
                },
                                       (index, delta) =>
                {
                    dataUpdatedIndexes.Add(index);
                });

                Assert.True(IsSamePrimitiveList(movedIndexes, shiftCallback.expectedMovedIndexes));
                Assert.True(IsSamePrimitiveList(dataUpdatedIndexes, shiftCallback.expectedUpdatedIndexes));
            }
        }
    }
Exemplo n.º 2
0
    public void Initialize()
    {
        m_initialized = true;

        if (m_unitGridManager == null)
        {
            m_unitGridManager = new UnitGridManager(
                m_gridWidth,
                m_gridHeight,
                m_horizontalCount,
                m_verticalCount);
        }

        SetUpListItems();
    }
Exemplo n.º 3
0
    public void ShiftTest()
    {
        foreach (var testCase in m_shiftTestCases)
        {
            var unitGaridManager = new UnitGridManager
                                       (testCase.gridWidth,
                                       testCase.gridHeight,
                                       testCase.horizontalCount,
                                       testCase.verticalCount);
            unitGaridManager.UpdateElementCount(testCase.elementCount);

            foreach (var verticalOffset in testCase.verticalOffsets)
            {
                unitGaridManager.Shift(verticalOffset.scrollValue, null, null);
                Assert.True(unitGaridManager.GetVerticalOffset() == verticalOffset.expected);
            }
        }
    }
Exemplo n.º 4
0
    public void InitialConditionTest()
    {
        foreach (var testCase in m_initialConditionTestCases)
        {
            var unitGaridManager = new UnitGridManager
                                       (testCase.gridWidth,
                                       testCase.gridHeight,
                                       testCase.horizontalCount,
                                       testCase.verticalCount);
            unitGaridManager.UpdateElementCount(testCase.elementCount);

            Assert.True(unitGaridManager.GetVerticalOffset() == testCase.expectedVerticalOffset);
            Assert.True(unitGaridManager.GetScrollRectHeight() == testCase.expectedScrollRectHeight);
            foreach (var initialPosition in testCase.initialPositions)
            {
                Assert.True(unitGaridManager.GetInitialPosition(initialPosition.index) == initialPosition.expected);
            }
        }
    }