public async Task UpdateLeilaoComSucesso()
        {
            //Arranje
            var faker             = new Faker("pt_BR");
            var leilaoRepository  = new LeilaoRepository(this.Context);
            var usuarioRepository = new UsuarioRepository(this.Context);
            var usuarioId         = await usuarioRepository.InsertAsync(new Usuario(faker.Name.FullName(), faker.Internet.Email()));

            var leilaoId = await leilaoRepository.InsertAsync(
                new Leilao(usuarioId, "Teste leilão GetLeilaoIdComSucesso", null, DateTime.UtcNow, DateTime.UtcNow.AddDays(50), 250.50)
                );


            Leilao leilao = await leilaoRepository.GetByIdAsync(leilaoId);

            string leilaoTituloUpdate = "Titulo leilão Update";

            leilao.Update(new LeilaoUpdate(leilaoId, usuarioId, leilaoTituloUpdate, null, null, null, null));
            //Act
            await leilaoRepository.UpdateAsync(leilao);

            //Assert
            Leilao leilaoUpdate = await leilaoRepository.GetByIdAsync(leilaoId);

            Assert.Equal(leilaoTituloUpdate, leilaoUpdate.Titulo);
        }
        public async Task IncluirLeilaoComSucessoAsync()
        {
            //Arranje
            var faker             = new Faker("pt_BR");
            var leilaoRepository  = new LeilaoRepository(this.Context);
            var usuarioRepository = new UsuarioRepository(this.Context);
            var usuarioId         = await usuarioRepository.InsertAsync(new Usuario(faker.Name.FullName(), faker.Internet.Email()));

            //Act
            var leilao = await leilaoRepository.InsertAsync(
                new Leilao(usuarioId, "Teste leilão", null, DateTime.UtcNow, DateTime.UtcNow.AddDays(5), 250.50)
                );

            //Assert
            Assert.NotNull(leilao);
        }
        public async Task GetLeiloadoPorIdComSucessoAsync()
        {
            //Arranje
            var faker             = new Faker("pt_BR");
            var leilaoRepository  = new LeilaoRepository(this.Context);
            var usuarioRepository = new UsuarioRepository(this.Context);
            var usuarioId         = await usuarioRepository.InsertAsync(new Usuario(faker.Name.FullName(), faker.Internet.Email()));

            var leilaoId = await leilaoRepository.InsertAsync(
                new Leilao(usuarioId, "Teste leilão GetLeilaoIdComSucesso", null, DateTime.UtcNow, DateTime.UtcNow.AddDays(50), 250.50)
                );

            //Act
            IList <Leilao> leiloes = await leilaoRepository.GetAllByLeiloadoPorIdAsync(usuarioId);

            //Assert
            Assert.NotNull(leiloes.Where(w => w.Id == leilaoId).FirstOrDefault());
        }
        public async Task GetLeilaoIdAndLeiloadoPorIdComSucessoAsync()
        {
            //Arranje
            var faker             = new Faker("pt_BR");
            var leilaoRepository  = new LeilaoRepository(this.Context);
            var usuarioRepository = new UsuarioRepository(this.Context);
            var usuarioId         = await usuarioRepository.InsertAsync(new Usuario(faker.Name.FullName(), faker.Internet.Email()));

            var leilaoId = await leilaoRepository.InsertAsync(
                new Leilao(usuarioId, "Teste leilão GetLeilaoIdComSucesso", null, DateTime.UtcNow, DateTime.UtcNow.AddDays(50), 250.50)
                );

            //Act
            Leilao leilao = await leilaoRepository.GetByIdAndLeiloadoPorIdAsync(leilaoId, usuarioId);

            //Assert
            Assert.Equal(leilao.Id, leilaoId);
        }
Пример #5
0
        public async Task DeleteLeilaoImagemComSucesso()
        {
            //Arranje
            var faker = new Faker("pt_BR");
            var leilaoImagemRepository = new LeilaoImagemRepository(this.Context);
            var leilaoRepository       = new LeilaoRepository(this.Context);
            var usuarioRepository      = new UsuarioRepository(this.Context);
            var usuarioId = await usuarioRepository.InsertAsync(new Usuario(faker.Name.FullName(), faker.Internet.Email()));

            var leilaoId = await leilaoRepository.InsertAsync(
                new Leilao(usuarioId, "Teste leilão", null, DateTime.UtcNow, DateTime.UtcNow.AddDays(5), 250.50)
                );


            var leilaoImagemId = await leilaoImagemRepository.InsertAsync(
                new LeilaoImagem(usuarioId, leilaoId, "url-da-imagem.png")
                );

            //Act
            await leilaoImagemRepository.DeleteAsync(leilaoImagemId);
        }
        public async Task GetAllComSucesso()
        {
            //Arranje
            var faker             = new Faker("pt_BR");
            var leilaoRepository  = new LeilaoRepository(this.Context);
            var usuarioRepository = new UsuarioRepository(this.Context);
            var usuarioId         = await usuarioRepository.InsertAsync(new Usuario(faker.Name.FullName(), faker.Internet.Email()));

            var totalLeiloes = 20;

            for (int i = 0; i < totalLeiloes; i++)
            {
                var leilaoId = await leilaoRepository.InsertAsync(
                    new Leilao(usuarioId, faker.Internet.UserNameUnicode(), null, DateTime.UtcNow, DateTime.UtcNow.AddDays(50), 250.50)
                    );
            }

            //Act
            LeilaoPaginacao leiloes = await leilaoRepository.GetAllAsync(new LeilaoPaginacao(porPagina : 20, pagina : 1, leiloadoPorId : usuarioId));

            //Assert
            Assert.Equal(leiloes.Resultados.Count, totalLeiloes);
        }