public async void ListDefinedTerms_Returns_Terms_Test()
        {
            var termsService = new TermsService(_definitionRepositorymock.Object);
            var definitions  = await termsService.ListDefinedTerms();

            Assert.IsNotNull(definitions);
            Assert.IsTrue(definitions.Any());
        }
Exemple #2
0
    protected async Task <TermsWithContent> GetNewestTerms(Guid userId, string language)
    {
        return((await Cache.GetOrCreateAsync($"terms-{language}-{userId}", async e => {
            e.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(60);

            return await TermsService.GetNewestTermsAsync("terms", userId.ToString(), language);
        })).Data);
    }
        public async void ListDefinedTerms_Returns_Terms_Returns_Synonyms()
        {
            var termsService = new TermsService(_definitionRepositorymock.Object);
            var definitions  = await termsService.ListDefinedTerms();

            Assert.IsNotNull(definitions);
            Assert.AreEqual(4, definitions.Count());
            Assert.AreEqual(TEST_SYNONYM, definitions.Last().Term);
        }
Exemple #4
0
    public async Task <IActionResult> AcceptTerms()
    {
        Guid   userId   = GetUserId();
        string language = Request.GetCurrentLanguage();

        TermsWithContent newestTerms = await GetNewestTerms(userId, language);

        await TermsService.MarkReadAsync(newestTerms.Id, userId.ToString(), language);

        //Clear cache so we get the updated boolean that the user has read the terms
        Cache.Remove($"terms-{language}-{userId}");

        return(RedirectToAction("index", new { lang = language }));
    }
 public RequireAcceptedTerms()
 {
     AllowedRoutes = new List <RouteDescriptor>();
     AllowedRoutes.Add(new RouteDescriptor {
         Controller = "Terms", Action = "Index"
     });
     AllowedRoutes.Add(new RouteDescriptor {
         Controller = "Terms", Action = "Accept"
     });
     AllowedRoutes.Add(new RouteDescriptor {
         Controller = "Account", Action = "Logout"
     });
     AllowedRoutes.Add(new RouteDescriptor {
         Controller = "Payments", Action = "PaySchedules "
     });
     TermsService = new TermsService();
 }
        private async Task <IEnumerable <NHS111.Models.Models.Domain.DefinedTerm> > SetupAndRunFindContainedTerms(string inputString)
        {
            var termsService = new TermsService(_definitionRepositorymock.Object);

            return(await termsService.FindContainedTerms(inputString));
        }