diff --git a/src/Tests/SetUp/AutoFakeDataAttribute.cs b/src/Tests/SetUp/AutoFakeDataAttribute.cs index 7cc1134..cf8a368 100644 --- a/src/Tests/SetUp/AutoFakeDataAttribute.cs +++ b/src/Tests/SetUp/AutoFakeDataAttribute.cs @@ -39,7 +39,7 @@ public static class Customizations { public static CompositeCustomization Get() => new CompositeCustomization( new AutoNSubstituteCustomization(), - new CastleConfigurationCustomization() + new CastleConfigurationDefaultCustomization() ); } } diff --git a/src/Tests/SetUp/CastleConfigurationCustomization.cs b/src/Tests/SetUp/CastleConfigurationCustomization.cs deleted file mode 100644 index 40d496a..0000000 --- a/src/Tests/SetUp/CastleConfigurationCustomization.cs +++ /dev/null @@ -1,13 +0,0 @@ -using AutoFixture; -using Castle.Config; - -namespace Tests.SetUp -{ - public class CastleConfigurationCustomization : ICustomization - { - public void Customize(IFixture fixture) - { - fixture.Customize(composer => composer.OmitAutoProperties()); - } - } -} diff --git a/src/Tests/SetUp/CastleConfigurationDefaultCustomization.cs b/src/Tests/SetUp/CastleConfigurationDefaultCustomization.cs new file mode 100644 index 0000000..6964d1e --- /dev/null +++ b/src/Tests/SetUp/CastleConfigurationDefaultCustomization.cs @@ -0,0 +1,24 @@ +using AutoFixture; +using Castle.Config; + +namespace Tests.SetUp +{ + public class CastleConfigurationDefaultCustomization : ICustomization + { + public void Customize(IFixture fixture) + { + fixture.Customize(composer => composer + .OmitAutoProperties()); + } + } + + public class CastleConfigurationNoTrackCustomization : ICustomization + { + public void Customize(IFixture fixture) + { + fixture.Customize(composer => composer + .OmitAutoProperties() + .With(x => x.DoNotTrack, true)); + } + } +} diff --git a/src/Tests/When_calling_client.cs b/src/Tests/When_calling_client.cs new file mode 100644 index 0000000..14daea1 --- /dev/null +++ b/src/Tests/When_calling_client.cs @@ -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 act = async () => await sut.Authenticate(request); + act.Should().NotThrow(); + } + + [Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] + public void Should_track(ActionRequest request, CastleClient sut) + { + Func act = async () => await sut.Track(request); + act.Should().NotThrow(); + } + + [Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] + public void Should_get_user_devices(string userId, CastleClient sut) + { + Func act = async () => await sut.GetDevicesForUser(userId); + act.Should().NotThrow(); + } + + [Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] + public void Should_get_device(string deviceToken, CastleClient sut) + { + Func act = async () => await sut.GetDevice(deviceToken); + act.Should().NotThrow(); + } + + [Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] + public void Should_approve_device(string deviceToken, CastleClient sut) + { + Func act = async () => await sut.ApproveDevice(deviceToken); + act.Should().NotThrow(); + } + + [Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] + public void Should_start_impersonation(ImpersonateStartRequest request, CastleClient sut) + { + Func act = async () => await sut.ImpersonateStart(request); + act.Should().NotThrow(); + } + + [Theory, AutoFakeData(typeof(CastleConfigurationNoTrackCustomization))] + public void Should_end_impersonation(ImpersonateEndRequest request, CastleClient sut) + { + Func act = async () => await sut.ImpersonateEnd(request); + act.Should().NotThrow(); + } + } +}