This file contains hidden or 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
| [Fact] | |
| public async Task Create_DomainIsValid() | |
| { | |
| var dto = new NetflixTitleDto | |
| { | |
| Director = "director", | |
| Country = "country", | |
| DurationMin = 1, | |
| Cast = "cast", | |
| Title = "title" |
This file contains hidden or 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
| private ICreateNetflixTitleServices MockServiceForCreate() | |
| { | |
| var mockCassandraContext = new Mock<ICassandraContext>(); | |
| mockCassandraContext | |
| .Setup(m => m.InsertAsync<NetflixTitle>(It.IsAny<NetflixTitle>())) | |
| .Returns(() => Task.CompletedTask); | |
| return new CreateNetflixTitleServices(mockCassandraContext.Object); | |
| } |
This file contains hidden or 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 async Task<NetflixTitleDto> Create(NetflixTitleDto dto) | |
| { | |
| try | |
| { | |
| dto.Id = Guid.NewGuid(); | |
| var netFlixTitleDomain = new NetflixTitleBuilder() | |
| .WithTitle(dto.Title) | |
| .WithDirector(dto.Director) | |
| .WithCountry(dto.Country) |
This file contains hidden or 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 async Task<DirectorsByCountryDto> GetDirectorsByCountry(string countryName) | |
| { | |
| ... | |
| try | |
| { | |
| var cqlQuery = @"select director as Name from netflix_titles where country=? allow filtering"; | |
| var returnQuery = await _cassandraContext.SelectAsync<string>(cqlQuery, countryName); |
This file contains hidden or 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
| [Fact] | |
| public void WithoutTitle_IsInvalid() | |
| { | |
| var domain = new NetflixTitleBuilder() | |
| .WithCast("cast example") | |
| .WithDescription("description example") | |
| .WithId(Guid.NewGuid()) | |
| .Build(); | |
| Assert.False(domain.IsValid()); |
This file contains hidden or 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 string Title { get; private set; } | |
| ... | |
| public void AddTitle(string title) | |
| { | |
| if (title.IsNullOrWhiteSpace()) | |
| { | |
| AddError("Faltou preencher o valor 'title'"); | |
| return; |
This file contains hidden or 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 BlackListHandler : DelegatingHandler | |
| { | |
| protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
| { | |
| request.Headers.TryGetValues("CLIENT_ID", out var values); | |
| var clientId = values?.FirstOrDefault(); | |
| if (clientId is null) | |
| { | |
| return ReturnBadRequest("Request bloqueada por falta de informações"); |
This file contains hidden or 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
| { | |
| "ReRoutes": [...], | |
| "Aggregates": [...], | |
| "DelegatingHandlers": [ | |
| "BlackListHandler" | |
| ], | |
| "GlobalConfiguration": {} | |
| } |
This file contains hidden or 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 void ConfigureServices(IServiceCollection services) | |
| { | |
| services | |
| .AddOcelot(_configuration) | |
| .AddDelegatingHandler<BlackListHandler>(true); | |
| } |
This file contains hidden or 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 BlackListHandler : DelegatingHandler | |
| { | |
| protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
| { | |
| return base.SendAsync(request, cancellationToken); | |
| } | |
| } |