Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#region Licence

/* The MIT License (MIT)
Copyright © 2014 Ian Cooper <ian_hammond_cooper@yahoo.co.uk>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */

#endregion

// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

/// <summary>
/// Provider for managing inbox storage and creating inbox instances.
/// </summary>
public interface IAmAnInboxProviderAsync
{
/// <summary>
/// Creates the inbox data store.
/// </summary>
Task CreateStoreAsync();

/// <summary>
/// Deletes the inbox data store.
/// </summary>
Task DeleteStoreAsync();

/// <summary>
/// Creates a new inbox instance for storing and retrieving commands.
/// </summary>
/// <returns>A new <see cref="IAmAnInboxAsync{T}"/u003e instance.</returns>
IAmAnInboxAsync CreateInboxAsync();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;
using Paramore.Brighter.Base.Test.Requests;
using Xunit;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

[Trait("Category", "DynamoDB")]

[Collection("DynamoDBInbox")]
public class WhenAddingACommandToTheInboxItCanBeRetrieved : IAsyncLifetime
{
private readonly IAmAnInboxProviderAsync _inboxProvider;

public WhenAddingACommandToTheInboxItCanBeRetrieved()
{
_inboxProvider = new DynamoDBInboxProvider();
}

[Fact]
public async Task When_Adding_A_Command_To_The_Inbox_It_Can_Be_Retrieved_Async()
{
// Arrange
var contextKey = Uuid.NewAsString();
var command = new MyCommand { Value = Uuid.NewAsString() };
var inbox = _inboxProvider.CreateInboxAsync();

// Act
await inbox.AddAsync(command, contextKey, null);
var loadedCommand = await inbox.GetAsync<MyCommand>(command.Id, contextKey, null);

// Assert
Assert.NotNull(loadedCommand);
Assert.Equal(command.Value, loadedCommand.Value);
Assert.Equal(command.Id, loadedCommand.Id);
}

public async Task InitializeAsync()
{
await _inboxProvider.CreateStoreAsync();
}

public async Task DisposeAsync()
{
await _inboxProvider.DeleteStoreAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;
using Paramore.Brighter.Base.Test.Requests;
using Xunit;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

[Trait("Category", "DynamoDB")]

[Collection("DynamoDBInbox")]
public class WhenAddingADuplicateCommandWithDifferentContextKeyItShouldNotThrow : IAsyncLifetime
{
private readonly IAmAnInboxProviderAsync _inboxProvider;

public WhenAddingADuplicateCommandWithDifferentContextKeyItShouldNotThrow()
{
_inboxProvider = new DynamoDBInboxProvider();
}

[Fact]
public async Task When_Adding_A_Duplicate_Command_With_Different_Context_Key_It_Should_Not_Throw_Async()
{
// Arrange
var contextKey = Uuid.NewAsString();
var command = new MyCommand { Value = Uuid.NewAsString() };
var inbox = _inboxProvider.CreateInboxAsync();

// Act
await inbox.AddAsync(command, contextKey, null);
await inbox.AddAsync(command, Uuid.NewAsString(), null);

// Assert
var exists = await inbox.ExistsAsync<MyCommand>(command.Id, contextKey, null);
Assert.True(exists, $"A command with '{command.Id.Value}' Id should exist");
}

public async Task InitializeAsync()
{
await _inboxProvider.CreateStoreAsync();
}

public async Task DisposeAsync()
{
await _inboxProvider.DeleteStoreAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;
using Paramore.Brighter.Base.Test.Requests;
using Xunit;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

[Trait("Category", "DynamoDB")]

[Collection("DynamoDBInbox")]
public class WhenAddingADuplicateCommandWithSameContextKeyItShouldNotThrow : IAsyncLifetime
{
private readonly IAmAnInboxProviderAsync _inboxProvider;

public WhenAddingADuplicateCommandWithSameContextKeyItShouldNotThrow()
{
_inboxProvider = new DynamoDBInboxProvider();
}

[Fact]
public async Task When_Adding_A_Duplicate_Command_With_Same_Context_Key_It_Should_Not_Throw_Async()
{
// Arrange
var contextKey = Uuid.NewAsString();
var command = new MyCommand { Value = Uuid.NewAsString() };
var inbox = _inboxProvider.CreateInboxAsync();

// Act
await inbox.AddAsync(command, contextKey, null);
await inbox.AddAsync(command, contextKey, null);

// Assert
var exists = await inbox.ExistsAsync<MyCommand>(command.Id, contextKey, null);
Assert.True(exists, $"A command with '{command.Id.Value}' Id should exist");
}

public async Task InitializeAsync()
{
await _inboxProvider.CreateStoreAsync();
}

public async Task DisposeAsync()
{
await _inboxProvider.DeleteStoreAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;
using Paramore.Brighter.Base.Test.Requests;
using Xunit;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

[Trait("Category", "DynamoDB")]

[Collection("DynamoDBInbox")]
public class WhenCheckingIfANonExistentCommandExistsItShouldReturnFalse : IAsyncLifetime
{
private readonly IAmAnInboxProviderAsync _inboxProvider;

public WhenCheckingIfANonExistentCommandExistsItShouldReturnFalse()
{
_inboxProvider = new DynamoDBInboxProvider();
}

[Fact]
public async Task When_Checking_If_A_Non_Existent_Command_Exists_It_Should_Return_False_Async()
{
// Arrange
var inbox = _inboxProvider.CreateInboxAsync();

// Act
var exists = await inbox.ExistsAsync<MyCommand>(Uuid.NewAsString(), Uuid.NewAsString(), null);

// Assert
Assert.False(exists, "A command should not exist");
}

public async Task InitializeAsync()
{
await _inboxProvider.CreateStoreAsync();
}

public async Task DisposeAsync()
{
await _inboxProvider.DeleteStoreAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;
using Paramore.Brighter.Base.Test.Requests;
using Xunit;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

[Trait("Category", "DynamoDB")]

[Collection("DynamoDBInbox")]
public class WhenCheckingIfAnExistingCommandExistsItShouldReturnTrue : IAsyncLifetime
{
private readonly IAmAnInboxProviderAsync _inboxProvider;

public WhenCheckingIfAnExistingCommandExistsItShouldReturnTrue()
{
_inboxProvider = new DynamoDBInboxProvider();
}

[Fact]
public async Task When_Checking_If_An_Existing_Command_Exists_It_Should_Return_True_Async()
{
// Arrange
var contextKey = Uuid.NewAsString();
var command = new MyCommand { Value = Uuid.NewAsString() };
var inbox = _inboxProvider.CreateInboxAsync();
await inbox.AddAsync(command, contextKey, null);

// Act
var exists = await inbox.ExistsAsync<MyCommand>(command.Id, contextKey, null);

// Assert
Assert.True(exists, $"A command with '{command.Id.Value}' Id should exist");
}

public async Task InitializeAsync()
{
await _inboxProvider.CreateStoreAsync();
}

public async Task DisposeAsync()
{
await _inboxProvider.DeleteStoreAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;
using Paramore.Brighter.Base.Test.Requests;
using Paramore.Brighter.Inbox.Exceptions;
using Xunit;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

[Trait("Category", "DynamoDB")]

[Collection("DynamoDBInbox")]
public class WhenGettingACommandWithWrongContextKeyItShouldThrowRequestNotFoundException : IAsyncLifetime
{
private readonly IAmAnInboxProviderAsync _inboxProvider;

public WhenGettingACommandWithWrongContextKeyItShouldThrowRequestNotFoundException()
{
_inboxProvider = new DynamoDBInboxProvider();
}

[Fact]
public async Task When_Getting_A_Command_With_Wrong_Context_Key_It_Should_Throw_RequestNotFoundException_Async()
{
// Arrange
var command = new MyCommand { Value = Uuid.NewAsString() };
var inbox = _inboxProvider.CreateInboxAsync();
await inbox.AddAsync(command, Uuid.NewAsString(), null);

// Act & Assert
await Assert.ThrowsAsync<RequestNotFoundException<MyCommand>>(async () => await inbox.GetAsync<MyCommand>(command.Id, Uuid.NewAsString(), null));
}

public async Task InitializeAsync()
{
await _inboxProvider.CreateStoreAsync();
}

public async Task DisposeAsync()
{
await _inboxProvider.DeleteStoreAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// <auto-generated>
// This file is auto-generated by Paramore.Brighter.Test.Generator
// </auto-generated>

using System.Threading.Tasks;
using Paramore.Brighter.Base.Test.Requests;
using Paramore.Brighter.Inbox.Exceptions;
using Xunit;

namespace Paramore.Brighter.DynamoDB.Tests.Inbox.DynamoDB.Async;

[Trait("Category", "DynamoDB")]

[Collection("DynamoDBInbox")]
public class WhenGettingANonExistentCommandItShouldThrowRequestNotFoundException : IAsyncLifetime
{
private readonly IAmAnInboxProviderAsync _inboxProvider;

public WhenGettingANonExistentCommandItShouldThrowRequestNotFoundException()
{
_inboxProvider = new DynamoDBInboxProvider();
}

[Fact]
public async Task When_Getting_A_Non_Existent_Command_It_Should_Throw_RequestNotFoundException_Async()
{
// Arrange
var contextKey = Uuid.NewAsString();
var commandId = Uuid.NewAsString();
var inbox = _inboxProvider.CreateInboxAsync();

// Act & Assert
await Assert.ThrowsAsync<RequestNotFoundException<MyCommand>>(async () => await inbox.GetAsync<MyCommand>(commandId, contextKey, null));
}

public async Task InitializeAsync()
{
await _inboxProvider.CreateStoreAsync();
}

public async Task DisposeAsync()
{
await _inboxProvider.DeleteStoreAsync();
}
}
Loading
Loading