dimanche 5 mars 2017

How to write the nunit test case for the following

How to write the Nunit test case for the following code snippet? CreateFolder() is a function to create a new folder in the tree view under the selected folder and CanCreateFolder() is a function to check whether a folder can be created.

    public ICommand CreateFolderCommand
    {
        get
        {
            if (createFolderCommand == null)
            {
                createFolderCommand = new RelayCommand(CreateFolder, CanCreateFolder);
            }
            return createFolderCommand;
        }
    }

    private bool CanCreateFolder(object parameter)
    {
        if (parameter is FolderItem)
        {
            return true;
        }
        return false;
    }
    #endregion

What all things should I add in the following test case?

    [Test]
    public void CreateFolderCommandMainVMTest()
    {
        MainVm mainVM = new MainVm();

        RelayCommand command = (RelayCommand)mainVM.CreateFolderCommand;
        bool canCreateFolder = command.CanExecute(mainVM);
        Assert.Equals(canCreateFolder, true);
   }

Aucun commentaire:

Enregistrer un commentaire