Browse Source

Reverted a change.

pull/556/head
Sebastian 5 years ago
parent
commit
458c650fbb
  1. 1
      backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs
  2. 1
      backend/tests/Squidex.Infrastructure.Tests/Commands/CommandRequestTests.cs
  3. 74
      backend/tests/Squidex.Infrastructure.Tests/Orleans/ExceptionWrapperFilterTests.cs
  4. 2
      frontend/app/shared/components/search/query-list.component.html

1
backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs

@ -21,7 +21,6 @@ using Squidex.Infrastructure.Assets;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Log;
using Squidex.Web;
using ThirdParty.BouncyCastle.Asn1;
#pragma warning disable 1573

1
backend/tests/Squidex.Infrastructure.Tests/Commands/CommandRequestTests.cs

@ -9,7 +9,6 @@ using System.Globalization;
using System.Threading.Tasks;
using Orleans;
using Orleans.TestingHost;
using Squidex.Infrastructure.Commands;
using Xunit;
#pragma warning disable SA1133 // Do not combine attributes

74
backend/tests/Squidex.Infrastructure.Tests/Orleans/ExceptionWrapperFilterTests.cs

@ -6,12 +6,21 @@
// ==========================================================================
using System;
using System.Net;
using System.Threading.Tasks;
using FakeItEasy;
using MongoDB.Driver;
using MongoDB.Driver.Core.Clusters;
using MongoDB.Driver.Core.Connections;
using MongoDB.Driver.Core.Servers;
using Orleans;
using Orleans.Hosting;
using Orleans.TestingHost;
using Squidex.Infrastructure.TestHelpers;
using Xunit;
#pragma warning disable SA1133 // Do not combine attributes
namespace Squidex.Infrastructure.Orleans
{
public class ExceptionWrapperFilterTests
@ -19,6 +28,28 @@ namespace Squidex.Infrastructure.Orleans
private readonly IIncomingGrainCallContext context = A.Fake<IIncomingGrainCallContext>();
private readonly ExceptionWrapperFilter sut;
public interface IExceptionGrain : IGrainWithStringKey
{
Task ThrowCustomAsync();
Task ThrowMongoAsync();
}
public sealed class ExceptionGrain : Grain, IExceptionGrain
{
public Task ThrowCustomAsync()
{
throw new InvalidException("My Message");
}
public Task ThrowMongoAsync()
{
var connection = new ConnectionId(new ServerId(new ClusterId(), new IPEndPoint(IPAddress.Loopback, 21017)), 1);
throw new MongoWriteException(connection, null, null, null);
}
}
private sealed class InvalidException : Exception
{
public InvalidException(string message)
@ -27,6 +58,14 @@ namespace Squidex.Infrastructure.Orleans
}
}
public sealed class Configurator : ISiloConfigurator
{
public void Configure(ISiloBuilder siloBuilder)
{
siloBuilder.AddIncomingGrainCallFilter<ExceptionWrapperFilter>();
}
}
public ExceptionWrapperFilterTests()
{
sut = new ExceptionWrapperFilter();
@ -68,8 +107,41 @@ namespace Squidex.Infrastructure.Orleans
var result = source.SerializeAndDeserializeBinary();
Assert.Equal(result.ExceptionType, source.ExceptionType);
Assert.Equal(result.Message, source.Message);
}
[Fact, Trait("Category", "Dependencies")]
public async Task Simple_grain_tests()
{
var cluster =
new TestClusterBuilder(1)
.AddSiloBuilderConfigurator<Configurator>()
.Build();
await cluster.DeployAsync();
var grain = cluster.GrainFactory.GetGrain<IExceptionGrain>(SingleGrain.Id);
var ex = await Assert.ThrowsAsync<OrleansWrapperException>(() => grain.ThrowCustomAsync());
Assert.Equal(typeof(InvalidException), ex.ExceptionType);
}
[Fact, Trait("Category", "Dependencies")]
public async Task Simple_grain_tests_with_mongo_exception()
{
var cluster =
new TestClusterBuilder(1)
.AddSiloBuilderConfigurator<Configurator>()
.Build();
await cluster.DeployAsync();
var grain = cluster.GrainFactory.GetGrain<IExceptionGrain>(SingleGrain.Id);
var ex = await Assert.ThrowsAsync<OrleansWrapperException>(() => grain.ThrowMongoAsync());
Assert.Equal(typeof(MongoWriteException), ex.ExceptionType);
}
}
}

2
frontend/app/shared/components/search/query-list.component.html

@ -1,4 +1,4 @@
<ng-container *ngIf="queries.length > 0; else noQuery">
<ng-container *ngIf="queries?.length > 0; else noQuery">
<a class="sidebar-item" *ngFor="let saved of queries; trackBy: trackByQuery" (click)="search.emit(saved.query)"
[class.active]="isSelectedQuery(saved)">

Loading…
Cancel
Save