-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
96 changed files
with
1,161 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ jobs: | |
- uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: ~/.nuget/packages | ||
path: packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
|
@@ -43,10 +43,15 @@ jobs: | |
#if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
nuget restore Snittlistan.sln | ||
Get-ChildItem -Recurse C:\Users\runneradmin\.nuget | ||
- name: Build | ||
run: msbuild build.build -t:All -p:Version=$env:BUILD_VERSION -p:WIX_PATH=$env:wix -p:NUnitConsoleRunnerPath=C:\Users\runneradmin\.nuget\packages\nunit.consolerunner\3.12.0\ | ||
run: msbuild build.build -t:All -p:Version=$env:BUILD_VERSION -p:WIX_PATH=$env:wix -p:NUnitConsoleRunnerPath=packages\nunit.consolerunner\3.12.0\ | ||
|
||
- name: Upload a Build Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: 'Test Result' | ||
path: Build\_build\TestResult.html | ||
|
||
- name: Push tag | ||
id: tag | ||
|
@@ -55,6 +60,18 @@ jobs: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ env.BUILD_VERSION }} | ||
|
||
- name: Comment pull request | ||
uses: actions/[email protected] | ||
if: github.event_name == 'pull_request' | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const filename = "Build/_build/TestResult.html"; | ||
const contents = fs.readFileSync(filename, "utf8"); | ||
const { issue: { number: issue_number }, repo: { owner, repo } } = context; | ||
github.issues.createComment({ issue_number, owner, repo, body: contents }); | ||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
|
@@ -64,7 +81,7 @@ jobs: | |
tag_name: ${{ steps.tag.outputs.new_tag }} | ||
release_name: Release v${{ steps.tag.outputs.new_tag }} | ||
draft: false | ||
prerelease: false | ||
prerelease: ${{ github.event_name == 'pull_request' }} | ||
|
||
- name: Upload artifact | ||
id: upload-artifact | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<config> | ||
<add key="repositoryPath" value="./packages" /> | ||
<add key="globalPackagesFolder" value="./packages" /> | ||
</config> | ||
<settings> | ||
<repositoryPath>./packages</repositoryPath> | ||
</settings> | ||
</configuration> |
2 changes: 1 addition & 1 deletion
2
...eue/Infrastructure/TenantConfiguration.cs → Snittlistan.Queue/Infrastructure/Tenant.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Snittlistan.Test/ApiControllers/Infrastructure/IdGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#nullable enable | ||
|
||
namespace Snittlistan.Test.ApiControllers.Infrastructure | ||
{ | ||
public class IdGenerator | ||
{ | ||
private int _currentId; | ||
|
||
public int GetNext() | ||
{ | ||
return ++_currentId; | ||
} | ||
} | ||
} |
141 changes: 141 additions & 0 deletions
141
Snittlistan.Test/ApiControllers/Infrastructure/InMemoryContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#nullable enable | ||
|
||
namespace Snittlistan.Test.ApiControllers.Infrastructure | ||
{ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Data.Entity; | ||
using System.Data.Entity.Infrastructure; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using Snittlistan.Web.Infrastructure.Database; | ||
|
||
public sealed class InMemoryDbSet<T> : IDbSet<T>, IDbAsyncEnumerable<T> where T : class | ||
{ | ||
private readonly IdGenerator _generator; | ||
private readonly HashSet<T> _data; | ||
private readonly IQueryable<T> _query; | ||
|
||
public InMemoryDbSet(IdGenerator generator) | ||
{ | ||
_generator = generator; | ||
_data = new HashSet<T>(); | ||
_query = _data.AsQueryable(); | ||
} | ||
|
||
public ObservableCollection<T> Local => new(_data); | ||
|
||
public Type ElementType => _query.ElementType; | ||
|
||
public Expression Expression => _query.Expression; | ||
|
||
public IQueryProvider Provider => new InMemoryDbAsyncQueryProvider<T>(_query.Provider); | ||
|
||
public IQueryable<T> AsQueryable() | ||
{ | ||
return _query; | ||
} | ||
|
||
public T Add(T entity) | ||
{ | ||
_ = _data.Add(entity); | ||
Type type = typeof(T); | ||
string idPropertyName = $"{type.Name}Id"; | ||
PropertyInfo propertyInfo = type.GetProperty(idPropertyName); | ||
if (propertyInfo == null) | ||
{ | ||
throw new Exception($"No {idPropertyName} property found on {type.Name} class"); | ||
} | ||
|
||
propertyInfo.SetValue(entity, _generator.GetNext()); | ||
|
||
return entity; | ||
} | ||
|
||
public T Attach(T entity) | ||
{ | ||
_ = _data.Add(entity); | ||
return entity; | ||
} | ||
|
||
public TDerivedEntity Create<TDerivedEntity>() where TDerivedEntity : class, T | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public T Create() | ||
{ | ||
return Activator.CreateInstance<T>(); | ||
} | ||
|
||
public T Find(params object[] keyValues) | ||
{ | ||
throw new NotImplementedException("Derive from FakeDbSet and override Find"); | ||
} | ||
|
||
public T Remove(T entity) | ||
{ | ||
_ = _data.Remove(entity); | ||
return entity; | ||
} | ||
|
||
public IEnumerator<T> GetEnumerator() | ||
{ | ||
return _data.GetEnumerator(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return _data.GetEnumerator(); | ||
} | ||
|
||
public IDbAsyncEnumerator<T> GetAsyncEnumerator() | ||
{ | ||
return new InMemoryDbAsyncEnumerator<T>(GetEnumerator()); | ||
} | ||
|
||
IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator() | ||
{ | ||
return GetAsyncEnumerator(); | ||
} | ||
} | ||
|
||
public class InMemoryContext : ISnittlistanContext, IBitsContext | ||
{ | ||
public InMemoryContext() | ||
{ | ||
IdGenerator generator = new(); | ||
DelayedTasks = new InMemoryDbSet<DelayedTask>(generator); | ||
PublishedTasks = new InMemoryDbSet<PublishedTask>(generator); | ||
Tenants = new InMemoryDbSet<Tenant>(generator); | ||
Teams = new InMemoryDbSet<Bits_Team>(generator); | ||
Hallar = new InMemoryDbSet<Bits_Hall>(generator); | ||
} | ||
|
||
public IDbSet<DelayedTask> DelayedTasks { get; } | ||
|
||
public IDbSet<PublishedTask> PublishedTasks { get; } | ||
|
||
public IDbSet<Bits_Team> Teams { get; } | ||
|
||
public IDbSet<Bits_Hall> Hallar { get; } | ||
|
||
public IDbSet<Tenant> Tenants { get; } | ||
|
||
public DbChangeTracker ChangeTracker => throw new NotImplementedException(); | ||
|
||
public int SaveChanges() | ||
{ | ||
return 0; | ||
} | ||
|
||
public Task<int> SaveChangesAsync() | ||
{ | ||
return Task.FromResult(0); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Snittlistan.Test/ApiControllers/Infrastructure/InMemoryDbAsyncEnumerable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#nullable enable | ||
|
||
namespace Snittlistan.Test.ApiControllers.Infrastructure | ||
{ | ||
using System.Collections.Generic; | ||
using System.Data.Entity.Infrastructure; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
|
||
public class InMemoryDbAsyncEnumerable<T> : EnumerableQuery<T>, IDbAsyncEnumerable<T>, IQueryable<T> | ||
{ | ||
public InMemoryDbAsyncEnumerable(IEnumerable<T> enumerable) | ||
: base(enumerable) | ||
{ } | ||
|
||
public InMemoryDbAsyncEnumerable(Expression expression) | ||
: base(expression) | ||
{ } | ||
|
||
public IQueryProvider Provider => new InMemoryDbAsyncQueryProvider<T>(this); | ||
|
||
public IDbAsyncEnumerator<T> GetAsyncEnumerator() | ||
{ | ||
return new InMemoryDbAsyncEnumerator<T>(this.AsEnumerable().GetEnumerator()); | ||
} | ||
|
||
IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator() | ||
{ | ||
return GetAsyncEnumerator(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Snittlistan.Test/ApiControllers/Infrastructure/InMemoryDbAsyncEnumerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#nullable enable | ||
|
||
namespace Snittlistan.Test.ApiControllers.Infrastructure | ||
{ | ||
using System.Collections.Generic; | ||
using System.Data.Entity.Infrastructure; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
public class InMemoryDbAsyncEnumerator<T> : IDbAsyncEnumerator<T> | ||
{ | ||
private readonly IEnumerator<T> _inner; | ||
|
||
public InMemoryDbAsyncEnumerator(IEnumerator<T> inner) | ||
{ | ||
_inner = inner; | ||
} | ||
|
||
public T Current => _inner.Current; | ||
|
||
object? IDbAsyncEnumerator.Current => Current; | ||
|
||
public void Dispose() | ||
{ | ||
_inner.Dispose(); | ||
} | ||
|
||
public Task<bool> MoveNextAsync(CancellationToken cancellationToken) | ||
{ | ||
return Task.FromResult(_inner.MoveNext()); | ||
} | ||
} | ||
} |
Oops, something went wrong.