The issue here is that the elsa.db for sqlite is going in the same
path every time. Depending on the order in which tests are run,
sometimes it means that migrations are run on a DB which is
expected to be empty but which already exists. That causes an
error & test failure.
Here I've just used temp folders to ensure that the DB file is in a
different path every time.
One of these tests is failing and this is the one which
demonstrates issue #738. The composite activity which begins
with ReceiveSignal doesn't generate a trigger.
This extension method is quite complex and is frustrating
when a unit test passes-through it. That's because extension
methods can't be mocked in tests.
The triggers-for-activity-blueprint functionality
is quite complex just on its own, so I have moved this to
a new service.
Once again the integration test which is left behind proves
that it still does the same job.
As stated in the comments for
WorkflowMayContainDuplicateActivitiesIntegrationTests
These tests might not describe actually-desired behaviour.
If they begin to "get in the way" in future, then it would
probably be safe to remove them.
As well as providing a unit test which matches other persistence
provider tests (round-tripping a workflow instance), two other tests
are included here:
* When using the default DI registration extension method, this sets
up pooling of DB contexts and so a resolved context will come from
the pool.
* When using the non-pooled DI registration extension method, this
sets up EF without pooling, which is more useful in a multi-tenanted
environment.
There are also some other changes in this commit corresponding to
improving the tests. Mainly de-duplicating logic & improving names.
This also includes a change to the workflow used in the test-case.
There are quite complex reasons for this, as explained here:
https://github.com/elsa-workflows/elsa-core/issues/728#issuecomment-794319236
The real crux of it is that the workflow must have an activity
which suspends it, and that activity that suspends the workflow
must not be the starting activity. This is why I added an unused
set-variable activity as the starter.
This commit shows that the various persistence test cases _mostly_
work OK, with the one exception of ActivityExecuted.
This test case shows that in-memory persistence is
also affected. It seems that that would mean that this
issue is not related to only a single persistence provider.
In fact, in retrospect this is not really a persistence
problem at all, but a problem with the test case. More
information is available in the comments to #728.
Actually, this unit test does not repro the issue.
Frustratingly I can't get it to save the executed workflow
into MongoDB at all. I see workflow execution logs
being saved, but the instance doesn't go in.
I'm not sure if this is a mistake I'm making or whether
I have found a different bug of some sort.
This refactor of integration test logic is to boost its
reusability. Moving some functionality to attributes &
customization classes means I can reuse elsewhere without
duplication.
Temporal activities no longer have a generalised extension method
for registering them with a service collecton. It is still static and has
the same rough shape as an extension method. This way it is less
visible and less likely to be called by accident.
Also in-line with changes in this branch, things have been renamed
Timers → Temporal
It actually turns out that no change is required to the SignalReceived
activity in order to achieve this. As these unit tests prove & document,
that is already the current behaviour.
Adds an XUnit test logger to each test csproj
file (will be used by test script).
Also add a skeleton SonarCloud analysis config file with a couple
of settings for starters: Don't analyse exception classes or samples
for coverage.
This reverts commit 3dc1b79b3b, reversing
changes made to 1dbafd8ba2.
The previous merge of work on #665 broke the build so this commit
reverts it back out.
Adds an XUnit test logger to each test csproj
file (will be used by test script).
Also add a skeleton SonarCloud analysis config file with a couple
of settings for starters: Don't analyse exception classes or samples
for coverage.
* WIP #653 - Delete two tests
These two couldn't easily be fixed, in both cases they were
integration tests which involved passing through many classes.
It wasn't immediately clear what needed to be done to fix them.
As noted in the issue description, removing them was an
acceptable fix.
* WIP #653 - Fix a failing test
I split this test into two. Per the discussion at:
https://github.com/xunit/xunit/issues/350
XUnit seems quite opinonated about not having assertion messages.
Thus, without changing assertion library (which deserves discussion
before I just do it), the logical next best thing is to split into two
single-assert tests, so it's clear which assertion failed on a test
failure.
Also, I moved the AutoMoqData attribute to the shared test lib, so
that it can be used anywhere. That allowed me to eliminate the
constructor for this test class, except for initialising the base class.
* Provisionally resolve#653 - reinstate tests in CI
This should complete the issue although we need to see a
passing CI build with this code change before we can say
it's done.
* Provisionally resolves#653 - Add test script
* Trivial - Add VS Code workspace
* Trivial - Add VSCode build task & extra ignore
On GNU/Linux, auto-generated .directory
files should be ignored.
* WIP #485 - Boilerplate for unit test project
* WIP #485 - Add test coverage (Remove/RemoveAll)
* WIP #485 - Implement RemoveAll
* Remove redundant logic, covered by IDictionary
Per the following, the contract for a generic IDictionary,
the Remove method already deals with non-existent keys.
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.idictionary-2.remove?view=net-5.0#System_Collections_Generic_IDictionary_2_Remove__0_
* Resolve#485 - Add PurgeVariables methods
These are convenience methods upon ActivityExecutionContext
and WorkflowExecutionContext, consistent with their current APIs.
Also in this commit are tests for those simple methods.
There's a bit of test-scaffold as well included, such as:
* Autofixture Xunit2 integration
* New project for unit tests
* Customize attribute for avoiding crashes on Autofixture recursion
* Reusable specimen builder for creating IServiceProvider which
resolves services from Autofixture
* Custonize attribute for a parameter to use that ^^ specimen builder
* Activity picker dialog
* Activity picker
* Activity editor
* Activity property fields
* Blazor bindings for Elsa designer
* Only index triggers from published & enabled workflow definitions
* Handle case of null workflow blueprint not found
* Add check for zero duration and general scheduler exceptions
* Don't rethrow expression evaluation failure
* Workflow definition settings editor modal
* Integration between stencil and blazor 🎉
* Fix expression type conversion
* Add publish button and restructure components
* Fix up workflow definition ID vs workflow definition version ID
* Update EF Core migrations
* Fix Workflow Publisher
* Fix version display
* Add Import menu item
* Initial version of workflow reviver
* Fix DI things
* Rename workflow builder parameter to `builder`
* Update EF Core stores to use short-lived db contexts
* Update serializer to use new settings to reset ID seed
* Write fault details
* Add faulty workflows sample project
* Switch to free & open source Z.EntityFramework.Plus.EFCore
* Add content type header
* Fix call to virtual OnSaving/OnLoading
* Fix retry
Before this change, the aforementioned activities would always schedule the Done outcome.
After this change, the Done outcome is scheduled **after** the Iterate branch and True or False branches have completed
* Seperate YesSql and added InMemory, MongoDb
* Error fixed, if DatabaseInitializer is run through several times
* icon.png was not packed
* Added AddWorkflowProvider to AddElsaPersistenceMongoDb
* Wrong primary keys were used for MongoDb
* Refactorig MongoDb
* Register IMongoCollection<WorkflowDefinition> and IMongoCollection<WorkflowInstance> with DI
* Wrong Parameter Type in Constructor (MongoDbWorkflowInstanceRepository)
* Add workflowDefinition.WorkflowDefinitionId = _idGenerator.Generate(); to Initialize
* Removed duplicated code
* Correct wrong Commit
Co-authored-by: Rafael Carnucci <rafael.carnucci@icn.de>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>