public void TestAdministratorGetAllOK2() { IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext(); AdministratorRepository adminRepo = new AdministratorRepository(IMMRequestContext); adminRepo.Add(new Administrator { Id = Guid.NewGuid(), Name = "Just Testing", Email = "*****@*****.**", Password = "******" }); adminRepo.Add(new Administrator { Id = Guid.NewGuid(), Name = "Just Testing again", Email = "*****@*****.**", Password = "******" }); adminRepo.Save(); var admins = adminRepo.GetAll().ToList().Count(); Assert.AreEqual(2, admins); }
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 TestAdministratorGet2() { var id = Guid.NewGuid(); IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext(); AdministratorRepository adminRepo = new AdministratorRepository(IMMRequestContext); Administrator admin1 = new Administrator() { Id = Guid.NewGuid(), Name = "Just Testing", Email = "*****@*****.**", Password = "******" }; Administrator admin2 = new Administrator() { Id = id, Name = "Just Testing again", Email = "*****@*****.**", Password = "******" }; adminRepo.Add(admin1); adminRepo.Add(admin2); adminRepo.Save(); Assert.AreEqual(adminRepo.Get(id), admin2); }
public void Initialize() { this.options = new DbContextOptionsBuilder <BetterCalmContext>().UseInMemoryDatabase(databaseName: "MSP.BetterCalmDB").Options; this.context = new BetterCalmContext(this.options); this.adminRepository = new AdministratorRepository(this.context); this.sessionLogic = new SessionLogic(this.adminRepository); Administrator admin1 = new Administrator("Mauro", "*****@*****.**", "12345"); Administrator admin2 = new Administrator("Rodrigo", "*****@*****.**", "4567"); adminRepository.Add(admin1); adminRepository.Add(admin2); }
public static void Add(Administrator _Administrator) { try { AdministratorRepository _AdministratorRepository = new AdministratorRepository(); _AdministratorRepository.Add(_Administrator); } catch (Exception ex) { throw ex; } }
public void AddAdministrator() { var options = new DbContextOptionsBuilder <BetterCalmContext>() .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options; var context = new BetterCalmContext(options); context.Add(listAdministrators[0]); context.SaveChanges(); repository = new AdministratorRepository(context); var initial = repository.GetAll().Count(); repository.Add(listAdministrators[1]); var final = repository.GetAll().Count(); context.Database.EnsureDeleted(); Assert.AreEqual(initial + 1, final); }
public void TestAdministratorGetAll3() { IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext(); AdministratorRepository adminRepo = new AdministratorRepository(IMMRequestContext); Administrator admin = new Administrator() { Id = Guid.NewGuid(), Name = "Just Testing", Email = "*****@*****.**", Password = "******" }; adminRepo.Add(admin); adminRepo.Save(); var admins = adminRepo.GetAll().ToList(); Assert.AreEqual(admins.First(), admin); }