Example #1
0
 private void SetupRepository()
 {
     #region Inserts
     _contaRepository.InsertOneAsync(null, Arg.Any <CancellationToken>()).Returns(Task.FromResult(string.Empty));
     _contaRepository.InsertOneAsync(Arg.Is <Conta>(x => x.Id == "0"), Arg.Any <CancellationToken>()).Returns(Task.FromResult(string.Empty));
     _contaRepository.InsertOneAsync(Arg.Is <Conta>(x => x.Id == "ABC"), Arg.Any <CancellationToken>()).Returns(Task.FromResult("1"));
     #endregion
     #region Gets
     _contaRepository.GetByIdAsync("0").Returns(Task.FromResult(default(Conta)));
     _contaRepository.GetByIdAsync("1").Returns(Task.FromResult(new Conta()
     {
         Id      = "ABC",
         Numero  = "010552-2",
         Cliente = new Cliente
         {
             Nome = "Renan",
             Id   = "ABC"
         }
     }));
     #endregion
     #region Delete
     _contaRepository.DeleteOneAsync("ABC", Arg.Any <CancellationToken>()).Returns(Task.FromResult(long.Parse("1")));
     _contaRepository.DeleteOneAsync("0", Arg.Any <CancellationToken>()).Returns(Task.FromResult(long.Parse("0")));
     #endregion
     #region Update
     _contaRepository.ReplaceOneAsync(Arg.Any <Expression <Func <Conta, bool> > >(), Arg.Is <Conta>(x => x.Id == "0"), Arg.Any <UpdateOptions>()).Returns(Task.FromResult(""));
     _contaRepository.ReplaceOneAsync(Arg.Any <Expression <Func <Conta, bool> > >(), Arg.Is <Conta>(x => x.Id == "ABC"), Arg.Any <UpdateOptions>()).Returns(Task.FromResult("1"));
     _contaRepository.UpdateAccountAsync(Arg.Is <Conta>(x => x.Id == "0")).Returns(false);
     _contaRepository.UpdateAccountAsync(Arg.Is <Conta>(x => x.Id == "ABC")).Returns(true);
     #endregion
 }