Skip to content

Commit

Permalink
memory provider idempotency updates (#25)
Browse files Browse the repository at this point in the history
* memory provider updates

* Delete test/WorkflowCore.UnitTests/MemoryPersistenceProviderTests/MemoryPersistenceProviderTests.cs

---------

Co-authored-by: Sergii Kram <sergiikram@outlook.com>
  • Loading branch information
starushykart and SergiiKram committed May 10, 2024
1 parent fdc6109 commit b7fe607
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Runtime.Serialization;

namespace WorkflowCore.Persistence.EntityFramework.Exceptions
namespace WorkflowCore.Exceptions
{
public class WorkflowExistsException : Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using WorkflowCore.Exceptions;
using WorkflowCore.Interface;
using WorkflowCore.Models;

Expand Down Expand Up @@ -30,6 +31,11 @@ public async Task<string> CreateNewWorkflow(WorkflowInstance workflow, Cancellat
{
lock (_instances)
{
if (workflow.Reference != null && _instances.Any(x => x.Reference == workflow.Reference))
{
throw new WorkflowExistsException();
}

workflow.Id = Guid.NewGuid().ToString();
_instances.Add(workflow);
return workflow.Id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using WorkflowCore.Persistence.EntityFramework.Exceptions;
using WorkflowCore.Exceptions;
using WorkflowCore.Persistence.EntityFramework.Models;
using WorkflowCore.Persistence.EntityFramework.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using WorkflowCore.Exceptions;
using WorkflowCore.IntegrationTests.Scenarios;
using WorkflowCore.Interface;
using WorkflowCore.Models;
using WorkflowCore.Persistence.EntityFramework.Exceptions;
using WorkflowCore.Persistence.EntityFramework.Interfaces;
using WorkflowCore.Testing;
using Xunit;
Expand Down

0 comments on commit b7fe607

Please sign in to comment.