Exemplo n.º 1
0
        public async Task <IActionResult> Add([FromBody] CreateTranslateCommand createTranslate)
        {
            var result = await Mediator.Send(createTranslate);

            if (result.Success)
            {
                return(Ok(result.Message));
            }
            return(BadRequest(result.Message));
        }
        public async Task Translate_CreateCommand_NameAlreadyExist()
        {
            //Arrange
            CreateTranslateCommand command = new CreateTranslateCommand();

            //propertyler buraya yazılacak
            //command.TranslateName = "test";

            _translateRepository.Setup(x => x.Query())
            .Returns(new List <Translate> {
                new Translate() /*TODO:propertyler buraya yazılacak TranslateId = 1, TranslateName = "test"*/ }
                {
}.AsQueryable());
        public async Task Translate_CreateCommand_Success()
        {
            Translate rt = null;
            //Arrange
            CreateTranslateCommand command = new CreateTranslateCommand();

            //propertyler buraya yazılacak
            //command.TranslateName = "deneme";

            _translateRepository.Setup(x => x.GetAsync(It.IsAny <Expression <Func <Translate, bool> > >()))
            .ReturnsAsync(rt);

            _translateRepository.Setup(x => x.Add(It.IsAny <Translate>())).Returns(new Translate());

            CreateTranslateCommandHandler handler = new CreateTranslateCommandHandler(_translateRepository.Object, _mediator.Object);
            var x = await handler.Handle(command, new System.Threading.CancellationToken());

            _translateRepository.Verify(x => x.SaveChangesAsync());
            Assert.That(x.Success, Is.True);
            Assert.That(x.Message, Is.EqualTo(Messages.Added));
        }
 public async Task <IActionResult> Add([FromBody] CreateTranslateCommand createTranslate)
 {
     return(GetResponseOnlyResultMessage(await Mediator.Send(createTranslate)));
 }