-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test CastleClient using do not track-feature
- Loading branch information
1 parent
1970279
commit caed839
Showing
4 changed files
with
90 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/Tests/SetUp/CastleConfigurationDefaultCustomization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using AutoFixture; | ||
using Castle.Config; | ||
|
||
namespace Tests.SetUp | ||
{ | ||
public class CastleConfigurationDefaultCustomization : ICustomization | ||
{ | ||
public void Customize(IFixture fixture) | ||
{ | ||
fixture.Customize<CastleConfiguration>(composer => composer | ||
.OmitAutoProperties()); | ||
} | ||
} | ||
|
||
public class CastleConfigurationNoTrackCustomization : ICustomization | ||
{ | ||
public void Customize(IFixture fixture) | ||
{ | ||
fixture.Customize<CastleConfiguration>(composer => composer | ||
.OmitAutoProperties() | ||
.With(x => x.DoNotTrack, true)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Castle; | ||
using Castle.Messages.Requests; | ||
using FluentAssertions; | ||
using Tests.SetUp; | ||
using Xunit; | ||
|
||
namespace Tests | ||
{ | ||
public class When_calling_client | ||
{ | ||
// We can test the Castle client by making use of the Do Not Track feature, | ||
// which makes the client not send any real requests. | ||
|
||
[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] | ||
public void Should_authenticate(ActionRequest request, CastleClient sut) | ||
{ | ||
Func<Task> act = async () => await sut.Authenticate(request); | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] | ||
public void Should_track(ActionRequest request, CastleClient sut) | ||
{ | ||
Func<Task> act = async () => await sut.Track(request); | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] | ||
public void Should_get_user_devices(string userId, CastleClient sut) | ||
{ | ||
Func<Task> act = async () => await sut.GetDevicesForUser(userId); | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] | ||
public void Should_get_device(string deviceToken, CastleClient sut) | ||
{ | ||
Func<Task> act = async () => await sut.GetDevice(deviceToken); | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] | ||
public void Should_approve_device(string deviceToken, CastleClient sut) | ||
{ | ||
Func<Task> act = async () => await sut.ApproveDevice(deviceToken); | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] | ||
public void Should_start_impersonation(ImpersonateStartRequest request, CastleClient sut) | ||
{ | ||
Func<Task> act = async () => await sut.ImpersonateStart(request); | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] | ||
public void Should_end_impersonation(ImpersonateEndRequest request, CastleClient sut) | ||
{ | ||
Func<Task> act = async () => await sut.ImpersonateEnd(request); | ||
act.Should().NotThrow(); | ||
} | ||
} | ||
} |