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
using Hangfire; | |
using Hangfire.SqlServer; | |
/// <summary> | |
/// specifies if hangfire job run or not | |
/// </summary> | |
protected bool HangFireEnabled => Configuration.GetSection("GeneralApplicationSettings").GetValue<bool>("HangFireEnabled"); | |
/// <summary> | |
/// configures Hangfire functionality (async jobs) |
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
RecurringJob.AddOrUpdate<UserGroupRolesSyncService>(nameof(UserGroupRolesSyncService), | |
x => x.SyncUserGroupRolesData(), | |
"0 10 17 * * *"); |
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
using Hangfire; | |
using Hangfire.SqlServer; | |
/// <summary> | |
/// specifies if hangfire job run or not | |
/// </summary> | |
protected bool HangFireEnabled => Configuration.GetSection("GeneralApplicationSettings").GetValue<bool>("HangFireEnabled"); | |
/// <summary> | |
/// configures Hangfire functionality (async jobs) |
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
using Hangfire; | |
using Hangfire.SqlServer; | |
/// <summary> | |
/// specifies if hangfire job run or not | |
/// </summary> | |
protected bool HangFireEnabled => Configuration.GetSection("GeneralApplicationSettings").GetValue<bool>("HangFireEnabled"); | |
/// <summary> | |
/// configures Hangfire functionality (async jobs) |
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
Kernel.Rebind<IEnvironmentProxyService>().To<EnvironmentProxyServiceMock>(); |
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 EnvironmentProxyServiceMock : IEnvironmentProxyService | |
{ | |
public List<EnvironmentServiceModel> Environments => EnvironmentInitialData.EnvironmentServiceModels; | |
public Dictionary<int, EnvironmentServiceModel> EnvironmentsMap => Environments.ToDictionary(item => item.EnvironmentId, item => item); | |
public EnvironmentServiceModel Get(int environmentId) => EnvironmentsMap.ContainsKey(environmentId) ? EnvironmentsMap[environmentId] : null; | |
public List<EnvironmentTypeApiModel> EnvironmentTypes => EnvironmentInitialData.EnvironmentTypeModels; |
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
/// <summary> | |
/// gets a list of environment service models | |
/// </summary> | |
/// <param name="applySecurity">specifies if current user security rules should be applied</param> | |
/// <param name="enabledOnly">specifies if only enabled environments will be returned</param> | |
/// <returns>a list of environment service models</returns> | |
public List<EnvironmentServiceModel> GetAllEnvironments(bool applySecurity, bool enabledOnly) | |
{ | |
var serviceModels = EnvironmentProxyService.Environments.Where(env => !enabledOnly || env.IsEnabled); | |
if (!applySecurity) |
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
[Test] | |
public void GetAllEnvironmentsTest() | |
{ | |
//DEV USER -> Only Enabled | |
ResetData(currentUserId: 1000); | |
var envDataDev1 = EnvironmentService.GetAllEnvironments(applySecurity: true, enabledOnly: true); | |
Assert.IsTrue(envDataDev1.Count == 2, "GetAllEnvironments count failed for enabled only"); | |
//DEV USER -> Enabled and Disabled | |
ResetData(currentUserId: 1000); |
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 void FakeCurrentUser(int userId) | |
{ | |
var userRef = DataAccess.AppUserRepository.AllNoTracking.FirstOrDefault(u => u.AppUserId == userId); | |
var securitySubstitude = Substitute.ForPartsOf<SecurityService>( | |
Kernel.Get<IScopedDataAccess>(), | |
Kernel.Get<IMappingService>(), | |
Kernel.Get<ILoggingService>(), | |
Kernel.Get<IEnvironmentProxyService>()); |
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
protected void RegisterCustomServicesForServiceTesting() | |
{ | |
// IRepository<T> should be solved using InMemoryRepository<T>, by default | |
Kernel.Rebind(typeof(IRepository<>)).To(typeof(InMemoryRepository<>)); | |
// IRepository<T> must be solved to Repository<T>, if used in CachedRepository<T> | |
Kernel.Rebind(typeof(IRepository<>)).To(typeof(InMemoryRepository<>)).WhenInjectedInto(typeof(CachedRepository<>)); | |
var nonCachedTypes = NinjectCommon.GetNonCachedTypes(); | |
nonCachedTypes.ForEach(type => |
NewerOlder