Esempio n. 1
0
        private void configuraReputacaoRepository(Mock <IReputacaoRepository> ReputacaoRepository)
        {
            ReputacaoRepository
            .Setup(s => s.Adicionar(It.IsAny <Reputacao>()))
            .ReturnsAsync(true);

            List <Reputacao> listaMock = new List <Reputacao>();

            Reputacao itemMock = new Reputacao
            {
                Id    = 1,
                Isbn  = "123456",
                Autor = "Autor1",
                Nota  = 5
            };

            Reputacao itemMock2 = new Reputacao
            {
                Id    = 2,
                Isbn  = "654321",
                Autor = "Autor1",
                Nota  = 4
            };

            listaMock.Add(itemMock);
            listaMock.Add(itemMock2);

            ReputacaoRepository
            .Setup(s => s.Obter("123456"))
            .ReturnsAsync(listaMock.Where(o => o.Isbn == "123456"));

            ReputacaoRepository
            .Setup(s => s.Remover("123456", 1))
            .ReturnsAsync(true);
        }
Esempio n. 2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Idplataforma != null)
         {
             hashCode = hashCode * 59 + Idplataforma.GetHashCode();
         }
         if (Idusuarioplatafaorma != null)
         {
             hashCode = hashCode * 59 + Idusuarioplatafaorma.GetHashCode();
         }
         if (Nome != null)
         {
             hashCode = hashCode * 59 + Nome.GetHashCode();
         }
         if (Avatar != null)
         {
             hashCode = hashCode * 59 + Avatar.GetHashCode();
         }
         if (Email != null)
         {
             hashCode = hashCode * 59 + Email.GetHashCode();
         }
         if (Reputacao != null)
         {
             hashCode = hashCode * 59 + Reputacao.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 3
0
        public async Task <bool> Adicionar(Reputacao item)
        {
            _virtualRepository.Add(item);

            WriteListInFile();

            return(true);
        }
Esempio n. 4
0
        public void AdicionarTestes()
        {
            var appService = serviceProvider.GetService <IReputacaoService>();

            Reputacao itemMock = new Reputacao
            {
                Id    = 3,
                Isbn  = "789123",
                Autor = "Autor1",
                Nota  = 5
            };

            bool retorno = appService.Adicionar(itemMock).Result;

            Assert.True(retorno);
        }
Esempio n. 5
0
        public async Task Post(Reputacao item)
        {
            var uri = new Uri(string.Format("{0}", url));

            using (var cliente = new HttpClient())
            {
                var data    = JsonConvert.SerializeObject(item);
                var content = new StringContent(data, Encoding.UTF8, "application/json");

                HttpResponseMessage response = await cliente.PostAsync(uri, content);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Falha ao realizar inclusao de reputacao!");
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Returns true if Usuarioplataformaitem instances are equal
        /// </summary>
        /// <param name="other">Instance of Usuarioplataformaitem to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Usuarioplataformaitem other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Idplataforma == other.Idplataforma ||
                     Idplataforma != null &&
                     Idplataforma.Equals(other.Idplataforma)
                     ) &&
                 (
                     Idusuarioplatafaorma == other.Idusuarioplatafaorma ||
                     Idusuarioplatafaorma != null &&
                     Idusuarioplatafaorma.Equals(other.Idusuarioplatafaorma)
                 ) &&
                 (
                     Nome == other.Nome ||
                     Nome != null &&
                     Nome.Equals(other.Nome)
                 ) &&
                 (
                     Avatar == other.Avatar ||
                     Avatar != null &&
                     Avatar.Equals(other.Avatar)
                 ) &&
                 (
                     Email == other.Email ||
                     Email != null &&
                     Email.Equals(other.Email)
                 ) &&
                 (
                     Reputacao == other.Reputacao ||
                     Reputacao != null &&
                     Reputacao.Equals(other.Reputacao)
                 ));
        }
 public async Task <bool> Adicionar(Reputacao item)
 {
     return(await _reputacaoRepository.Adicionar(item));
 }
 public async Task Post([FromBody] Reputacao item)
 {
     await _reputacaoService.Adicionar(item);
 }
 public async Task Adicionar(Reputacao item)
 {
     await _reputacaoAdapter.Post(item);
 }