Exemplo n.º 1
0
 public LockManager(LockRepository lockRepository, string instanceName, string instanceId, int lockTtlSeconds)
 {
     _lockRepository = lockRepository;
     _instanceName   = instanceName;
     _instanceId     = instanceId;
     _lockTtl        = lockTtlSeconds;
 }
 public LockInstance(LockManager lockManager, LockType lockType, string instanceId)
 {
     _lockManager    = lockManager;
     LockType        = lockType;
     InstanceId      = instanceId;
     _lockRepository = lockManager._lockRepository;
 }
Exemplo n.º 3
0
 public EventsController(EventRepository repository, IMapper mapper, IHubContext <EventHub> hubContext, UserManager <User> userManager, LockRepository lockManager, SignalREventService signalREventService, IHttpContextAccessor httpContext)
 {
     _repository          = repository;
     _mapper              = mapper;
     _userManager         = userManager;
     _lockRepository      = lockManager;
     _signalREventService = signalREventService;
     _httpContext         = httpContext;
 }
Exemplo n.º 4
0
        public void Resource_And_Parent_Folder_Should_Have_Been_Unlocked()
        {
            Assert.AreEqual(ResourceLockState.ReadOnly, LockRepository.GetLockState(SourceFile.FullName.ToLowerInvariant()));
            Assert.AreEqual(ResourceLockState.ReadOnly, LockRepository.GetLockState(SourceFile.Directory.FullName.ToLowerInvariant()));

            //expire and wait for the scheduler to readjust
            SystemTime.Now = () => Token.ExpirationTime.Value.AddSeconds(1);
            Thread.CurrentThread.Join(500);

            Assert.AreEqual(ResourceLockState.Unlocked, LockRepository.GetLockState(SourceFile.FullName.ToLowerInvariant()));
            Assert.AreEqual(ResourceLockState.Unlocked, LockRepository.GetLockState(SourceFile.Directory.FullName.ToLowerInvariant()));
        }
        public void Read_Lock_Should_Have_Been_Established_For_Resources_Parent_Folders()
        {
            DirectoryInfo dir = SourceFile.Directory;

            while (dir.Name != rootDirectory.Name)
            {
                var lockState = LockRepository.GetLockState(dir.FullName.ToLowerInvariant());
                Assert.AreEqual(ResourceLockState.ReadOnly, lockState, "Folder is not locked: " + dir.FullName);

                dir = dir.Parent;
            }
        }
        public void Getting_The_Stream_Should_Lock_File()
        {
            string resourceId = SourceFile.FullName.ToLowerInvariant();

            var state = LockRepository.GetLockState(resourceId);

            Assert.AreEqual(ResourceLockState.Unlocked, state);

            using (Stream stream = DownloadHandler.ReadFile(resourceId))
            {
                state = LockRepository.GetLockState(resourceId);
                Assert.AreEqual(ResourceLockState.ReadOnly, state);
            }
        }
Exemplo n.º 7
0
 public GenericLockableRepository(AppDbContext context, IHttpContextAccessor contextAccessor, LockRepository lockManager)
 {
     _context     = context;
     _lockManager = lockManager;
 }
 public LockManager(IMongoDatabase database, string instanceName, string collectionPrefix)
 {
     _lockRepository = new LockRepository(database, instanceName, collectionPrefix);
 }
Exemplo n.º 9
0
 public EventRepository(AppDbContext context, IHttpContextAccessor contextAccessor, LockRepository lockManager) : base(context, contextAccessor, lockManager)
 {
 }
Exemplo n.º 10
0
 public EventHub(UserManager <User> userManager, LockRepository lockManager)
 {
     _userManager = userManager;
     _lockManager = lockManager;
 }
 public void Read_Lock_Should_Have_Been_Established_For_Resource()
 {
     Assert.AreEqual(ResourceLockState.ReadOnly, LockRepository.GetLockState(SourceFile.FullName.ToLowerInvariant()));
 }