public async Task E_Possivel_Invocar_a_Controller_Get() { var serviceMock = new Mock <IUfService>(); var sigla = "RS"; var nome = "Rio Grande do Sul"; serviceMock.Setup(c => c.Get(It.IsAny <Guid>())).ReturnsAsync( new UfDto { Id = Guid.NewGuid(), Sigla = sigla, Nome = nome } ); _controller = new UfsController(serviceMock.Object); var result = await _controller.Get(Guid.NewGuid()); Assert.True(result is OkObjectResult); var resultValue = ((OkObjectResult)result).Value as UfDto; Assert.NotNull(resultValue); Assert.Equal(sigla, resultValue.Sigla); Assert.Equal(nome, resultValue.Nome); }
public async Task E_Possivel_Invocar_a_Controller_GetAll() { var serviceMock = new Mock <IUfService>(); serviceMock.Setup(m => m.GetAll()).ReturnsAsync( new List <UfDto> { new UfDto { Id = Guid.NewGuid(), Nome = "São Paulo", Sigla = "SP", }, new UfDto { Id = Guid.NewGuid(), Nome = "Amazonas", Sigla = "AM", } } ); _controller = new UfsController(serviceMock.Object); var result = await _controller.GetAll(); Assert.True(result is OkObjectResult); }
public async Task PossivelGetAllUf() { var serviceMock = new Mock <IUfService>(); serviceMock.Setup(m => m.GetAll()). ReturnsAsync( new List <UfDto> { new UfDto { Id = Guid.NewGuid(), Nome = "São Paulo", Sigla = "Sp", }, new UfDto { Id = Guid.NewGuid(), Nome = "Amazonas", Sigla = "Am", } } ); _controller = new UfsController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato invalido"); var result = await _controller.GetAll(); Assert.True(result is BadRequestObjectResult); }
public async Task E_Possivel_Invocar_a_Controller_GetAll() { var serviceMock = new Mock <IUfService>(); serviceMock.Setup(m => m.GetAll()).ReturnsAsync( new List <UfDto> { new UfDto { Id = Guid.NewGuid(), Estado = "Rio de Janeiro", Sigla = "Rj", }, new UfDto { Id = Guid.NewGuid(), Estado = "Amazonas", Sigla = "AM", } } ); _controller = new UfsController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato Invalido"); var result = await _controller.GetAll(); Assert.True(result is BadRequestObjectResult); }
public async Task E_Possivel_Invocar_a_Controller_GetAll() { var serviceMock = new Mock <IUfService>(); serviceMock.Setup(c => c.GetAll()).ReturnsAsync( new List <UfDto> { new UfDto { Id = Guid.NewGuid(), Sigla = "RS", Nome = "Rio Grande do Sul", }, new UfDto { Id = Guid.NewGuid(), Sigla = "SP", Nome = "São Paulo", } } ); _controller = new UfsController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato Invalido"); var result = await _controller.GetAll(); Assert.True(result is BadRequestObjectResult); }
public async Task E_Possivel_Invocar_a_Controller_Get() { var serviceMock = new Mock <IUfService>(); serviceMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(Task.FromResult((UfDto)null)); _controller = new UfsController(serviceMock.Object); var result = await _controller.Get(Guid.NewGuid()); Assert.True(result is NotFoundResult); }
public async Task E_Possivel_Invocar_a_Controller_Get() { var serviceMock = new Mock <IUfService>(); serviceMock.Setup(m => m.Get(It.IsAny <Guid>())).ReturnsAsync( new UfDto { Id = Guid.NewGuid(), Nome = "São Paulo", Sigla = "SP" } ); _controller = new UfsController(serviceMock.Object); var result = await _controller.Get(Guid.NewGuid()); Assert.True(result is OkObjectResult); }
public async Task Get() { var serviceMock = new Mock <IUfService>(); serviceMock.Setup(m => m.Get(It.IsAny <Guid>())).ReturnsAsync( new Domain.Dtos.Uf.UfDto { Id = Guid.NewGuid(), Nome = "São Paulo", Sigla = "SP" }); _controller = new UfsController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato Inválido"); var result = await _controller.Get(Guid.NewGuid()); Assert.True(result is BadRequestObjectResult); }
public async Task E_Possivel_Invocar_a_Controller_Get() { var serviceMock = new Mock <IUfService>(); var sigla = "RS"; var nome = "Rio Grande do Sul"; serviceMock.Setup(c => c.Get(It.IsAny <Guid>())).ReturnsAsync( new UfDto { Id = Guid.NewGuid(), Sigla = sigla, Nome = nome } ); _controller = new UfsController(serviceMock.Object); _controller.ModelState.AddModelError("Id", "Formato invalido"); var result = await _controller.Get(Guid.NewGuid()); Assert.True(result is BadRequestObjectResult); }