public UsuarioRepositorioTeste() { var configServices = ServicesConfiguration.Configure(); _memoryDb = configServices .GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _usuarioRepositorio = new UsuarioRepositorio(_memoryDb); _usuarioTest = _memoryDb.Usuarios.First(); string salt = SenhaHasherHelper.CriarSalt(8); _usuarioFake = new Faker <Usuario>() .RuleFor(u => u.Nome, f => f.Person.FirstName) .RuleFor(u => u.Sobrenome, f => f.Person.LastName) .RuleFor(u => u.Email, f => f.Person.Email) .RuleFor(u => u.Telefone, f => f.Person.Phone) .RuleFor(u => u.Username, f => f.UniqueIndex + f.Person.UserName) .RuleFor(u => u.Senha, f => SenhaHasherHelper.GerarHash(f.Internet.Password(), salt)) .RuleFor(u => u.Salt, salt) .RuleFor(u => u.TipoUsuario, TipoUsuario.Jogador); _usuarioEsperado = new { Nome = "Test", Sobrenome = "One", Username = "******", Email = "*****@*****.**", Telefone = "+551155256325", TipoUsuario = TipoUsuario.ProprietarioQuadra, }; }
public QuadraFutebolRepositorioTeste() { var configServices = ServicesConfiguration.Configure(); _memoryDb = configServices .GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _quadraFutebolRepositorio = new QuadraFutebolRepositorio(_memoryDb); _quadraTeste = _memoryDb.Quadras.First(); _quadrasFake = new Faker <QuadraFutebol>() .RuleFor(sc => sc.Nome, f => f.Company.CompanyName()) .RuleFor(sc => sc.Imagem, f => f.Image.PicsumUrl()) .RuleFor(sc => sc.PrecoHora, f => f.Random.Decimal(80M, 200M)) .RuleFor(sc => sc.Telefone, f => f.Phone.PhoneNumber("(##) ####-####")) .RuleFor(sc => sc.Endereco, f => f.Address.FullAddress()) .RuleFor(sc => sc.Cep, f => f.Address.ZipCode("#####-###")) .RuleFor(sc => sc.Latitude, f => f.Address.Latitude()) .RuleFor(sc => sc.Longitude, f => f.Address.Longitude()) .RuleFor(sc => sc.UsuarioProprietarioId, f => _memoryDb.Usuarios.First().Id); _quadraEsperada = new { Nome = "Soccer Court 3", Imagem = "soccerCourt3.png", PrecoHora = 90M, Telefone = "(11) 3692-1472", Endereco = "Av. teste 321, teste", Cep = "01012-345", Latitude = -23.1096504, Longitude = -46.533172, }; }
public ObterUsuarioPorIdTeste(CustomWebApplicationFactory factory, ITestOutputHelper output) : base(factory, output) { _memoryDb = factory.Services .GetRequiredService <MatchDayAppContext>() .SeedFakeData(); }
public UsuarioHandlerTeste() { var cfg = ServicesConfiguration.Configure(); _memoryDb = cfg.GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _mediator = cfg.GetRequiredService <IMediator>(); _usuarioId = _memoryDb.Usuarios.Last().Id; }
public ConfirmacaoEmailRepositorioTeste() { var configServices = ServicesConfiguration.Configure(); _memoryDb = configServices .GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _confirmacaoEmailRepositorio = new ConfirmacaoEmailRepositorio(_memoryDb); }
public PartidaHandlerTeste() { var cfg = ServicesConfiguration.Configure(); _memoryDb = cfg.GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _mediator = cfg.GetRequiredService <IMediator>(); _partidaId = _memoryDb.Partidas.Last().Id; }
public PartidaRepositorioTeste() { var configServices = ServicesConfiguration.Configure(); _memoryDb = configServices .GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _partidaRepositorio = new PartidaRepositorio(_memoryDb); _partidaTeste = _memoryDb.Partidas.First(); }
public UsuarioServicoTeste() { var cfg = ServicesConfiguration.Configure(); _memoryDb = cfg.GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _uow = cfg.GetRequiredService <IUnitOfWork>(); _usuarioServico = new UsuarioServico(_uow, cfg.GetRequiredService <IMapper>()); }
public TimeHandlerTeste() { var cfg = ServicesConfiguration.Configure(); _memoryDb = cfg.GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _mediator = cfg.GetRequiredService <IMediator>(); _timeId = _memoryDb.Times.Last().Id; _faker = new Faker("pt_BR"); }
public TimeServicoTeste() { var cfg = ServicesConfiguration.Configure(); _memoryDb = cfg.GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _uow = cfg.GetRequiredService <IUnitOfWork>(); _timeServico = new TimeServico(_uow, cfg.GetRequiredService <IMapper>()); _timeId = _memoryDb.Times.Last().Id; }
public PartidaServicoTeste() { var configServices = ServicesConfiguration.Configure(); _memoryDb = configServices .GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _uow = configServices .GetRequiredService <IUnitOfWork>(); _partidaServico = new PartidaServico(_uow, configServices.GetRequiredService <IMapper>()); }
public QuadraFutebolServicoTeste() { var cfg = ServicesConfiguration.Configure(); _memoryDb = cfg.GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _uow = cfg.GetRequiredService <IUnitOfWork>(); _quadraServico = new QuadraFutebolServico(_uow, cfg.GetRequiredService <IMapper>()); _quadraId = _memoryDb.Quadras.Last().Id; }
public TimeRepositorioTeste() { var configServices = ServicesConfiguration.Configure(); _memoryDb = configServices .GetRequiredService <MatchDayAppContext>() .SeedFakeData(); _timeRepositorio = new TimeRepositorio(_memoryDb); _timeTeste = _memoryDb.Times.First(); _timeFake = new Faker <Time>() .RuleFor(u => u.Nome, f => f.Company.CompanyName()) .RuleFor(u => u.Imagem, f => f.Image.PicsumUrl()) .RuleFor(u => u.QtdIntegrantes, f => f.Random.Int(6, 16)) .RuleFor(u => u.UsuarioProprietarioId, f => _memoryDb.Usuarios.First().Id); _timeEsperado = new { Nome = "Team 3", Imagem = "team3.png", QtdIntegrantes = 11 }; }
public QuadraFutebolRepositorio(MatchDayAppContext context) : base(context) { }
public RepositoryBase(MatchDayAppContext context) { _context = context; }
public static MatchDayAppContext SeedFakeData(this MatchDayAppContext testContext) { #region Usuarios var salt = SenhaHasherHelper.CriarSalt(8); var Usuarios = new List <Usuario> { new Usuario { Nome = "Test", Sobrenome = "One", Username = "******", Email = "*****@*****.**", EmailConfirmado = true, Telefone = "+551155256325", Senha = SenhaHasherHelper.GerarHash("test123", salt), Salt = salt, TipoUsuario = TipoUsuario.ProprietarioQuadra, Deletado = true }, new Usuario { Nome = "Test", Sobrenome = "Two", Username = "******", Email = "*****@*****.**", EmailConfirmado = true, Telefone = "+551112345525", Senha = SenhaHasherHelper.GerarHash("test321", salt), Salt = salt, TipoUsuario = TipoUsuario.ProprietarioTime }, new Usuario { Nome = "Test", Sobrenome = "Three", Username = "******", Email = "*****@*****.**", EmailConfirmado = true, Telefone = "+551198765525", Senha = SenhaHasherHelper.GerarHash("test231", salt), Salt = salt, TipoUsuario = TipoUsuario.ProprietarioQuadra } }; testContext.Usuarios.AddRange(Usuarios); testContext.SaveChanges(); #endregion #region Confirmação Email Request var confirmacaoEmail = new ConfirmacaoEmail { Id = Guid.NewGuid(), UsuarioId = Usuarios.Last().Id, RequisicaoEm = DateTime.Now, ChaveConfirmacao = Guid.Parse("C9267B0B-54A1-4971-9ED7-173008905696") }; testContext.ConfirmacaoEmails.AddRange(confirmacaoEmail); testContext.SaveChanges(); #endregion #region Times var teams = new List <Time> { new Time { Nome = "Team 1", Imagem = "team1.png", QtdIntegrantes = 15, UsuarioProprietarioId = testContext.Usuarios.ToList()[0].Id }, new Time { Nome = "Team 2", Imagem = "team2.png", QtdIntegrantes = 13, UsuarioProprietarioId = testContext.Usuarios.ToList()[1].Id }, new Time { Nome = "Team 3", Imagem = "team3.png", QtdIntegrantes = 11, UsuarioProprietarioId = testContext.Usuarios.ToList()[2].Id } }; Usuarios[0].UsuarioTime = new UsuarioTime { UsuarioId = Usuarios[0].Id, TimeId = teams[0].Id, Aceito = true }; Usuarios[1].UsuarioTime = new UsuarioTime { UsuarioId = Usuarios[1].Id, TimeId = teams[1].Id, Aceito = true }; Usuarios[2].UsuarioTime = new UsuarioTime { UsuarioId = Usuarios[2].Id, TimeId = teams[2].Id, Aceito = true }; testContext.Usuarios.UpdateRange(Usuarios); testContext.Times.AddRange(teams); testContext.SaveChanges(); #endregion #region Quadras var quadra = new List <QuadraFutebol> { new QuadraFutebol { Nome = "Soccer Court 1", Imagem = "soccerCourt1.png", PrecoHora = 100M, Telefone = "(11) 1234-5678", Endereco = "Av. teste 10, teste", Cep = "12345-789", Latitude = -23.1278154, Longitude = -46.5552845, UsuarioProprietarioId = testContext.Usuarios.ToList()[0].Id }, new QuadraFutebol { Nome = "Soccer Court 2", Imagem = "soccerCourt2.png", PrecoHora = 110M, Telefone = "(11) 0000-9999", Endereco = "Av. teste 123, teste", Cep = "98745-036", Latitude = -22.3254, Longitude = -43.7595, UsuarioProprietarioId = testContext.Usuarios.ToList()[1].Id }, new QuadraFutebol { Nome = "Soccer Court 3", Imagem = "soccerCourt3.png", PrecoHora = 90M, Telefone = "(11) 3692-1472", Endereco = "Av. teste 321, teste", Cep = "01012-345", Latitude = -23.1096504, Longitude = -46.533172, UsuarioProprietarioId = testContext.Usuarios.ToList()[2].Id } }; testContext.Quadras.AddRange(quadra); testContext.SaveChanges(); #endregion #region Partidas var matches = new List <Partida> { new Partida { PrimeiroTimeId = testContext.Times.ToList()[0].Id, PrimeiroTimeConfirmado = true, SegundoTimeId = testContext.Times.ToList()[2].Id, SegundoTimeConfirmado = true, QuadraFutebolId = testContext.Quadras.ToList()[2].Id, HorasPartida = 1, DataPartida = new DateTime(2020, 10, 20, 21, 0, 0, DateTimeKind.Local), StatusPartida = StatusPartida.Confirmada }, new Partida { PrimeiroTimeId = testContext.Times.ToList()[1].Id, PrimeiroTimeConfirmado = true, SegundoTimeId = testContext.Times.ToList()[0].Id, SegundoTimeConfirmado = false, QuadraFutebolId = testContext.Quadras.ToList()[1].Id, HorasPartida = 1, DataPartida = new DateTime(2020, 10, 19, 18, 0, 0, DateTimeKind.Local), StatusPartida = StatusPartida.AguardandoConfirmacao }, new Partida { PrimeiroTimeId = testContext.Times.ToList()[1].Id, PrimeiroTimeConfirmado = true, SegundoTimeId = testContext.Times.ToList()[2].Id, SegundoTimeConfirmado = true, QuadraFutebolId = testContext.Quadras.ToList()[1].Id, HorasPartida = 1, DataPartida = new DateTime(2020, 10, 21, 19, 0, 0, DateTimeKind.Local), StatusPartida = StatusPartida.Confirmada }, new Partida { PrimeiroTimeId = testContext.Times.ToList()[0].Id, PrimeiroTimeConfirmado = true, SegundoTimeId = testContext.Times.ToList()[1].Id, SegundoTimeConfirmado = true, QuadraFutebolId = testContext.Quadras.ToList()[0].Id, HorasPartida = 1, DataPartida = new DateTime(2020, 10, 16, 20, 0, 0, DateTimeKind.Local), StatusPartida = StatusPartida.Finalizada }, new Partida { PrimeiroTimeId = testContext.Times.ToList()[2].Id, PrimeiroTimeConfirmado = false, SegundoTimeId = testContext.Times.ToList()[1].Id, SegundoTimeConfirmado = true, QuadraFutebolId = testContext.Quadras.ToList()[2].Id, HorasPartida = 1, DataPartida = new DateTime(2020, 10, 18, 17, 0, 0, DateTimeKind.Local), StatusPartida = StatusPartida.Cancelada } }; testContext.Partidas.Add(matches[0]); testContext.SaveChanges(); testContext.Partidas.Add(matches[1]); testContext.SaveChanges(); testContext.Partidas.Add(matches[2]); testContext.SaveChanges(); testContext.Partidas.Add(matches[3]); testContext.SaveChanges(); testContext.Partidas.Add(matches[4]); testContext.SaveChanges(); #endregion foreach (var entity in testContext.ChangeTracker.Entries()) { entity.State = EntityState.Detached; } return(testContext); }
public ConfirmacaoEmailRepositorio(MatchDayAppContext context) => _context = context;
public PartidaRepositorio(MatchDayAppContext context) { _context = context; }
public UnitOfWork(MatchDayAppContext context) => _context = context;
public TimeRepositorio(MatchDayAppContext context) : base(context) { }
public Repository(MatchDayAppContext context) : base(context) { }
public UsuarioRepositorio(MatchDayAppContext context) : base(context) { }