microsoft / UnitTestBoilerplateGenerator

An extension for Visual Studio that generates a unit test boilerplate from a given class, setting up mocks for all dependencies. Supports NUnit, Visual Studio Test, Moq and SimpleStubs.
MIT License
158 stars 51 forks source link

NotSupportedException: Parameter type not supported when creating test file. #29

Closed d2lip closed 6 years ago

d2lip commented 6 years ago

Installed product versions

Steps to recreate

  1. Right click the file I want to create unit tests for
  2. Click on the boilerplate icon
  3. Select Test Project, Nunit and Moq

Current behavior

Throws exception:

System.NotSupportedException: Parameter type not supported

at UnitTestBoilerplate.Services.TestGenerationService.GetSimpleTypeName(TypeSyntax argumentType) in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 372

at UnitTestBoilerplate.Services.TestGenerationService.GetArgumentDescriptors(List`1 argumentList, SemanticModel semanticModel, MockFramework mockFramework) in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 316

at UnitTestBoilerplate.Services.TestGenerationService.d__9.MoveNext() in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 231

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.Services.TestGenerationService.d__17.MoveNext() in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 388

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.Services.TestGenerationService.d__6.MoveNext() in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 57

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.d__54.MoveNext() in C:\projects\unittestboilerplategenerator\src\ViewModel\CreateUnitTestBoilerplateViewModel.cs:line 181

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.<b__53_0>d.MoveNext() in C:\projects\unittestboilerplategenerator\src\ViewModel\CreateUnitTestBoilerplateViewModel.cs:line 166

Expected behavior

It should create the test file, I guess? :)

rCartoux commented 6 years ago

Could you share here the types of the arguments of the public methods of the class you want to create unit tests for?

d2lip commented 6 years ago

Sure, maybe there a couple more details for this class that can help too.

``

public class IdentitySearchProvider : BaseSearchProvider<ISearchResultDoorEvent>, IIdentitySearchProvider
{

    public IdentitySearchProvider(App.AccessControlGid identityId, EagleCs.TimeRange timeRange, IEnumerable<App.Gid> targetDevices, ISearchBase searchBase)
        : this(identityId, new IdentitySearchSession(), new SearchImageRequestor(), null, new Thumbnails.IdentityResultItemFactory(), timeRange, targetDevices, searchBase)
    {

    }

    public IdentitySearchProvider(App.AccessControlGid identityId, ISearchSession<ISearchResultDoorEvent> searchSession, ISearchImageRequestor imageRequestor, ISearchFacade facade, Thumbnails.IResultItemsFactory resultFactory, EagleCs.TimeRange timeRange, IEnumerable<App.Gid> targetDevices, ISearchBase searchBase, App.GuiManager guiManager = null)
        : base(searchSession, imageRequestor, facade, resultFactory, timeRange, targetDevices, searchBase)
    {

    }

    #region Overrides of BaseSearchProvider

    public override IEnumerable<Thumbnails.IResultItem> ReferenceResults
    {
        get
        {

        }
    }

    public override bool RemoveGroupWithId(object id)
    {
    }

    public override bool CanRemoveGroupWithId(object id)
    {

    }

    public override Task<Thumbnails.IBaseResultItem> LoadReferenceImage(App.DeviceGid sourceDevice, DateTime objectTime, System.Windows.Rect roi)
    {
    }

    public override ISearchParameters GetCurrentSearchParameters()
    {

    }

    public override Task StarredThumbnailsChanged(IEnumerable<Thumbnails.IStarringResultItem> addedItems, IEnumerable<Thumbnails.IStarringResultItem> removedItems)
    {

    }

    public override Task ResetSearch()
    {

    }

    public override bool UserConfirmedAction()
    {

    }

    public override bool CanUnstarLastResult()
    {

    }

    #endregion

    #region Overrides of BaseSearchProvider<ISearchResultDoorEvent>

    public override void Dispose()
    {

    }

    #endregion

    #region Implementation of IIdentitySearchProvider

    public bool FilterAccessDenied
    {
        get {  }
        set {  }
    }

    public bool FilterAccessGranted
    {
        get {  }
        set {  }
    }

    public bool ShouldShowOnlyAnalyticResults
    {
        get { }
        set { }
    }

    #endregion
}

``

d2lip commented 6 years ago

Also, I tried with other classes in that project and it works(but it didn't take my template changes), so there is something specific about this class.

All in all, seems like a great tool, hope to be able to use it soon!

rCartoux commented 6 years ago

Thanks! I believe your issue is not related to C++/CLI but rather to the usage of arguments with explicit namespace declaration like System.Windows.Rect; I have submitted a pull request

RandomEngy commented 6 years ago

Released 1.9.6 with this fix.

d2lip commented 6 years ago

Works like a charm now!

Thanks