private async Task <List <Cliente> > InsereRegistros() { var clientes = clienteFaker.Generate(100); foreach (var cli in clientes) { cli.Id = 0; await context.Clientes.AddAsync(cli); } await context.SaveChangesAsync(); return(clientes); }
public async Task GetClientesAsync_Sucesso() { var listaClientes = ClienteFaker.Generate(10); repository.GetClientesAsync().Returns(listaClientes); var controle = mapper.Map <IEnumerable <Cliente>, IEnumerable <ClienteView> >(listaClientes); var retorno = await manager.GetClientesAsync(); await repository.Received().GetClientesAsync(); retorno.Should().BeEquivalentTo(controle); }
public ClienteRepositoryTest() { var optionsBuilder = new DbContextOptionsBuilder <ClContext>(); optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); context = new ClContext(optionsBuilder.Options); repository = new ClienteRepository(context); clienteFaker = new ClienteFaker(); cliente = clienteFaker.Generate(); }
public ClienteManagerTest() { repository = Substitute.For <IClienteRepository>(); logger = Substitute.For <ILogger <ClienteManager> >(); mapper = new MapperConfiguration(p => p.AddProfile <NovoClienteMappingProfile>()).CreateMapper(); manager = new ClienteManager(repository, mapper, logger); ClienteFaker = new ClienteFaker(); NovoClienteFaker = new NovoClienteFaker(); AlteraClienteFaker = new AlteraClienteFaker(); Cliente = ClienteFaker.Generate(); NovoCliente = NovoClienteFaker.Generate(); AlteraCliente = AlteraClienteFaker.Generate(); }