Beispiel #1
0
        public async Task Language_GetQueries_Success()
        {
            //Arrange
            GetLanguagesQuery query = new GetLanguagesQuery();

            _languageRepository.Setup(x => x.GetListAsync(It.IsAny <Expression <Func <Language, bool> > >()))
            .ReturnsAsync(new List <Language> {
                new Language()
                {
                    Id = 1, Code = "tr-TR", Name = "Türkçe"
                },
                new Language()
                {
                    Id = 2, Code = "en-US", Name = "English"
                }
            });

            GetLanguagesQueryHandler handler = new GetLanguagesQueryHandler(_languageRepository.Object, _mediator.Object);

            //Act
            var x = await handler.Handle(query, new System.Threading.CancellationToken());

            //Asset
            Assert.That(x.Success, Is.True);
            Assert.That(((List <Language>)x.Data).Count, Is.GreaterThan(1));
        }
Beispiel #2
0
 /// <inheritdoc/>
 public async Task <IEnumerable <LanguageResult> > Handle(GetLanguagesQuery request, CancellationToken cancellationToken)
 {
     return(await this.context
            .Languages
            .AsQueryable()
            .ProjectTo <LanguageResult>(this.mapper.ConfigurationProvider)
            .ToListAsync());
 }
Beispiel #3
0
        public JsonResult GetLanguages(bool filter, bool?isExotic)
        {
            var langagesQuery = new GetLanguagesQuery {
                Filter = filter, IsExotic = isExotic
            };
            var languagesDto = SendQuery <GetLanguagesQuery, IEnumerable <LanguageDTO> >(langagesQuery);

            return(Json(languagesDto));
        }
        public void WhenThereAreNoLanguagesAnEmptyListShouldBeReturned()
        {
            RemoveAllTestLanguages();
            var command   = new GetLanguagesQuery(repo);
            var languages = command.Execute(request).ToList();

            Assert.IsFalse(languages == null);
            Assert.IsFalse(languages.Any());
        }
        public async Task Language_GetQueries_Success()
        {
            //Arrange
            var query = new GetLanguagesQuery();

            _languageRepository.Setup(x => x.GetListAsync(It.IsAny <Expression <Func <Language, bool> > >()))
            .ReturnsAsync(new List <Language> {
                new() { Id = 1, Code = "tr-TR", Name = "Türkçe" },
                new() { Id = 2, Code = "en-US", Name = "English" }
            });
 public LanguageController(
     GetLanguagesQuery getLanguagesCommand,
     GetLanguageByIdQuery getLanguageByIdCommand,
     CreateLanguageCommand createLanguageCommand,
     UpdateLanguageCommand updateLanguageCommand,
     DeleteLanguageCommand deleteLanguageCommand)
 {
     this.getLanguagesCommand    = getLanguagesCommand;
     this.getLanguageByIdCommand = getLanguageByIdCommand;
     this.createLanguageCommand  = createLanguageCommand;
     this.updateLanguageCommand  = updateLanguageCommand;
     this.deleteLanguageCommand  = deleteLanguageCommand;
 }
        public void AllLanguagesInDatabaseAreReturned()
        {
            RemoveAllTestLanguages();
            InsertTestLanguages();

            var command   = new GetLanguagesQuery(repo);
            var languages = command.Execute(request).ToList();

            Assert.IsTrue(languages.Any());
            Assert.IsTrue(languages.Count() == 3);
            Assert.IsTrue(languages.Any(x => x.Name.Equals("Name1")));
            Assert.IsTrue(languages.Any(x => x.Name.Equals("Name2")));
            Assert.IsTrue(languages.Any(x => x.Name.Equals("Name3")));
        }
Beispiel #8
0
 public async Task <IDataResult <IEnumerable <Language> > > Handle(GetLanguagesQuery request, CancellationToken cancellationToken)
 {
     return(new SuccessDataResult <IEnumerable <Language> >(await _languageRepository.GetListAsync()));
 }
Beispiel #9
0
 public override async Task <IEnumerable <KeyValuePair <string, int> > > ExecuteAsync(GetLanguagesQuery query, CancellationToken cancellationToken = new CancellationToken())
 {
     return(await _apiClient.Get <IEnumerable <KeyValuePair <string, int> > >("/api/languages"));
 }
Beispiel #10
0
 public override Task <IEnumerable <KeyValuePair <string, int> > > ExecuteAsync(GetLanguagesQuery query, CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }