mercredi 20 novembre 2019

Nunit unit testing random number

I'm looking to unit test a method that returns a random float as an ID. I am trying to use Red Green Refactor, but am stumped by the randomness of the code. Below find the method I am trying to test. I am aware that I am technically supposed to write the test first, but I don't know how to test for random. Thanks in advance

public Random ReturnDevID()
            {
                var rnd = new Random();
                rnd.NextDouble();
                return rnd;
            }



Aucun commentaire:

Enregistrer un commentaire