public void testUpdate()
        {
            // Arrange
            int count = repo.All().Count();

            repo.Add(entity);
            this.repo.SaveChanges();

            Assert.IsEmpty(repo.Get(x => x.FirstName == fn + "alala" &&
                                    x.LastName == ln));


            Assert.AreEqual(count + 1, repo.All().Count());
            entity.FirstName += "alala";


            // Act
            repo.Update(entity);
            repo.SaveChanges();

            // Assert

            Assert.NotNull(repo.Get(x => x.FirstName == fn + "alala" &&
                                    x.LastName == ln));

            this.repo.HardDelete(entity);
            this.repo.SaveChanges();
        }
        public void UpdateAdministrator()
        {
            var options = new DbContextOptionsBuilder <BetterCalmContext>()
                          .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options;
            var context = new BetterCalmContext(options);

            listAdministrators.ForEach(cat => context.Add(cat));
            context.SaveChanges();
            repository = new AdministratorRepository(context);
            listAdministrators[0].Name = "Nicolas";
            repository.Update(listAdministrators[0]);
            var admin = repository.Get(listAdministrators[0].Id);

            context.Database.EnsureDeleted();
            Assert.AreEqual(admin.Name, "Nicolas");
        }
Exemplo n.º 3
0
 public async Task <Administrator> Update(Administrator entity)
 {
     return(await _administratorRepository.Update(entity));
 }