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 GetInvalid() { var id = Guid.NewGuid(); IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext(); AdministratorRepository adminRepo = new AdministratorRepository(IMMRequestContext); adminRepo.Get(id); }
public void GetOneAdministrator() { 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); var category = repository.Get(listAdministrators[0].Id); context.Database.EnsureDeleted(); Assert.AreEqual(listAdministrators[0].Id, category.Id); }
public void DeleteAdministrator() { var options = new DbContextOptionsBuilder <BetterCalmContext>() .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options; var context = new BetterCalmContext(options); listAdministrators.ForEach(track => context.Add(track)); context.SaveChanges(); repository = new AdministratorRepository(context); repository.Delete(listAdministrators[0]); context.Database.EnsureDeleted(); Administrator getAdmin = repository.Get(1); Assert.AreEqual(null, getAdmin); }
public void testGet() { // Arrange int count = repo.All().Count(); this.repo.Add(entity); this.repo.SaveChanges(); // Act Administrator actual = repo.Get(x => (x.FirstName == fn && x.LastName == ln)).FirstOrDefault(); // Assert Assert.NotNull(actual); this.repo.HardDelete(entity); this.repo.SaveChanges(); }
public async Task <Administrator> Get(long id) { return(await _repository.Get(id)); }