classdef DocPolynomMultiplicationTest < matlab.unittest.TestCase
    properties
        TextToDisplay = "Equation under test: "
    end

    methods (TestClassSetup)
        function addDocPolynomClassToPath(testCase)
            import matlab.unittest.fixtures.PathFixture
            folder = fullfile(matlabroot, ...
                "help","techdoc","matlab_oop","examples");
            testCase.applyFixture(PathFixture(folder))
            testCase.assertNotEmpty(?DocPolynom)
        end
    end

    methods (Test)
        function test1(testCase)
            p1 = DocPolynom([1 0 3]);
            p2 = DocPolynom([5 2]);
            actual = p1 * p2;
            expected = DocPolynom([5 2 15 6]);
            diagnostic = [testCase.TextToDisplay ...
                "(x^2 + 3) * (5*x + 2) = 5*x^3 + 2*x^2 + 15*x + 6"];
            testCase.verifyEqual(actual,expected,diagnostic)
        end

        function test2(testCase)
            p1 = DocPolynom([1 4]);
            p2 = DocPolynom([2 3]);
            p3 = DocPolynom([1 0 -1]);
            actual = p1 * p2 * p3;
            expected = DocPolynom([2 11 10 -11 -12]);
            diagnostic = [testCase.TextToDisplay ...
                "(x + 4) * (2*x + 3) * (x^2 - 1) = 2*x^4 + 11*x^3 + 10*x^2 - 11*x - 12"];
            testCase.verifyEqual(actual,expected,diagnostic)
        end
    end
end