diff --git a/test/Core.Test/Services/AmazonSesMailDeliveryServiceTests.cs b/test/Core.Test/Services/AmazonSesMailDeliveryServiceTests.cs new file mode 100644 index 000000000..edea84eae --- /dev/null +++ b/test/Core.Test/Services/AmazonSesMailDeliveryServiceTests.cs @@ -0,0 +1,43 @@ +using System; +using Bit.Core.Services; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class AmazonSesMailDeliveryServiceTests : IDisposable + { + private readonly AmazonSesMailDeliveryService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly IHostingEnvironment _hostingEnvironment; + private readonly ILogger _logger; + + public AmazonSesMailDeliveryServiceTests() + { + _globalSettings = new GlobalSettings(); + _hostingEnvironment = Substitute.For(); + _logger = Substitute.For>(); + _sut = new AmazonSesMailDeliveryService( + _globalSettings, + _hostingEnvironment, + _logger + ); + } + + public void Dispose() + { + _sut?.Dispose(); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/AmazonSqsBlockIpServiceTests.cs b/test/Core.Test/Services/AmazonSqsBlockIpServiceTests.cs new file mode 100644 index 000000000..abc9c9743 --- /dev/null +++ b/test/Core.Test/Services/AmazonSqsBlockIpServiceTests.cs @@ -0,0 +1,34 @@ +using System; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class AmazonSqsBlockIpServiceTests : IDisposable + { + private readonly AmazonSqsBlockIpService _sut; + + private readonly GlobalSettings _globalSettings; + + public AmazonSqsBlockIpServiceTests() + { + _globalSettings = new GlobalSettings(); + + _sut = new AmazonSqsBlockIpService(_globalSettings); + } + + public void Dispose() + { + _sut?.Dispose(); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/AzureAttachmentStorageServiceTests.cs b/test/Core.Test/Services/AzureAttachmentStorageServiceTests.cs new file mode 100644 index 000000000..c18027d1c --- /dev/null +++ b/test/Core.Test/Services/AzureAttachmentStorageServiceTests.cs @@ -0,0 +1,29 @@ +using System; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class AzureAttachmentStorageServiceTests + { + private readonly AzureAttachmentStorageService _sut; + + private readonly GlobalSettings _globalSettings; + + public AzureAttachmentStorageServiceTests() + { + _globalSettings = new GlobalSettings(); + + _sut = new AzureAttachmentStorageService(_globalSettings); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/AzureQueueBlockIpServiceTests.cs b/test/Core.Test/Services/AzureQueueBlockIpServiceTests.cs new file mode 100644 index 000000000..7b1d7b6a8 --- /dev/null +++ b/test/Core.Test/Services/AzureQueueBlockIpServiceTests.cs @@ -0,0 +1,29 @@ +using System; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class AzureQueueBlockIpServiceTests + { + private readonly AzureQueueBlockIpService _sut; + + private readonly GlobalSettings _globalSettings; + + public AzureQueueBlockIpServiceTests() + { + _globalSettings = new GlobalSettings(); + + _sut = new AzureQueueBlockIpService(_globalSettings); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/AzureQueueEventWriteServiceTests.cs b/test/Core.Test/Services/AzureQueueEventWriteServiceTests.cs new file mode 100644 index 000000000..c5921989e --- /dev/null +++ b/test/Core.Test/Services/AzureQueueEventWriteServiceTests.cs @@ -0,0 +1,35 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class AzureQueueEventWriteServiceTests + { + private readonly AzureQueueEventWriteService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly IEventRepository _eventRepository; + + public AzureQueueEventWriteServiceTests() + { + _globalSettings = new GlobalSettings(); + _eventRepository = Substitute.For(); + + _sut = new AzureQueueEventWriteService( + _eventRepository, + _globalSettings + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs b/test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs new file mode 100644 index 000000000..caaf1dcf8 --- /dev/null +++ b/test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs @@ -0,0 +1,35 @@ +using System; +using Bit.Core.Services; +using Microsoft.AspNetCore.Http; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class AzureQueuePushNotificationServiceTests + { + private readonly AzureQueuePushNotificationService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly IHttpContextAccessor _httpContextAccessor; + + public AzureQueuePushNotificationServiceTests() + { + _globalSettings = new GlobalSettings(); + _httpContextAccessor = Substitute.For(); + + _sut = new AzureQueuePushNotificationService( + _globalSettings, + _httpContextAccessor + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/CipherServiceTests.cs b/test/Core.Test/Services/CipherServiceTests.cs new file mode 100644 index 000000000..e1f949db7 --- /dev/null +++ b/test/Core.Test/Services/CipherServiceTests.cs @@ -0,0 +1,65 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class CipherServiceTests + { + private readonly CipherService _sut; + + private readonly ICipherRepository _cipherRepository; + private readonly IFolderRepository _folderRepository; + private readonly ICollectionRepository _collectionRepository; + private readonly IUserRepository _userRepository; + private readonly IOrganizationRepository _organizationRepository; + private readonly IOrganizationUserRepository _organizationUserRepository; + private readonly ICollectionCipherRepository _collectionCipherRepository; + private readonly IPushNotificationService _pushService; + private readonly IAttachmentStorageService _attachmentStorageService; + private readonly IEventService _eventService; + private readonly IUserService _userService; + private readonly GlobalSettings _globalSettings; + + public CipherServiceTests() + { + _cipherRepository = Substitute.For(); + _folderRepository = Substitute.For(); + _collectionRepository = Substitute.For(); + _userRepository = Substitute.For(); + _organizationRepository = Substitute.For(); + _organizationUserRepository = Substitute.For(); + _collectionCipherRepository = Substitute.For(); + _pushService = Substitute.For(); + _attachmentStorageService = Substitute.For(); + _eventService = Substitute.For(); + _userService = Substitute.For(); + _globalSettings = new GlobalSettings(); + + _sut = new CipherService( + _cipherRepository, + _folderRepository, + _collectionRepository, + _userRepository, + _organizationRepository, + _organizationUserRepository, + _collectionCipherRepository, + _pushService, + _attachmentStorageService, + _eventService, + _userService, + _globalSettings + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/EventServiceTests.cs b/test/Core.Test/Services/EventServiceTests.cs new file mode 100644 index 000000000..60bcd5cd9 --- /dev/null +++ b/test/Core.Test/Services/EventServiceTests.cs @@ -0,0 +1,44 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class EventServiceTests + { + private readonly EventService _sut; + + private readonly IEventWriteService _eventWriteService; + private readonly IOrganizationUserRepository _organizationUserRepository; + private readonly IApplicationCacheService _applicationCacheService; + private readonly CurrentContext _currentContext; + private readonly GlobalSettings _globalSettings; + + public EventServiceTests() + { + _eventWriteService = Substitute.For(); + _organizationUserRepository = Substitute.For(); + _applicationCacheService = Substitute.For(); + _currentContext = new CurrentContext(); + _globalSettings = new GlobalSettings(); + + _sut = new EventService( + _eventWriteService, + _organizationUserRepository, + _applicationCacheService, + _currentContext, + _globalSettings + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/GroupServiceTests.cs b/test/Core.Test/Services/GroupServiceTests.cs new file mode 100644 index 000000000..2301caf01 --- /dev/null +++ b/test/Core.Test/Services/GroupServiceTests.cs @@ -0,0 +1,41 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class GroupServiceTests + { + private readonly GroupService _sut; + + private readonly IEventService _eventService; + private readonly IOrganizationRepository _organizationRepository; + private readonly IOrganizationUserRepository _organizationUserRepository; + private readonly IGroupRepository _groupRepository; + + public GroupServiceTests() + { + _eventService = Substitute.For(); + _organizationRepository = Substitute.For(); + _organizationUserRepository = Substitute.For(); + _groupRepository = Substitute.For(); + + _sut = new GroupService( + _eventService, + _organizationRepository, + _organizationUserRepository, + _groupRepository + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/HandlebarsMailServiceTests.cs b/test/Core.Test/Services/HandlebarsMailServiceTests.cs new file mode 100644 index 000000000..f6207a95f --- /dev/null +++ b/test/Core.Test/Services/HandlebarsMailServiceTests.cs @@ -0,0 +1,34 @@ +using System; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class HandlebarsMailServiceTests + { + private readonly HandlebarsMailService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly IMailDeliveryService _mailDeliveryService; + + public HandlebarsMailServiceTests() + { + _globalSettings = new GlobalSettings(); + _mailDeliveryService = Substitute.For(); + + _sut = new HandlebarsMailService( + _globalSettings, + _mailDeliveryService + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/InMemoryApplicationCacheServiceTests.cs b/test/Core.Test/Services/InMemoryApplicationCacheServiceTests.cs new file mode 100644 index 000000000..63ba7a128 --- /dev/null +++ b/test/Core.Test/Services/InMemoryApplicationCacheServiceTests.cs @@ -0,0 +1,30 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class InMemoryApplicationCacheServiceTests + { + private readonly InMemoryApplicationCacheService _sut; + + private readonly IOrganizationRepository _organizationRepository; + + public InMemoryApplicationCacheServiceTests() + { + _organizationRepository = Substitute.For(); + + _sut = new InMemoryApplicationCacheService(_organizationRepository); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/InMemoryServiceBusApplicationCacheServiceTests.cs b/test/Core.Test/Services/InMemoryServiceBusApplicationCacheServiceTests.cs new file mode 100644 index 000000000..25751f7b6 --- /dev/null +++ b/test/Core.Test/Services/InMemoryServiceBusApplicationCacheServiceTests.cs @@ -0,0 +1,35 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class InMemoryServiceBusApplicationCacheServiceTests + { + private readonly InMemoryServiceBusApplicationCacheService _sut; + + private readonly IOrganizationRepository _organizationRepository; + private readonly GlobalSettings _globalSettings; + + public InMemoryServiceBusApplicationCacheServiceTests() + { + _organizationRepository = Substitute.For(); + _globalSettings = new GlobalSettings(); + + _sut = new InMemoryServiceBusApplicationCacheService( + _organizationRepository, + _globalSettings + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/LicensingServiceTests.cs b/test/Core.Test/Services/LicensingServiceTests.cs new file mode 100644 index 000000000..bd7e9ea65 --- /dev/null +++ b/test/Core.Test/Services/LicensingServiceTests.cs @@ -0,0 +1,49 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class LicensingServiceTests + { + private readonly LicensingService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly IUserRepository _userRepository; + private readonly IOrganizationRepository _organizationRepository; + private readonly IOrganizationUserRepository _organizationUserRepository; + private readonly IHostingEnvironment _hostingEnvironment; + private readonly ILogger _logger; + + public LicensingServiceTests() + { + _userRepository = Substitute.For(); + _organizationRepository = Substitute.For(); + _organizationUserRepository = Substitute.For(); + _hostingEnvironment = Substitute.For(); + _logger = Substitute.For>(); + _globalSettings = new GlobalSettings(); + + _sut = new LicensingService( + _userRepository, + _organizationRepository, + _organizationUserRepository, + _hostingEnvironment, + _logger, + _globalSettings + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs b/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs new file mode 100644 index 000000000..44cf84349 --- /dev/null +++ b/test/Core.Test/Services/LocalAttachmentStorageServiceTests.cs @@ -0,0 +1,29 @@ +using System; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class LocalAttachmentStorageServiceTests + { + private readonly LocalAttachmentStorageService _sut; + + private readonly GlobalSettings _globalSettings; + + public LocalAttachmentStorageServiceTests() + { + _globalSettings = new GlobalSettings(); + + _sut = new LocalAttachmentStorageService(_globalSettings); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/MailKitSmtpMailDeliveryServiceTests.cs b/test/Core.Test/Services/MailKitSmtpMailDeliveryServiceTests.cs new file mode 100644 index 000000000..568af8df3 --- /dev/null +++ b/test/Core.Test/Services/MailKitSmtpMailDeliveryServiceTests.cs @@ -0,0 +1,38 @@ +using System; +using Bit.Core.Services; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class MailKitSmtpMailDeliveryServiceTests + { + private readonly MailKitSmtpMailDeliveryService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly ILogger _logger; + + public MailKitSmtpMailDeliveryServiceTests() + { + _globalSettings = new GlobalSettings(); + _logger = Substitute.For>(); + + _globalSettings.Mail.Smtp.Host = "unittests.example.com"; + _globalSettings.Mail.ReplyToEmail = "noreply@unittests.example.com"; + + _sut = new MailKitSmtpMailDeliveryService( + _globalSettings, + _logger + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/MultiServicePushNotificationServiceTests.cs b/test/Core.Test/Services/MultiServicePushNotificationServiceTests.cs new file mode 100644 index 000000000..b78b4842d --- /dev/null +++ b/test/Core.Test/Services/MultiServicePushNotificationServiceTests.cs @@ -0,0 +1,52 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class MultiServicePushNotificationServiceTests + { + private readonly MultiServicePushNotificationService _sut; + + private readonly IDeviceRepository _deviceRepository; + private readonly IInstallationDeviceRepository _installationDeviceRepository; + private readonly GlobalSettings _globalSettings; + private readonly IHttpContextAccessor _httpContextAccessor; + private readonly ILogger _logger; + private readonly ILogger _relayLogger; + private readonly ILogger _hubLogger; + + public MultiServicePushNotificationServiceTests() + { + _deviceRepository = Substitute.For(); + _installationDeviceRepository = Substitute.For(); + _globalSettings = new GlobalSettings(); + _httpContextAccessor = Substitute.For(); + _logger = Substitute.For>(); + _relayLogger = Substitute.For>(); + _hubLogger = Substitute.For>(); + + _sut = new MultiServicePushNotificationService( + _deviceRepository, + _installationDeviceRepository, + _globalSettings, + _httpContextAccessor, + _logger, + _relayLogger, + _hubLogger + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/NotificationHubPushNotificationServiceTests.cs b/test/Core.Test/Services/NotificationHubPushNotificationServiceTests.cs new file mode 100644 index 000000000..b04987741 --- /dev/null +++ b/test/Core.Test/Services/NotificationHubPushNotificationServiceTests.cs @@ -0,0 +1,39 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using Microsoft.AspNetCore.Http; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class NotificationHubPushNotificationServiceTests + { + private readonly NotificationHubPushNotificationService _sut; + + private readonly IInstallationDeviceRepository _installationDeviceRepository; + private readonly GlobalSettings _globalSettings; + private readonly IHttpContextAccessor _httpContextAccessor; + + public NotificationHubPushNotificationServiceTests() + { + _installationDeviceRepository = Substitute.For(); + _globalSettings = new GlobalSettings(); + _httpContextAccessor = Substitute.For(); + + _sut = new NotificationHubPushNotificationService( + _installationDeviceRepository, + _globalSettings, + _httpContextAccessor + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/NotificationHubPushRegistrationServiceTests.cs b/test/Core.Test/Services/NotificationHubPushRegistrationServiceTests.cs new file mode 100644 index 000000000..bd5f37303 --- /dev/null +++ b/test/Core.Test/Services/NotificationHubPushRegistrationServiceTests.cs @@ -0,0 +1,35 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class NotificationHubPushRegistrationServiceTests + { + private readonly NotificationHubPushRegistrationService _sut; + + private readonly IInstallationDeviceRepository _installationDeviceRepository; + private readonly GlobalSettings _globalSettings; + + public NotificationHubPushRegistrationServiceTests() + { + _installationDeviceRepository = Substitute.For(); + _globalSettings = new GlobalSettings(); + + _sut = new NotificationHubPushRegistrationService( + _installationDeviceRepository, + _globalSettings + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/NotificationsApiPushNotificationServiceTests.cs b/test/Core.Test/Services/NotificationsApiPushNotificationServiceTests.cs new file mode 100644 index 000000000..fa6e6773c --- /dev/null +++ b/test/Core.Test/Services/NotificationsApiPushNotificationServiceTests.cs @@ -0,0 +1,39 @@ +using System; +using Bit.Core.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class NotificationsApiPushNotificationServiceTests + { + private readonly NotificationsApiPushNotificationService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly IHttpContextAccessor _httpContextAccessor; + private readonly ILogger _logger; + + public NotificationsApiPushNotificationServiceTests() + { + _globalSettings = new GlobalSettings(); + _httpContextAccessor = Substitute.For(); + _logger = Substitute.For>(); + + _sut = new NotificationsApiPushNotificationService( + _globalSettings, + _httpContextAccessor, + _logger + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/RelayPushNotificationServiceTests.cs b/test/Core.Test/Services/RelayPushNotificationServiceTests.cs new file mode 100644 index 000000000..079b04961 --- /dev/null +++ b/test/Core.Test/Services/RelayPushNotificationServiceTests.cs @@ -0,0 +1,43 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class RelayPushNotificationServiceTests + { + private readonly RelayPushNotificationService _sut; + + private readonly IDeviceRepository _deviceRepository; + private readonly GlobalSettings _globalSettings; + private readonly IHttpContextAccessor _httpContextAccessor; + private readonly ILogger _logger; + + public RelayPushNotificationServiceTests() + { + _deviceRepository = Substitute.For(); + _globalSettings = new GlobalSettings(); + _httpContextAccessor = Substitute.For(); + _logger = Substitute.For>(); + + _sut = new RelayPushNotificationService( + _deviceRepository, + _globalSettings, + _httpContextAccessor, + _logger + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/RelayPushRegistrationServiceTests.cs b/test/Core.Test/Services/RelayPushRegistrationServiceTests.cs new file mode 100644 index 000000000..606f814eb --- /dev/null +++ b/test/Core.Test/Services/RelayPushRegistrationServiceTests.cs @@ -0,0 +1,35 @@ +using System; +using Bit.Core.Services; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class RelayPushRegistrationServiceTests + { + private readonly RelayPushRegistrationService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly ILogger _logger; + + public RelayPushRegistrationServiceTests() + { + _globalSettings = new GlobalSettings(); + _logger = Substitute.For>(); + + _sut = new RelayPushRegistrationService( + _globalSettings, + _logger + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/RepositoryEventWriteServiceTests.cs b/test/Core.Test/Services/RepositoryEventWriteServiceTests.cs new file mode 100644 index 000000000..6b02a2ceb --- /dev/null +++ b/test/Core.Test/Services/RepositoryEventWriteServiceTests.cs @@ -0,0 +1,30 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class RepositoryEventWriteServiceTests + { + private readonly RepositoryEventWriteService _sut; + + private readonly IEventRepository _eventRepository; + + public RepositoryEventWriteServiceTests() + { + _eventRepository = Substitute.For(); + + _sut = new RepositoryEventWriteService(_eventRepository); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/SendGridMailDeliveryServiceTests.cs b/test/Core.Test/Services/SendGridMailDeliveryServiceTests.cs new file mode 100644 index 000000000..f2691208b --- /dev/null +++ b/test/Core.Test/Services/SendGridMailDeliveryServiceTests.cs @@ -0,0 +1,29 @@ +using System; +using Bit.Core.Services; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class SendGridMailDeliveryServiceTests + { + private readonly SendGridMailDeliveryService _sut; + + private readonly GlobalSettings _globalSettings; + + public SendGridMailDeliveryServiceTests() + { + _globalSettings = new GlobalSettings(); + + _sut = new SendGridMailDeliveryService(_globalSettings); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact(Skip = "Needs additional work")] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/SmtpMailDeliveryServiceTests.cs b/test/Core.Test/Services/SmtpMailDeliveryServiceTests.cs new file mode 100644 index 000000000..0ad4fcda7 --- /dev/null +++ b/test/Core.Test/Services/SmtpMailDeliveryServiceTests.cs @@ -0,0 +1,35 @@ +using System; +using Bit.Core.Services; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class SmtpMailDeliveryServiceTests + { + private readonly SmtpMailDeliveryService _sut; + + private readonly GlobalSettings _globalSettings; + private readonly ILogger _logger; + + public SmtpMailDeliveryServiceTests() + { + _globalSettings = new GlobalSettings(); + _logger = Substitute.For>(); + + _globalSettings.Mail.Smtp.Host = "unittests.example.com"; + _globalSettings.Mail.ReplyToEmail = "noreply@unittests.example.com"; + + _sut = new SmtpMailDeliveryService(_globalSettings, _logger); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/StripePaymentServiceTests.cs b/test/Core.Test/Services/StripePaymentServiceTests.cs new file mode 100644 index 000000000..4b2ccef18 --- /dev/null +++ b/test/Core.Test/Services/StripePaymentServiceTests.cs @@ -0,0 +1,39 @@ +using System; +using Bit.Core.Repositories; +using Bit.Core.Services; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class StripePaymentServiceTests + { + private readonly StripePaymentService _sut; + + private readonly ITransactionRepository _transactionRepository; + private readonly GlobalSettings _globalSettings; + private readonly ILogger _logger; + + public StripePaymentServiceTests() + { + _transactionRepository = Substitute.For(); + _globalSettings = new GlobalSettings(); + _logger = Substitute.For>(); + + _sut = new StripePaymentService( + _transactionRepository, + _globalSettings, + _logger + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +} diff --git a/test/Core.Test/Services/UserServiceTests.cs b/test/Core.Test/Services/UserServiceTests.cs new file mode 100644 index 000000000..9fd0512ee --- /dev/null +++ b/test/Core.Test/Services/UserServiceTests.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using Bit.Core.Models.Table; +using Bit.Core.Repositories; +using Bit.Core.Services; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Options; +using Microsoft.Extensions.Logging; +using NSubstitute; +using Xunit; + +namespace Bit.Core.Test.Services +{ + public class UserServiceTests + { + private readonly UserService _sut; + + private readonly IUserRepository _userRepository; + private readonly ICipherRepository _cipherRepository; + private readonly IOrganizationUserRepository _organizationUserRepository; + private readonly IOrganizationRepository _organizationRepository; + private readonly IU2fRepository _u2fRepository; + private readonly IMailService _mailService; + private readonly IPushNotificationService _pushService; + private readonly IUserStore _userStore; + private readonly IOptions _optionsAccessor; + private readonly IPasswordHasher _passwordHasher; + private readonly IEnumerable> _userValidators; + private readonly IEnumerable> _passwordValidators; + private readonly ILookupNormalizer _keyNormalizer; + private readonly IdentityErrorDescriber _errors; + private readonly IServiceProvider _services; + private readonly ILogger> _logger; + private readonly ILicensingService _licenseService; + private readonly IEventService _eventService; + private readonly IApplicationCacheService _applicationCacheService; + private readonly IDataProtectionProvider _dataProtectionProvider; + private readonly IPaymentService _paymentService; + private readonly CurrentContext _currentContext; + private readonly GlobalSettings _globalSettings; + + public UserServiceTests() + { + _userRepository = Substitute.For(); + _cipherRepository = Substitute.For(); + _organizationUserRepository = Substitute.For(); + _organizationRepository = Substitute.For(); + _u2fRepository = Substitute.For(); + _mailService = Substitute.For(); + _pushService = Substitute.For(); + _userStore = Substitute.For>(); + _optionsAccessor = Substitute.For>(); + _passwordHasher = Substitute.For>(); + _userValidators = new List>(); + _passwordValidators = new List>(); + _keyNormalizer = Substitute.For(); + _errors = new IdentityErrorDescriber(); + _services = Substitute.For(); + _logger = Substitute.For>>(); + _licenseService = Substitute.For(); + _eventService = Substitute.For(); + _applicationCacheService = Substitute.For(); + _dataProtectionProvider = Substitute.For(); + _paymentService = Substitute.For(); + _currentContext = new CurrentContext(); + _globalSettings = new GlobalSettings(); + + _sut = new UserService( + _userRepository, + _cipherRepository, + _organizationUserRepository, + _organizationRepository, + _u2fRepository, + _mailService, + _pushService, + _userStore, + _optionsAccessor, + _passwordHasher, + _userValidators, + _passwordValidators, + _keyNormalizer, + _errors, + _services, + _logger, + _licenseService, + _eventService, + _applicationCacheService, + _dataProtectionProvider, + _paymentService, + _currentContext, + _globalSettings + ); + } + + // Remove this test when we add actual tests. It only proves that + // we've properly constructed the system under test. + [Fact] + public void ServiceExists() + { + Assert.NotNull(_sut); + } + } +}