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
[CollectionDefinition(nameof(ApiTestCollection))] | |
public class ApiTestCollection : ICollectionFixture<LocalStackFixture>, ICollectionFixture<TestServerFixture> | |
{ | |
} |
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
public class LocalStackFixture : IAsyncLifetime | |
{ | |
private readonly TestcontainersContainer _localStackContainer; | |
public LocalStackFixture() | |
{ | |
var localStackBuilder = new TestcontainersBuilder<TestcontainersContainer>() | |
.WithImage("localstack/localstack:0.10.9") | |
.WithCleanUp(true) | |
.WithEnvironment("DEFAULT_REGION", "eu-central-1") |
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
public class TestServerFixture : WebApplicationFactory<Startup> | |
{ | |
private const string DynamoDbServiceUrl = "http://localhost:4566/"; | |
private const string SqsServiceUrl = "http://localhost:4566/"; | |
protected override IHostBuilder CreateHostBuilder() | |
{ | |
var hostBuilder = base.CreateHostBuilder() | |
.UseEnvironment("Testing") | |
.ConfigureAppConfiguration(builder => |
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
[DynamoDBTable("Movies")] | |
public class MovieEntity | |
{ | |
[DynamoDBHashKey] | |
public Guid DirectorId { get; set; } | |
[DynamoDBRangeKey] | |
public string CreateDate { get; set; } | |
public Guid MovieId { get; set; } |
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
public class DynamoDbSeeder | |
{ | |
public static void Seed(AmazonDynamoDBClient client) | |
{ | |
var installers = typeof(DynamoDbMovieSeeder).Assembly.ExportedTypes | |
.Where(m => typeof(IDynamoDbSeeder).IsAssignableFrom(m) && !m.IsInterface && !m.IsAbstract) | |
.Select(Activator.CreateInstance) | |
.Cast<IDynamoDbSeeder>() | |
.ToList(); |
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
public class DynamoDbMovieSeeder : IDynamoDbSeeder | |
{ | |
public void Seed(AmazonDynamoDBClient client) | |
{ | |
MovieEntity model = new MovieEntity | |
{ | |
MovieId = TestConstants.GetMovieId(), | |
DirectorId = TestConstants.GetDirectorId(), | |
MovieName = TestConstants.GetMovieName(), | |
CreateDate = DateTime.UtcNow.ToComparableDateString() |
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
public class SqsSeeder | |
{ | |
public static void CreateQueue(AmazonSQSClient client) | |
{ | |
var installers = typeof(MovieLikeSeeder).Assembly.ExportedTypes | |
.Where(m => typeof(ISqsSeeder).IsAssignableFrom(m) && !m.IsInterface && !m.IsAbstract) | |
.Select(Activator.CreateInstance) | |
.Cast<ISqsSeeder>() | |
.ToList(); |
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
public class MovieLikeSeeder : ISqsSeeder | |
{ | |
public void CreateQueue(AmazonSQSClient client) | |
{ | |
CreateQueueRequest createDlqRequest = new CreateQueueRequest | |
{ | |
QueueName = "ArmutLocalStack-Test-DLQ.fifo", | |
Attributes = new Dictionary<string, string> | |
{ | |
{ |
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
[Route("api/movies")] | |
[ApiController] | |
public class MovieController : ControllerBase | |
{ | |
private readonly IMovieService _movieService; | |
public MovieController(IMovieService movieService) | |
{ | |
_movieService = movieService; | |
} |
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
public class MovieService : IMovieService | |
{ | |
private readonly IMovieRepository _movieRepository; | |
private readonly IValidatorService _validatorService; | |
private readonly IAmazonSQS _amazonSqs; | |
private readonly SqsQueueConfig _sqsQueueConfig; | |
public MovieService(IMovieRepository movieRepository, IValidatorService validatorService, IAmazonSQS amazonSqs, IOptions<SqsQueueConfig> options) | |
{ | |
_movieRepository = movieRepository; |
OlderNewer