hibri / HttpMock

A library for creating Http servers on the fly in tests and stubbing responses
MIT License
128 stars 44 forks source link

NuGet dependency on Kayak should be versioned (was: Kayak causing System.TypeLoadException) #34

Closed oschwald closed 9 years ago

oschwald commented 9 years ago

This is a follow-up to my comment in #18. I created a test repo with a project that exhibits the issue for me with VS 2015. The dependencies were all installed with NuGet.

The full output when run by the NUnit runner is:

Test Name:  SUT_should_return_stubbed_response
Test FullName:  ClassLibrary1.Class1.SUT_should_return_stubbed_response
Test Source:    c:\users\gregory\documents\visual studio 2015\Projects\ClassLibrary2\ClassLibrary2\Class1.cs : line 15
Test Outcome:   Failed
Test Duration:  0:00:00.039

Result StackTrace:  
at HttpMock.HttpServer..ctor(Uri uri)
at HttpMock.HttpServerFactory.Create(Uri uri) in c:\dev\HttpMock\src\HttpMock\HttpServerFactory.cs:line 23
at HttpMock.HttpServerFactory.Get(Uri uri) in c:\dev\HttpMock\src\HttpMock\HttpServerFactory.cs:line 16
at HttpMock.HttpMockRepository.At(Uri uri) in c:\dev\HttpMock\src\HttpMock\HttpMockRepository.cs:line 19
at HttpMock.HttpMockRepository.At(String uri) in c:\dev\HttpMock\src\HttpMock\HttpMockRepository.cs:line 14
at ClassLibrary1.Class1.SUT_should_return_stubbed_response() in c:\users\gregory\documents\visual studio 2015\Projects\ClassLibrary2\ClassLibrary2\Class1.cs:line 16
Result Message: System.TypeLoadException : Could not load type 'Kayak.KayakScheduler' from assembly 'Kayak, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
hibri commented 9 years ago

@oschwald Thanks for creating the test repo. Noticed that you had an older version of kayak in the packages.config.

https://github.com/oschwald/http-mock-test/blob/master/ClassLibrary2/packages.config#L4 The default package install of HttpMock pulls in the latest version of Kayak is 0.7.2

oschwald commented 9 years ago

I just created that solution for this and I installed HttpMock through NuGet. I did not install Kayak directly. Looking at the HttpMock NuGet page, there isn't a versioned dependency on Kayak. Maybe it would be worth updating that. I confirmed that upgrading Kayak to the latest version does fix the issue.

hibri commented 9 years ago

The issue is fixed in the latest version. The type wasn't there in the old version. The latest version of Kayak predates HttpMock. HttpMock was always written against 0.7.2

Nuget should pull in the latest version, not sure why it didn't in this case.

oschwald commented 9 years ago

NuGet failed to pull the latest version both for this test project and my use in a real project. Is there a reason not to add a minimum version to the .nuspec to prevent this in the future?

hibri commented 9 years ago

Nope don't see a reason, and will add it. Feel free to raise a PR too.

oschwald commented 9 years ago

Per the NuGet v3 documentation, "NuGet restores the lowest possible version of a package as defined by its dependencies." However, I will close this issue given the above discussion.