コード例 #1
0
        public async Task BuscarEditoraPorId_DeveRetornarComSucesso()
        {
            var newId            = Guid.NewGuid();
            var mapper           = new Mock <IMapper>();
            var notificador      = new Notificador();
            var editora          = new Domain.Entities.Editora(newId, "Editora Fake", "*****@*****.**", "Brasil");
            var editoraViewModel = new EditoraViewModel
            {
                Id    = editora.Id,
                Nome  = editora.Nome,
                Email = editora.Email,
                Pais  = editora.Pais
            };

            var query = new Mock <IEditoraRepository>();

            query.Setup(x => x.BuscarEditoraPorId(It.IsAny <Guid>()))
            .ReturnsAsync(editora);
            mapper.Setup(x => x.Map <EditoraViewModel>(It.IsAny <Domain.Entities.Editora>()))
            .Returns(editoraViewModel);

            var useCase   = new BuscarEditoraPorIdUseCase(query.Object, notificador, mapper.Object);
            var resultado = await useCase.Executar(newId);

            resultado.Should().Be(editoraViewModel);
        }
コード例 #2
0
 public static EditoraViewModel ConverterEditoraParaViewModel(Domain.Entities.Editora editora)
 {
     return(new EditoraViewModel
     {
         Id = editora.Id,
         Nome = editora.Nome,
         Email = editora.Email,
         Pais = editora.Pais
     });
 }