Rename FeedbackReceiverService.cs to FeedbackReceiversService.cs

This commit is contained in:
Denis-Cosmin Nutiu 2021-07-04 17:39:07 +03:00
parent b89d2b5f9f
commit eca110d669
9 changed files with 38 additions and 38 deletions

View file

@ -4,7 +4,7 @@ using Retroactiune.Core.Entities;
namespace Retroactiune.Core.Interfaces namespace Retroactiune.Core.Interfaces
{ {
public interface IFeedbackReceiverService public interface IFeedbackReceiversService
{ {
/// <summary> /// <summary>
/// Creates feedback receivers. /// Creates feedback receivers.

View file

@ -12,11 +12,11 @@ namespace Retroactiune.Core.Services
/// Service that simplifies access to the database for managing FeedbackReceiver items. /// Service that simplifies access to the database for managing FeedbackReceiver items.
/// <see cref="FeedbackReceiver"/> /// <see cref="FeedbackReceiver"/>
/// </summary> /// </summary>
public class FeedbackReceiverService : IFeedbackReceiverService public class FeedbackReceiversService : IFeedbackReceiversService
{ {
private readonly IMongoCollection<FeedbackReceiver> _collection; private readonly IMongoCollection<FeedbackReceiver> _collection;
public FeedbackReceiverService(IMongoClient client, IDatabaseSettings settings) public FeedbackReceiversService(IMongoClient client, IDatabaseSettings settings)
{ {
var database = client.GetDatabase(settings.DatabaseName); var database = client.GetDatabase(settings.DatabaseName);
_collection = database.GetCollection<FeedbackReceiver>(settings.FeedbackReceiverCollectionName); _collection = database.GetCollection<FeedbackReceiver>(settings.FeedbackReceiverCollectionName);

View file

@ -35,7 +35,7 @@ namespace Retroactiune.Tests.Retroactiune.Core.Services
.Returns(mongoCollectionMock.Object); .Returns(mongoCollectionMock.Object);
// Test // Test
var service = new FeedbackReceiverService(mongoClientMock.Object, mongoSettingsMock.Object); var service = new FeedbackReceiversService(mongoClientMock.Object, mongoSettingsMock.Object);
var feedbackReceivers = items as FeedbackReceiver[] ?? items.ToArray(); var feedbackReceivers = items as FeedbackReceiver[] ?? items.ToArray();
await service.CreateManyAsync(feedbackReceivers); await service.CreateManyAsync(feedbackReceivers);
@ -70,7 +70,7 @@ namespace Retroactiune.Tests.Retroactiune.Core.Services
.Returns(mongoCollectionMock.Object); .Returns(mongoCollectionMock.Object);
// Test // Test
var service = new FeedbackReceiverService(mongoClientMock.Object, mongoSettingsMock.Object); var service = new FeedbackReceiversService(mongoClientMock.Object, mongoSettingsMock.Object);
var ex = Record.ExceptionAsync(async () => await service.CreateManyAsync(null)); var ex = Record.ExceptionAsync(async () => await service.CreateManyAsync(null));
@ -111,7 +111,7 @@ namespace Retroactiune.Tests.Retroactiune.Core.Services
.Returns(mongoCollectionMock.Object); .Returns(mongoCollectionMock.Object);
// Test // Test
var service = new FeedbackReceiverService(mongoClientMock.Object, mongoSettingsMock.Object); var service = new FeedbackReceiversService(mongoClientMock.Object, mongoSettingsMock.Object);
var ex = Record.ExceptionAsync(async () => await service.CreateManyAsync(new List<FeedbackReceiver>())); var ex = Record.ExceptionAsync(async () => await service.CreateManyAsync(new List<FeedbackReceiver>()));
@ -152,7 +152,7 @@ namespace Retroactiune.Tests.Retroactiune.Core.Services
.Returns(mongoCollectionMock.Object); .Returns(mongoCollectionMock.Object);
// Test // Test
var service = new FeedbackReceiverService(mongoClientMock.Object, mongoSettingsMock.Object); var service = new FeedbackReceiversService(mongoClientMock.Object, mongoSettingsMock.Object);
await service.DeleteManyAsync(new []{"insert_guid_here"}); await service.DeleteManyAsync(new []{"insert_guid_here"});
// Assert // Assert
@ -193,7 +193,7 @@ namespace Retroactiune.Tests.Retroactiune.Core.Services
.ReturnsAsync(mongoCursorMock.Object); .ReturnsAsync(mongoCursorMock.Object);
// Test // Test
var service = new FeedbackReceiverService(mongoClientMock.Object, mongoSettingsMock.Object); var service = new FeedbackReceiversService(mongoClientMock.Object, mongoSettingsMock.Object);
var guids = new[] {"insert_guid_here"}; var guids = new[] {"insert_guid_here"};
await service.FindAsync(guids, 0, 15); await service.FindAsync(guids, 0, 15);

View file

@ -21,7 +21,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
@ -40,7 +40,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
@ -59,7 +59,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
@ -82,7 +82,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
@ -104,7 +104,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
mockService.Setup(i => i.DeleteManyAsync(It.IsAny<IEnumerable<string>>())) mockService.Setup(i => i.DeleteManyAsync(It.IsAny<IEnumerable<string>>()))
@ -127,7 +127,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
mockService.Setup(i => i.FindAsync(It.IsAny<IEnumerable<string>>(), null, null)) mockService.Setup(i => i.FindAsync(It.IsAny<IEnumerable<string>>(), null, null))
@ -150,7 +150,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
@ -171,7 +171,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var mockService = new Mock<IFeedbackReceiverService>(); var mockService = new Mock<IFeedbackReceiversService>();
var tokensService = new Mock<ITokensService>(); var tokensService = new Mock<ITokensService>();
var logger = new Mock<ILogger<FeedbackReceiversController>>(); var logger = new Mock<ILogger<FeedbackReceiversController>>();
var filterArr = filter as string[] ?? filter.ToArray(); var filterArr = filter as string[] ?? filter.ToArray();

View file

@ -19,7 +19,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
public async Task Test_GenerateTokens_InexistentFeedbackReceiver() public async Task Test_GenerateTokens_InexistentFeedbackReceiver()
{ {
// Arrange // Arrange
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
@ -37,7 +37,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
@ -64,7 +64,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
@ -82,7 +82,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
tokens.Setup(i => i.DeleteTokens(It.IsAny<IEnumerable<string>>())) tokens.Setup(i => i.DeleteTokens(It.IsAny<IEnumerable<string>>()))
@ -102,7 +102,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
@ -120,7 +120,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
tokens.Setup(i => i.DeleteTokens(It.IsAny<IEnumerable<string>>())) tokens.Setup(i => i.DeleteTokens(It.IsAny<IEnumerable<string>>()))
@ -140,7 +140,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
@ -158,7 +158,7 @@ namespace Retroactiune.Tests.Retroactiune.WebAPI.Controllers
{ {
// Arrange // Arrange
var mapper = TestUtils.GetMapper(); var mapper = TestUtils.GetMapper();
var feedbackService = new Mock<IFeedbackReceiverService>(); var feedbackService = new Mock<IFeedbackReceiversService>();
var tokens = new Mock<ITokensService>(); var tokens = new Mock<ITokensService>();
var logger = new Mock<ILogger<TokensController>>(); var logger = new Mock<ILogger<TokensController>>();
tokens.Setup(i => i.ListTokens(It.IsAny<TokenListFilters>())) tokens.Setup(i => i.ListTokens(It.IsAny<TokenListFilters>()))

View file

@ -22,16 +22,16 @@ namespace Retroactiune.Controllers
private readonly IOptions<ApiBehaviorOptions> _apiBehaviorOptions; private readonly IOptions<ApiBehaviorOptions> _apiBehaviorOptions;
// Note: Probably refactor this to use an Aggregate object, need to learn more about aggregates.. // Note: Probably refactor this to use an Aggregate object, need to learn more about aggregates..
private readonly IFeedbackReceiverService _feedbackReceiverService; private readonly IFeedbackReceiversService _feedbackReceiversService;
private readonly ITokensService _tokensService; private readonly ITokensService _tokensService;
private readonly IMapper _mapper; private readonly IMapper _mapper;
private readonly ILogger _logger; private readonly ILogger _logger;
public FeedbackReceiversController(IFeedbackReceiverService feedbackReceiverService, public FeedbackReceiversController(IFeedbackReceiversService feedbackReceiversService,
ITokensService tokensService, IMapper mapper, ITokensService tokensService, IMapper mapper,
IOptions<ApiBehaviorOptions> apiBehaviorOptions, ILogger<FeedbackReceiversController> logger) IOptions<ApiBehaviorOptions> apiBehaviorOptions, ILogger<FeedbackReceiversController> logger)
{ {
_feedbackReceiverService = feedbackReceiverService; _feedbackReceiversService = feedbackReceiversService;
_tokensService = tokensService; _tokensService = tokensService;
_mapper = mapper; _mapper = mapper;
_apiBehaviorOptions = apiBehaviorOptions; _apiBehaviorOptions = apiBehaviorOptions;
@ -66,7 +66,7 @@ namespace Retroactiune.Controllers
return result; return result;
}); });
await _feedbackReceiverService.CreateManyAsync(mappedItems); await _feedbackReceiversService.CreateManyAsync(mappedItems);
return Ok(new BasicResponse() return Ok(new BasicResponse()
{ {
@ -88,7 +88,7 @@ namespace Retroactiune.Controllers
[StringLength(24, ErrorMessage = "invalid guid, must be 24 characters", MinimumLength = 24)] [StringLength(24, ErrorMessage = "invalid guid, must be 24 characters", MinimumLength = 24)]
string guid) string guid)
{ {
await Task.WhenAll(_feedbackReceiverService.DeleteManyAsync(new[] {guid}), await Task.WhenAll(_feedbackReceiversService.DeleteManyAsync(new[] {guid}),
_tokensService.DeleteManyByFeedbackReceiverIdAsync(new[] {guid})); _tokensService.DeleteManyByFeedbackReceiverIdAsync(new[] {guid}));
return NoContent(); return NoContent();
} }
@ -109,7 +109,7 @@ namespace Retroactiune.Controllers
[StringLength(24, ErrorMessage = "invalid guid, must be 24 characters", MinimumLength = 24)] [StringLength(24, ErrorMessage = "invalid guid, must be 24 characters", MinimumLength = 24)]
string guid) string guid)
{ {
var result = await _feedbackReceiverService.FindAsync(new[] {guid}); var result = await _feedbackReceiversService.FindAsync(new[] {guid});
var feedbackReceivers = result as FeedbackReceiver[] ?? result.ToArray(); var feedbackReceivers = result as FeedbackReceiver[] ?? result.ToArray();
if (!feedbackReceivers.Any()) if (!feedbackReceivers.Any())
{ {
@ -140,7 +140,7 @@ namespace Retroactiune.Controllers
[RangeAttribute(1, 1000, ErrorMessage = "limit is out of range, allowed ranges [1-1000]"), FromQuery] [RangeAttribute(1, 1000, ErrorMessage = "limit is out of range, allowed ranges [1-1000]"), FromQuery]
int limit) int limit)
{ {
return Ok(await _feedbackReceiverService.FindAsync(filter, offset, limit)); return Ok(await _feedbackReceiversService.FindAsync(filter, offset, limit));
} }
/// <summary> /// <summary>
@ -158,7 +158,7 @@ namespace Retroactiune.Controllers
try try
{ {
var feedbackReceiverIds = ids as string[] ?? ids.ToArray(); var feedbackReceiverIds = ids as string[] ?? ids.ToArray();
await Task.WhenAll(_feedbackReceiverService.DeleteManyAsync(feedbackReceiverIds), await Task.WhenAll(_feedbackReceiversService.DeleteManyAsync(feedbackReceiverIds),
_tokensService.DeleteManyByFeedbackReceiverIdAsync(feedbackReceiverIds)); _tokensService.DeleteManyByFeedbackReceiverIdAsync(feedbackReceiverIds));
return NoContent(); return NoContent();
} }

View file

@ -17,15 +17,15 @@ namespace Retroactiune.Controllers
[Route("api/v1/[controller]")] [Route("api/v1/[controller]")]
public class TokensController : ControllerBase public class TokensController : ControllerBase
{ {
private readonly IFeedbackReceiverService _feedbackReceiverService; private readonly IFeedbackReceiversService _feedbackReceiversService;
private readonly ITokensService _tokensService; private readonly ITokensService _tokensService;
private readonly IMapper _mapper; private readonly IMapper _mapper;
private readonly ILogger _logger; private readonly ILogger _logger;
public TokensController(IFeedbackReceiverService feedbackReceiverService, ITokensService tokensService, public TokensController(IFeedbackReceiversService feedbackReceiversService, ITokensService tokensService,
ILogger<TokensController> logger, IMapper mapper) ILogger<TokensController> logger, IMapper mapper)
{ {
_feedbackReceiverService = feedbackReceiverService; _feedbackReceiversService = feedbackReceiversService;
_tokensService = tokensService; _tokensService = tokensService;
_mapper = mapper; _mapper = mapper;
_logger = logger; _logger = logger;
@ -72,7 +72,7 @@ namespace Retroactiune.Controllers
public async Task<IActionResult> GenerateTokens([Required] GenerateTokensDto generateTokensDto) public async Task<IActionResult> GenerateTokens([Required] GenerateTokensDto generateTokensDto)
{ {
var feedbackReceiverId = generateTokensDto.FeedbackReceiverId; var feedbackReceiverId = generateTokensDto.FeedbackReceiverId;
var result = await _feedbackReceiverService.FindAsync( var result = await _feedbackReceiversService.FindAsync(
new[] {feedbackReceiverId}); new[] {feedbackReceiverId});
if (!result.Any()) if (!result.Any())
{ {

View file

@ -38,7 +38,7 @@ namespace Retroactiune
// Services // Services
services.AddSingleton<IFeedbackReceiverService, FeedbackReceiverService>(); services.AddSingleton<IFeedbackReceiversService, FeedbackReceiversService>();
services.AddSingleton<ITokensService, TokensService>(); services.AddSingleton<ITokensService, TokensService>();
services.AddSingleton<IMongoClient, MongoClient>(i => services.AddSingleton<IMongoClient, MongoClient>(i =>
{ {

View file

@ -34,7 +34,7 @@ namespace Retroactiune
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
// Services // Services
services.AddSingleton<IFeedbackReceiverService, FeedbackReceiverService>(); services.AddSingleton<IFeedbackReceiversService, FeedbackReceiversService>();
services.AddSingleton<ITokensService, TokensService>(); services.AddSingleton<ITokensService, TokensService>();
services.AddSingleton<IMongoClient, MongoClient>(i => services.AddSingleton<IMongoClient, MongoClient>(i =>
{ {