Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions HttpMock.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpMock.Verify.NUnit", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpMock.Logging.Log4Net", "src\HttpMock.Logging.Log4Net\HttpMock.Logging.Log4Net.csproj", "{873E4657-ED89-4B3A-B2F2-82B183AB358C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ci", "ci", "{AB33A74A-FBFF-4598-855E-1BD6014F0CE3}"
ProjectSection(SolutionItems) = preProject
azure-pipelines.yml = azure-pipelines.yml
buildpackage.ps1 = buildpackage.ps1
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

pool:
vmImage: 'VS2017-Win2016'
vmImage: 'windows-2019'

variables:
solution: '**/*.sln'
Expand Down
4 changes: 2 additions & 2 deletions src/HttpMock.Integration.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion src/HttpMock.Logging.Log4Net/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
2 changes: 1 addition & 1 deletion src/HttpMock.Unit.Tests/BufferedConsumerTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
using NUnit.Framework;

Expand Down
227 changes: 122 additions & 105 deletions src/HttpMock.Unit.Tests/EndpointMatchingRuleTests.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/HttpMock.Unit.Tests/HttpMock.Unit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Rhino.Mocks">
<HintPath>..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll</HintPath>
<Reference Include="Moq">
<HintPath>..\..\packages\Moq.4.20.1\lib\netstandard2.0\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
20 changes: 11 additions & 9 deletions src/HttpMock.Unit.Tests/RequestProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Kayak;
using Kayak.Http;
using NUnit.Framework;
using Rhino.Mocks;
using Moq;

namespace HttpMock.Unit.Tests {
[TestFixture]
Expand All @@ -18,16 +18,18 @@ public class RequestProcessorTests

[SetUp]
public void SetUp() {
_processor = new RequestProcessor(_ruleThatReturnsFirstHandler, new RequestHandlerList());
_requestHandlerFactory = new RequestHandlerFactory(_processor);
_dataProducer = MockRepository.GenerateStub<IDataProducer>();
_httpResponseDelegate = MockRepository.GenerateStub<IHttpResponseDelegate>();
var ruleFirstHandlerMock = new Mock<IMatchingRule>();
ruleFirstHandlerMock.Setup(x => x.IsEndpointMatch(It.IsAny<object>(), It.IsAny<HttpRequestHead>())).Returns(true);
_ruleThatReturnsFirstHandler = ruleFirstHandlerMock.Object;

_ruleThatReturnsFirstHandler = MockRepository.GenerateStub<IMatchingRule>();
_ruleThatReturnsFirstHandler.Stub(x => x.IsEndpointMatch(null, new HttpRequestHead())).IgnoreArguments().Return(true).Repeat.Once();
var ruleNoHandlersMock = new Mock<IMatchingRule>();
ruleNoHandlersMock.Setup(x => x.IsEndpointMatch(It.IsAny<object>(), It.IsAny<HttpRequestHead>())).Returns(false);
_ruleThatReturnsNoHandlers = ruleNoHandlersMock.Object;

_ruleThatReturnsNoHandlers = MockRepository.GenerateStub<IMatchingRule>();
_ruleThatReturnsNoHandlers.Stub(x => x.IsEndpointMatch(null, new HttpRequestHead())).IgnoreArguments().Return(false);
_processor = new RequestProcessor(_ruleThatReturnsFirstHandler, new RequestHandlerList());
_requestHandlerFactory = new RequestHandlerFactory(_processor);
_dataProducer = new Mock<IDataProducer>().Object;
_httpResponseDelegate = new Mock<IHttpResponseDelegate>().Object;
}

[Test]
Expand Down
5 changes: 2 additions & 3 deletions src/HttpMock.Unit.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kayak" version="0.7.2" />
<package id="NUnit" version="3.13.1" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.13.0" targetFramework="net45" />
<package id="RhinoMocks" version="3.6.1" requireReinstallation="True" />
<package id="NUnit" version="3.13.1" requireReinstallation="True" />
<package id="Moq" version="4.20.1" />
</packages>
4 changes: 2 additions & 2 deletions src/HttpMock.Verify.NUnit/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -37,4 +37,4 @@
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
48 changes: 48 additions & 0 deletions upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Upgrade Plan: HttpMock to .NET 8

Always use Test Drven Development.
## User Instructions


1. Upgrade the entire project to .NET 8.
2. Remove the Kayak dependency completely.
3. Preserve all tests. Do not change any test code.
4. Run all the tests after making changes
5. Make small changes
6. Commit changes when tests pass
7. Run tests before making changes so that all the tests pass
8. Do not change test behaviour
9. Maintain the behaviour of interfaces that are used in test. Change the parameters of the interfaces to remove Kayak dependencies, but ensure that the interfaces still behave the same way.
10. Change the RhinoMocks to use Moq

### 1. Project Upgrade
- Create a Dockerfile to build and test the project in a container. Use an image .Net framework 4.8 first, then upgrade to .NET 8.
- Convert all `.csproj` files to SDK-style format.
- Change target framework to `net8.0` for all projects.
- Remove any legacy or obsolete settings from project files.
- Ensure all dependencies are compatible with .NET 8.

### 2. Remove Kayak
- Remove Kayak references from all `.csproj` and `packages.config` files.
- Remove all `using Kayak` and `using Kayak.Http` statements from code.
- Refactor the HTTP server implementation to use `HttpListner' (primarily in `HttpServer.cs`) to use a modern .NET 8 HTTP servers.
- Update or replace any code that depends on Kayak types or APIs.
- Don't break any of the interfaces

### 3. Preserve Tests
- Do not modify any test logic or files.
- Ensure tests still reference the main library and run under .NET 8.

### 4. Build & Test
- Update build/test scripts (e.g., Azure Pipelines, PowerShell) to use .NET 8 if needed.
- Verify that all tests pass after the upgrade and refactor.

### 5. Keep a journal

- Keep a journal of all changes made to journal.md

---

**Note:**
- The main focus is to modernize the codebase and remove Kayak, while keeping the test suite unchanged and fully functional.
- The HTTP server implementation will need the most attention, as it is tightly coupled to Kayak in the current codebase.
Loading