Skip to content

Commit

Permalink
Using FunctionStoreFactory in in-memory tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stidsborg committed Aug 10, 2024
1 parent f8b8bf6 commit a5f90ef
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using Cleipnir.ResilientFunctions.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cleipnir.ResilientFunctions.Tests.InMemoryTests;
Expand All @@ -8,25 +9,25 @@ public class EffectStoreTests : Cleipnir.ResilientFunctions.Tests.TestTemplates.
{
[TestMethod]
public override Task SunshineScenarioTest()
=> SunshineScenarioTest(FunctionStoreFactory.CreateEffectStore());
=> SunshineScenarioTest(FunctionStoreFactory.Create().SelectAsync(fs => fs.EffectsStore));

[TestMethod]
public override Task SingleEffectWithResultLifeCycle()
=> SingleEffectWithResultLifeCycle(FunctionStoreFactory.CreateEffectStore());
=> SingleEffectWithResultLifeCycle(FunctionStoreFactory.Create().SelectAsync(fs => fs.EffectsStore));

[TestMethod]
public override Task SingleFailingEffectLifeCycle()
=> SingleFailingEffectLifeCycle(FunctionStoreFactory.CreateEffectStore());
=> SingleFailingEffectLifeCycle(FunctionStoreFactory.Create().SelectAsync(fs => fs.EffectsStore));

[TestMethod]
public override Task EffectCanBeDeleted()
=> EffectCanBeDeleted(FunctionStoreFactory.CreateEffectStore());
=> EffectCanBeDeleted(FunctionStoreFactory.Create().SelectAsync(fs => fs.EffectsStore));

[TestMethod]
public override Task DeleteFunctionIdDeletesAllRelatedEffects()
=> DeleteFunctionIdDeletesAllRelatedEffects(FunctionStoreFactory.CreateEffectStore());
=> DeleteFunctionIdDeletesAllRelatedEffects(FunctionStoreFactory.Create().SelectAsync(fs => fs.EffectsStore));

[TestMethod]
public override Task TruncateDeletesAllEffects()
=> TruncateDeletesAllEffects(FunctionStoreFactory.CreateEffectStore());
=> TruncateDeletesAllEffects(FunctionStoreFactory.Create().SelectAsync(fs => fs.EffectsStore));
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ public static class FunctionStoreFactory
{
public static Task<IFunctionStore> Create()
=> new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask();

public static Task<IEffectsStore> CreateEffectStore()
=> Create().SelectAsync(fs => fs.EffectsStore);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ public class DoubleInvocationTests : Cleipnir.ResilientFunctions.Tests.TestTempl
{
[TestMethod]
public override Task SecondInvocationWaitsForAndReturnsSuccessfulResult()
=> SecondInvocationWaitsForAndReturnsSuccessfulResult(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SecondInvocationWaitsForAndReturnsSuccessfulResult(FunctionStoreFactory.Create());

[TestMethod]
public override Task SecondInvocationFailsOnSuspendedFlow()
=> SecondInvocationFailsOnSuspendedFlow(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SecondInvocationFailsOnSuspendedFlow(FunctionStoreFactory.Create());

[TestMethod]
public override Task SecondInvocationFailsOnPostponedFlow()
=> SecondInvocationFailsOnPostponedFlow(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SecondInvocationFailsOnPostponedFlow(FunctionStoreFactory.Create());

[TestMethod]
public override Task SecondInvocationFailsOnFailedFlow()
=> SecondInvocationFailsOnFailedFlow(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SecondInvocationFailsOnFailedFlow(FunctionStoreFactory.Create());
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,41 @@ public class EffectTests : Cleipnir.ResilientFunctions.Tests.TestTemplates.RFunc
{
[TestMethod]
public override Task SunshineActionTest()
=> SunshineActionTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SunshineActionTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task SunshineAsyncActionTest()
=> SunshineAsyncActionTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SunshineAsyncActionTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task SunshineFuncTest()
=> SunshineFuncTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SunshineFuncTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task SunshineAsyncFuncTest()
=> SunshineAsyncFuncTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> SunshineAsyncFuncTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task ExceptionThrowingActionTest()
=> ExceptionThrowingActionTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> ExceptionThrowingActionTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task TaskWhenAnyFuncTest()
=> TaskWhenAnyFuncTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> TaskWhenAnyFuncTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task TaskWhenAllFuncTest()
=> TaskWhenAllFuncTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> TaskWhenAllFuncTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task ClearEffectsTest()
=> ClearEffectsTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> ClearEffectsTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task EffectsCrudTest()
=> EffectsCrudTest(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> EffectsCrudTest(FunctionStoreFactory.Create());

[TestMethod]
public override Task ExistingEffectsFuncIsOnlyInvokedAfterGettingValue()
=> ExistingEffectsFuncIsOnlyInvokedAfterGettingValue(new InMemoryFunctionStore().CastTo<IFunctionStore>().ToTask());
=> ExistingEffectsFuncIsOnlyInvokedAfterGettingValue(FunctionStoreFactory.Create());
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ public class TimeoutStoreTests : TestTemplates.TimeoutStoreTests
{
[TestMethod]
public override Task TimeoutCanBeCreatedFetchedAndRemoveSuccessfully()
=> TimeoutCanBeCreatedFetchedAndRemoveSuccessfully(new InMemoryTimeoutStore().CastTo<ITimeoutStore>().ToTask());
=> TimeoutCanBeCreatedFetchedAndRemoveSuccessfully(FunctionStoreFactory.Create().SelectAsync(fs => fs.TimeoutStore));

[TestMethod]
public override Task ExistingTimeoutCanUpdatedSuccessfully()
=> ExistingTimeoutCanUpdatedSuccessfully(new InMemoryTimeoutStore().CastTo<ITimeoutStore>().ToTask());
=> ExistingTimeoutCanUpdatedSuccessfully(FunctionStoreFactory.Create().SelectAsync(fs => fs.TimeoutStore));

[TestMethod]
public override Task OverwriteFalseDoesNotAffectExistingTimeout()
=> OverwriteFalseDoesNotAffectExistingTimeout(new InMemoryTimeoutStore().CastTo<ITimeoutStore>().ToTask());
=> OverwriteFalseDoesNotAffectExistingTimeout(FunctionStoreFactory.Create().SelectAsync(fs => fs.TimeoutStore));

[TestMethod]
public override Task RegisteredTimeoutIsReturnedFromRegisteredTimeouts()
=> RegisteredTimeoutIsReturnedFromRegisteredTimeouts(new InMemoryTimeoutStore().CastTo<ITimeoutStore>().ToTask());
=> RegisteredTimeoutIsReturnedFromRegisteredTimeouts(FunctionStoreFactory.Create().SelectAsync(fs => fs.TimeoutStore));

[TestMethod]
public override Task TimeoutStoreCanBeInitializedMultipleTimes()
=> TimeoutStoreCanBeInitializedMultipleTimes(new InMemoryTimeoutStore().CastTo<ITimeoutStore>().ToTask());
=> TimeoutStoreCanBeInitializedMultipleTimes(FunctionStoreFactory.Create().SelectAsync(fs => fs.TimeoutStore));

[TestMethod]
public override Task RegisteredTimeoutIsReturnedFromRegisteredTimeoutsForFunctionId()
=> RegisteredTimeoutIsReturnedFromRegisteredTimeoutsForFunctionId(new InMemoryTimeoutStore().CastTo<ITimeoutStore>().ToTask());
=> RegisteredTimeoutIsReturnedFromRegisteredTimeoutsForFunctionId(FunctionStoreFactory.Create().SelectAsync(fs => fs.TimeoutStore));

[TestMethod]
public override Task TimeoutIsNotRegisteredAgainWhenProviderAlreadyContainsTimeout()
=> TimeoutIsNotRegisteredAgainWhenProviderAlreadyContainsTimeout(new InMemoryTimeoutStore().CastTo<ITimeoutStore>().ToTask());
=> TimeoutIsNotRegisteredAgainWhenProviderAlreadyContainsTimeout(FunctionStoreFactory.Create().SelectAsync(fs => fs.TimeoutStore));

[TestMethod]
public override Task CancellingNonExistingTimeoutDoesNotResultInIO()
Expand Down

0 comments on commit a5f90ef

Please sign in to comment.