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 IPolicyRepository _policyRepository; private readonly IReferenceEventService _referenceEventService; private readonly CurrentContext _currentContext; private readonly GlobalSettings _globalSettings; private readonly IOrganizationService _organizationService; 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(); _policyRepository = Substitute.For(); _referenceEventService = Substitute.For(); _currentContext = new CurrentContext(); _globalSettings = new GlobalSettings(); _organizationService = Substitute.For(); _sut = new UserService( _userRepository, _cipherRepository, _organizationUserRepository, _organizationRepository, _u2fRepository, _mailService, _pushService, _userStore, _optionsAccessor, _passwordHasher, _userValidators, _passwordValidators, _keyNormalizer, _errors, _services, _logger, _licenseService, _eventService, _applicationCacheService, _dataProtectionProvider, _paymentService, _policyRepository, _referenceEventService, _currentContext, _globalSettings, _organizationService ); } // 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); } } }