示例#1
0
        public void ConvertRenderDataOffsetToPoint_ShouldWork()
        {
            InitializeTestData();
            PSConsoleReadLine instance = GetPSConsoleReadLineSingleton();

            foreach (ResizingTestData test in s_resizingTestData)
            {
                RenderData renderData = new()
                {
                    lines       = new RenderedLineData[test.Lines.Count],
                    bufferWidth = test.OldBufferWidth
                };

                for (int i = 0; i < test.Lines.Count; i++)
                {
                    renderData.lines[i] = new RenderedLineData(test.Lines[i], isFirstLogicalLine: i == 0);
                }

                for (int j = 0; j < test.Context.Count; j++)
                {
                    ResizingTestContext context = test.Context[j];
                    if (context.Offset.LineIndex != -1)
                    {
                        renderData.cursorLeft = context.OldCursor.X;
                        renderData.cursorTop  = context.OldCursor.Y;

                        var   offset    = new RenderDataOffset(context.Offset.LineIndex, context.Offset.CharIndex);
                        Point newCursor = instance.ConvertRenderDataOffsetToPoint(context.NewInitial.X, context.NewInitial.Y, test.NewBufferWidth, renderData, offset);
                        Assert.True(
                            context.NewCursor.X == newCursor.X &&
                            context.NewCursor.Y == newCursor.Y,
                            $"{test.Name}-context_{j}: calculated new cursor is not what's expected [X: {newCursor.X}, Y: {newCursor.Y}]");
                    }
                }
            }
        }