Esempio n. 1
0
        public void PolynomialPrintTest()
        {
            Polynomial P1 = new Polynomial(3, new double[] { 1, 1, 2, 1 });

            string file = Path.GetTempFileName();
            FileStream fs = new FileStream(file, FileMode.Create);
            TextWriter tmp = Console.Out;
            StreamWriter sw = new StreamWriter(fs);
            Console.SetOut(sw);
            #pragma warning disable 618
            P1.print();
            #pragma warning restore 618
            Console.SetOut(tmp);
            sw.Close();
            string actual = File.ReadAllText(file);
            string expected = "1\t1\t2\t1\t" + System.Environment.NewLine;

            Assert.AreEqual(actual, expected);

            File.Delete(file);

            P1.print(file);
            actual = File.ReadAllText(file);
            Assert.AreEqual(actual, expected);
        }