mardi 7 mars 2017

How to write nunit test case for singleton class

NAudioEngine is a singleton class how to write the can execute in the following code snippet:

    private bool CanAddNew(object parameter)
    {
        if (NAudioEngine.Instance.SelectionEnd.Milliseconds != 0)
        {
            return true;
        }
        return false;
    }
   [Test]
    public void AddNewCommandMainVMTestTrue()
    {
        MainVm mainVM = new MainVm();
        RelayCommand command = (RelayCommand)mainVM.AddNewCommand;
        bool canAddNew = command.CanExecute(null);
        Assert.IsTrue(canAddNew);

    }

Aucun commentaire:

Enregistrer un commentaire