Thursday, June 2, 2016

Fraction and unit testing

here is the test document

Test Document

here is the Unit Test Code

using System;
using Fractions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FractionTestProject
{
    [TestClass]
    public class UnitTest1
    {

        [TestMethod]
        public void AdditionTestMethod()
        {
            Fraction f1 = new Fraction("1/2");
            Fraction f2 = new Fraction(1, 3);
            Fraction f3 = f1 + f2;

            Assert.AreEqual("5/6", f3.ToString());
        }

        [TestMethod]

        public void MultiplicationTestMethod()
        {
            Fraction f1 = new Fraction("1/2");
            Fraction f2 = new Fraction(1, 3);
            Fraction f3 = f1 * f2;

            Assert.AreEqual("1/6", f3.ToString());
        }

        [TestMethod]
        public void GreaterThanTestMethod()
        {
            Fraction f1 = new Fraction("1/2");
            Fraction f2 = new Fraction(1, 3);


            Assert.IsTrue(f1 > f2);
        }

    }
}

No comments:

Post a Comment