Exemple #1
0
        public Task <bool> Delete <T>(T item) where T : BaseModel, new()
        {
            var element = database.Find <WrapRealm <T> >(item.Id);

            if (element != null)
            {
                database.Remove(element);

                return(Task.FromResult(true));
            }

            return(Task.FromResult(false));
        }
Exemple #2
0
        public void ExpireJob_OneDay_SetsJobExpirationData()
        {
            // ARRANGE
            JobDto jobDto        = CreateEmptyJob();
            JobDto anotherJobDto = CreateEmptyJob();

            _realm.Write(() =>
            {
                _realm.Add(jobDto);
                _realm.Add(anotherJobDto);
            });



            var jobId        = jobDto.Id;
            var anotherJobId = anotherJobDto.Id;

            // ACT
            _transaction.ExpireJob(jobId, TimeSpan.FromDays(1));
            _transaction.Commit();

            // ASSERT
            var testJob = _realm.Find <JobDto>(jobId);

            Assert.True(DateTime.UtcNow.AddMinutes(-1) < testJob.ExpireAt && testJob.ExpireAt <= DateTime.UtcNow.AddDays(1));

            var anotherTestJob = _realm.Find <JobDto>(anotherJobId);

            Assert.Null(anotherTestJob.ExpireAt);
        }