public void AddManagerShouldAddManager() { using (var context = new StoreDBContext(options)) { IManagerRepository _repo = new ManagerRepoDB(context); _repo.AddManager ( new Model.Manager { Id = 2, ManagerName = "Batman", ManagerEmail = "*****@*****.**", ManagerPasswordHash = "Pa55WordI23", ManagerPhone = "7948062079", ManagerLocId = 1 } ); } //use the context to check the state of the db directly when asserting. using (var assertContext = new StoreDBContext(options)) { var result = assertContext.Managers.FirstOrDefault(manager => manager.ManagerName == "Batman"); Assert.NotNull(result); Assert.Equal("Batman", result.ManagerName); } }
public void GetManagerByEmailShouldRetuenManager() { using (var context = new StoreDBContext(options)) { IManagerRepository _repo = new ManagerRepoDB(context); var foundManager = _repo.GetManagerByEmail("*****@*****.**"); Assert.NotNull(foundManager); Assert.Equal("*****@*****.**", foundManager.ManagerEmail); } }
public void GetAllManagersShouldReturnAllManagers() { //This is a using block, at the end of the execution of the code surrounded by the block, the //unmanaged resource is going to be disposed of using (var context = new StoreDBContext(options)) { //Arrange IManagerRepository _repo = new ManagerRepoDB(context); //Act var managers = _repo.GetManagers(); Assert.Equal(2, managers.Count); } }
public void UpdateManagerShouldUpdate() { using (var context = new StoreDBContext(options)) { IManagerRepository _repo = new ManagerRepoDB(context); _repo.UpdateManager( new Model.Manager { Id = 1, ManagerName = "Aquaperson", ManagerEmail = "*****@*****.**", ManagerPasswordHash = "PassW0rd12E", ManagerPhone = "9702608497", ManagerLocId = 1 } ); } }
public void DeleteShouldDelete() { using (var context = new StoreDBContext(options)) { IManagerRepository _repo = new ManagerRepoDB(context); _repo.DeleteManager( new Model.Manager { Id = 1, ManagerName = "Aquaman", ManagerEmail = "*****@*****.**", ManagerPasswordHash = "PassW0rd12E", ManagerPhone = "9702608497", ManagerLocId = 2 } ); } using (var assertContext = new StoreDBContext(options)) { var result = assertContext.Managers.Find(1); Assert.Null(result); } }