Пример #1
0
        public void Task1_PrintMatrix()
        {
            //int.MaxValue   =   2147483647
            Day3.CalculateNPlus1(265149);
            //Day3.CalculateNPlus1(806);
            GetOuterCorners(out var lowerLeft, out var upperRight);

            var stringWriter = new StringWriter();

            using (var writer = new HtmlTextWriter(stringWriter))
            {
                writer.RenderBeginTag("html");
                writer.RenderBeginTag("head");
                writer.RenderBeginTag(HtmlTextWriterTag.Style);
                writer.Write(".value { display: inline-block; width: 65px; height: 65px; background: blue; color: white; font-size: 14pt; }");
                writer.RenderEndTag();
                writer.RenderEndTag();

                writer.RenderBeginTag("body");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                int x = lowerLeft.X, y = upperRight.Y;
                while (y >= lowerLeft.Y)
                {
                    while (x <= upperRight.X)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, "value");
                        writer.RenderBeginTag(HtmlTextWriterTag.Div);
                        if (Day3.ValueMap.ContainsKey(new Point(x, y)))
                        {
                            writer.Write(Day3.ValueMap[new Point(x, y)]);
                        }
                        else
                        {
                            writer.Write("&nbsp;");
                        }
                        writer.RenderEndTag();
                        x++;
                    }

                    writer.Write("<br/>");
                    x = lowerLeft.X;
                    y--;
                }

                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.RenderEndTag();
            }

            // Return the result.
            var temp = stringWriter.ToString();

            File.WriteAllText("C:\\Users\\frwi20\\Desktop\\valueMatrix.htm", temp);
        }
Пример #2
0
        public void Task2_CorrectSum1()
        {
            var val = Day3.CalculateNPlus1(23);

            Assert.That(val, Is.EqualTo(25));
        }