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

System.InvalidOperationException: Sequence contains no matching element #4

Closed ravensorb closed 7 years ago

ravensorb commented 7 years ago

Installed product versions

System.InvalidOperationException: Sequence contains no matching element

Steps to recreate

Not sure as it seems to happen only on some classes even if the class is almost identical to one that work

Current behavior

---------------------------

---------------------------
System.InvalidOperationException: Sequence contains no matching element

   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)

   at UnitTestBoilerplate.CreateUnitTestBoilerplateViewModel.<GenerateUnitTestContentsFromFileAsync>d__20.MoveNext() in C:\projects\unittestboilerplategenerator\src\CreateUnitTestBoilerplateViewModel.cs:line 258

--- 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.CreateUnitTestBoilerplateViewModel.<GenerateUnitTestFromProjectItemSummaryAsync>d__19.MoveNext() in C:\projects\unittestboilerplategenerator\src\CreateUnitTestBoilerplateViewModel.cs:line 162

--- 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.CreateUnitTestBoilerplateViewModel.<<get_CreateUnitTestCommand>b__18_0>d.MoveNext() in C:\projects\unittestboilerplategenerator\src\CreateUnitTestBoilerplateViewModel.cs:line 118
---------------------------
OK   
---------------------------
RandomEngy commented 7 years ago

Can you post a class that causes this crash?

RandomEngy commented 7 years ago

Ahh I think I figured it out. If you have a simple type like int as a constructor parameter it does that. I can update to be resilient to that.

RandomEngy commented 7 years ago

Fixed in 1.4.5, now leaves "TODO" when there is a constructor parameter with a simple type.