Skip to content
Merged
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
2 changes: 2 additions & 0 deletions Internal/Xcepto.Internal.Http/Xcepto.Internal.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<RepositoryUrl>https://github.com/xcepto/Xcepto.NET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2025 themassiveone, Xcepto</Copyright>
<PackageIcon>xcepto256.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\..\media\xcepto256.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Samples.CleanupExecution.Tests.Adapters;

public class FailingInitAdapter: TrackableCleanupAdapter
{
protected override Task Initialize(IServiceProvider serviceProvider)
{
throw new Exception();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Samples.CleanupExecution.Tests.Adapters;

public class SuccessfulAdapter: TrackableCleanupAdapter
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Xcepto.Adapters;

namespace Samples.CleanupExecution.Tests.Adapters;

public abstract class TrackableCleanupAdapter: XceptoAdapter
{
public bool CleanedUp { get; private set; } = false;
protected override Task Cleanup(IServiceProvider serviceProvider)
{
CleanedUp = true;
return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="NUnit" Version="3.14.0"/>
<PackageReference Include="NUnit.Analyzers" Version="3.9.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Xcepto\Xcepto.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Xcepto.Builder;
using Xcepto.Data;
using Xcepto.Scenarios;

namespace Samples.CleanupExecution.Tests.Scenario;

public class FailingInitDoScenario : TrackableCleanupScenario
{
protected override ScenarioSetup Setup(ScenarioSetupBuilder builder) => builder.Build();

protected override ScenarioInitialization Initialize(ScenarioInitializationBuilder builder) => builder
.Do(_ => throw new Exception())
.Build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Xcepto.Builder;
using Xcepto.Data;
using Xcepto.Scenarios;

namespace Samples.CleanupExecution.Tests.Scenario;

public class FailingInitFireScenario : TrackableCleanupScenario
{
protected override ScenarioSetup Setup(ScenarioSetupBuilder builder) => builder.Build();

protected override ScenarioInitialization Initialize(ScenarioInitializationBuilder builder) => builder
.FireAndForget(_ => throw new Exception())
.Build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Xcepto.Builder;
using Xcepto.Data;

namespace Samples.CleanupExecution.Tests.Scenario;

public class SuccessfulScenario: TrackableCleanupScenario
{
protected override ScenarioSetup Setup(ScenarioSetupBuilder builder) => builder.Build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Xcepto.Builder;
using Xcepto.Data;
using Xcepto.Scenarios;

namespace Samples.CleanupExecution.Tests.Scenario;

public abstract class TrackableCleanupScenario : XceptoScenario
{
public bool CleanupRan { get; private set; } = false;
protected override ScenarioCleanup Cleanup(ScenarioCleanupBuilder builder) => builder
.Do(() => CleanupRan = true)
.Build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Samples.CleanupExecution.Tests.Adapters;
using Samples.CleanupExecution.Tests.Scenario;
using Xcepto;
using Xcepto.Exceptions;
using Xcepto.Strategies;
using Xcepto.Strategies.Execution;

namespace Samples.CleanupExecution.Tests.Test;


[TestFixtureSource(typeof(StrategyCombinations), nameof(StrategyCombinations.AllCombinations))]
public class AdapterCleanupTests
{
private readonly XceptoTest _test;
public AdapterCleanupTests(BaseExecutionStrategy executionStrategy)
{
_test = new XceptoTest(executionStrategy);
}


[Test]
public async Task SuccessfulAdapter_CleanedUp()
{
var adapter = new SuccessfulAdapter();
await _test.GivenWithStrategies(new SuccessfulScenario(), builder =>
{
builder.RegisterAdapter(adapter);
});

Assert.That(adapter.CleanedUp, Is.True);
}

[Test]
public void FailingInitAdapter_CleanedUp()
{
var adapter = new FailingInitAdapter();
Assert.That(async () =>
{
await _test.GivenWithStrategies(new SuccessfulScenario(), builder =>
{
builder.RegisterAdapter(adapter);
});
}, Throws.InstanceOf<AdapterInitException>());

Assert.That(adapter.CleanedUp, Is.True);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Samples.CleanupExecution.Tests.Scenario;
using Xcepto;
using Xcepto.Exceptions;
using Xcepto.Strategies;
using Xcepto.Strategies.Execution;

namespace Samples.CleanupExecution.Tests.Test;

[TestFixtureSource(typeof(StrategyCombinations), nameof(StrategyCombinations.AllCombinations))]
public class ScenarioCleanupTests
{
private readonly XceptoTest _test;
public ScenarioCleanupTests(BaseExecutionStrategy executionStrategy)
{
_test = new XceptoTest(executionStrategy);
}

[Test]
public async Task CleanupHappens_OnSuccessfulRun()
{
SuccessfulScenario scenario = new SuccessfulScenario();
await _test.GivenWithStrategies(scenario, _ => { });

Assert.That(scenario.CleanupRan, Is.True);
}

[Test]
public void CleanupHappens_OnFailingScenarioInitDo()
{
FailingInitDoScenario scenario = new FailingInitDoScenario();

Assert.That(async () =>
{
await _test.GivenWithStrategies(scenario, _ => { });
}, Throws.InstanceOf<ScenarioInitException>());

Assert.That(scenario.CleanupRan, Is.True);
}

[Test]
public void CleanupHappens_OnFailingScenarioInitFire()
{
FailingInitFireScenario scenario = new FailingInitFireScenario();

Assert.That(async () =>
{
await _test.GivenWithStrategies(scenario, _ => { });
}, Throws.InstanceOf<ScenarioInitException>());

Assert.That(scenario.CleanupRan, Is.True);
}
}
10 changes: 10 additions & 0 deletions Xcepto.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExceptionDetail", "Exceptio
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.ExceptionDetail.Tests", "Samples\ExceptionDetail\Samples.ExceptionDetail.Tests\Samples.ExceptionDetail.Tests.csproj", "{A1F50247-A6CB-479E-98C8-1E3AC815C0E6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CleanupExecution", "CleanupExecution", "{AA06077D-7B5D-41BC-8822-7FA52BC15191}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.CleanupExecution.Tests", "Samples\CleanupExecution\Samples.CleanupExecution.Tests\Samples.CleanupExecution.Tests.csproj", "{64BC5387-B5C0-4BFE-A5FD-B837B9D983DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -136,6 +140,10 @@ Global
{A1F50247-A6CB-479E-98C8-1E3AC815C0E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1F50247-A6CB-479E-98C8-1E3AC815C0E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1F50247-A6CB-479E-98C8-1E3AC815C0E6}.Release|Any CPU.Build.0 = Release|Any CPU
{64BC5387-B5C0-4BFE-A5FD-B837B9D983DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64BC5387-B5C0-4BFE-A5FD-B837B9D983DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64BC5387-B5C0-4BFE-A5FD-B837B9D983DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64BC5387-B5C0-4BFE-A5FD-B837B9D983DC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BABA2E33-65CD-4EB3-8FDC-3DF7B2DC2EAD} = {1C2E2691-2BCB-4F59-9222-DDA2C58EC928}
Expand All @@ -159,5 +167,7 @@ Global
{4315D42A-16FC-438E-8439-238FAB7FC248} = {31BF92D6-8D80-4E2C-8B58-2E212C86F5A2}
{33A8048C-6324-475C-AC7F-F27B47805228} = {1C2E2691-2BCB-4F59-9222-DDA2C58EC928}
{A1F50247-A6CB-479E-98C8-1E3AC815C0E6} = {33A8048C-6324-475C-AC7F-F27B47805228}
{AA06077D-7B5D-41BC-8822-7FA52BC15191} = {1C2E2691-2BCB-4F59-9222-DDA2C58EC928}
{64BC5387-B5C0-4BFE-A5FD-B837B9D983DC} = {AA06077D-7B5D-41BC-8822-7FA52BC15191}
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions Xcepto.NewtonsoftJson/Xcepto.NewtonsoftJson.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<RepositoryUrl>https://github.com/xcepto/Xcepto.NET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2025 themassiveone, Xcepto</Copyright>
<PackageIcon>xcepto256.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\media\xcepto256.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Xcepto.Rest/Xcepto.Rest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<RepositoryUrl>https://github.com/xcepto/Xcepto.NET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2025 themassiveone, Xcepto</Copyright>
<PackageIcon>xcepto256.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\media\xcepto256.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Xcepto.SSR/Xcepto.SSR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<RepositoryUrl>https://github.com/xcepto/Xcepto.NET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2025 themassiveone, Xcepto</Copyright>
<PackageIcon>xcepto256.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\media\xcepto256.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Xcepto.Testcontainers/Xcepto.Testcontainers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<RepositoryUrl>https://github.com/xcepto/Xcepto.NET</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2025 themassiveone, Xcepto</Copyright>
<PackageIcon>xcepto256.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\media\xcepto256.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading