public void Repository_Can_Update_DetachedAsync()
        {
            using (var context = new InMemoryContext())
            {
                IRepository <TabelaTesteWithLongKey, long> repository = new TabelaTesteWithLongKeyRepository(context, GetUserContextService());
                var uow = new UnitOfWork(context, Substitute.For <ILogger <UnitOfWork> >());

                var result = repository.AddOrUpdateAsync(new TabelaTesteWithLongKey()
                {
                    Propriedade = Guid.NewGuid().ToString()
                }).Result;

                var alteracoes = uow.SaveAndCommitAsync().Result;
                Assert.IsTrue(alteracoes == 1);

                var chave = repository.FindAsync(p => p.Propriedade == result.Propriedade).Result.FirstOrDefault();
                Assert.NotNull(chave);
                Assert.IsTrue(chave.Id > 0);

                var registro = new TabelaTesteWithLongKey()
                {
                    Id          = chave.Id,
                    Propriedade = "Alterada_123"
                };

                registro = repository.AddOrUpdateAsync(registro).Result;
                var contextSaveResult = uow.SaveAndCommitAsync().Result;
                Assert.IsTrue(alteracoes == 1);

                registro = repository.GetByIdAsync(registro.Id).Result;
                Assert.NotNull(registro);
                Assert.AreEqual(registro.Propriedade, "Alterada_123");
            }
        }
        public void Repository_Can_Remove_ByIdAsync()
        {
            using (var context = new InMemoryContext())
            {
                IRepository <TabelaTesteWithLongKey, long> repository = new TabelaTesteWithLongKeyRepository(context, GetUserContextService());

                var uow = new UnitOfWork(context, Substitute.For <ILogger <UnitOfWork> >());

                var registro = new TabelaTesteWithLongKey()
                {
                    Propriedade = Guid.NewGuid().ToString()
                };

                var saveResult = repository.AddOrUpdateAsync(registro).Result;

                var alteracoes = uow.SaveAndCommitAsync().Result;
                Assert.IsTrue(alteracoes == 1);

                var removeResult     = repository.RemoveAsync(registro.Id).Result;
                var saveRemoveResult = uow.SaveAndCommitAsync().Result;
                Assert.IsTrue(alteracoes == 1);

                registro = repository.FindAsync(p => p.Id == registro.Id).Result.FirstOrDefault();
                Assert.Null(registro);
            }
        }