vendredi 21 octobre 2016

NUnit 3.X - How to pass dynamic parameters into a TestCase or TestCaseSource?

    CGrunddaten m_grdDaten;

    [SetUp]
    public void Init()
    {
        m_grdDaten = new CGrunddaten();
        m_grdDaten.m_cwdGeoH.m_dW = 325.0;
        m_grdDaten.m_cwd_tl.m_dW = 15;

    }


    [Test]
    public void TestMethod()
    {
        m_grdDaten.RechGrdDaten();
        Assert.That(m_grdDaten.m_cwd_pl.m_dW, Is.EqualTo(93344).Within(.1),"Außenluftdruck");
        Assert.That(m_grdDaten.m_cwd_pl_neb.m_dW, Is.EqualTo(93147.3).Within(.1), "Außenluftdruck Nebenluftberechnung");
        Assert.That(m_grdDaten.m_cwd_pl_pmax.m_dW, Is.EqualTo(92928.2).Within(.1), "Außenluftdruck max. zul. Unterdruck");
        Assert.That(m_grdDaten.m_cwdRho_l.m_dW, Is.EqualTo(1.124).Within(.001), "Dichte Außenluft");
        Assert.That(m_grdDaten.m_cwdRho_l_neb.m_dW, Is.EqualTo(1.184).Within(.001), "Dichte Außenluft Nebenluftberechnung");
        Assert.That(m_grdDaten.m_cwdRho_l_pmax.m_dW, Is.EqualTo(1.249).Within(.001), "Dichte Außenluft max. zul. Unterdruck");
    }

Is there a ways to get this in a TestCase or TestCaseSource, so that I have only one Assert-line ? I know that TestCase and TestCaseSource are static.... but is there another way?

Aucun commentaire:

Enregistrer un commentaire