Exemple #1
0
 public static string ToString(this Complex complex, ComplexDisplay format)
 {
     return(format switch
     {
         ComplexDisplay.Algebraic => AlgebraicDisplay(complex),
         ComplexDisplay.Trigonometric => TrigonometricDisplay(complex),
         _ => complex.ToString()
     });
Exemple #2
0
            public void Test_complex_display_dynamic_dimensions_with_lines()
            {
                ComplexDisplay display = new ComplexDisplay();

                DisplayLine line1 = new DisplayLine
                {
                    Canvas = new DisplayCanvas
                    {
                        Sizes = new List <int> {
                            0
                        },
                        DynamicIndex = 0
                    },
                    Texts = new List <DisplayText>
                    {
                        new DisplayText("test", 4)
                    }
                };//Total size = 4

                DisplayLine line2 = new DisplayLine
                {
                    Canvas = new DisplayCanvas
                    {
                        Sizes = new List <int> {
                            0
                        },
                        DynamicIndex = 0
                    },
                    Texts = new List <DisplayText>
                    {
                        new DisplayText("test", 5)
                    }
                };                  //Total size = 5

                display.Add(line1); //base size = 4
                display.Add(line2); //base size = 5
                //display.Add() modifies the size of each line so their size is equal to the longest line.
                //This is necessary so that lines with text after their name align.
                line1.TotalSize.Should().Be(5);
            }