public void GetAUserShouldReturnResult() { // arrange var options = new DbContextOptionsBuilder <PH_DbContext>() .UseInMemoryDatabase("GetAUserShouldReturnResult") .Options; using var arrangeContext = new PH_DbContext(options); var id = 5; var username = "******"; arrangeContext.Users.Add(new Users { Id = id, Username = username }); arrangeContext.SaveChanges(); using var actContext = new PH_DbContext(options); var repo = new UserRepo(actContext); // act var result = repo.GetAUserAsync(username); // assert Assert.NotNull(result); }
public void GetUsersQuestionShouldReturnResult() { // arrange var options = new DbContextOptionsBuilder <PH_DbContext>() .UseInMemoryDatabase("GetUsersQuestionShouldReturnResult") .Options; using var arrangeContext = new PH_DbContext(options); string username = "******"; arrangeContext.Questions.Add(new Questions { UserQuestion = "wtf?" }); arrangeContext.SaveChanges(); using var actContext = new PH_DbContext(options); var repo = new UserRepo(actContext); // act var result = repo.GetUsersQuestionAsync(username); // assert Assert.NotNull(result); }
public void GetProfessionalListShouldReturnResult() { // arrange var options = new DbContextOptionsBuilder <PH_DbContext>() .UseInMemoryDatabase("GetProfessionalListShouldReturnResult") .Options; using var arrangeContext = new PH_DbContext(options); var id = 5; var userId = 10; arrangeContext.Professionals.Add(new Professionals { Id = id, UserID = userId }); arrangeContext.SaveChanges(); using var actContext = new PH_DbContext(options); var repo = new UserRepo(actContext); // act var result = repo.GetProfessionalListAsync(); // assert Assert.NotNull(result); }
public void GetMemberListShouldReturnResult() { // arrange var options = new DbContextOptionsBuilder <PH_DbContext>() .UseInMemoryDatabase("GetMemberListShouldReturnResult") .Options; using var arrangeContext = new PH_DbContext(options); var id = 5; arrangeContext.Users.Add(new Users { FirstName = "Abc" }); arrangeContext.SaveChanges(); using var actContext = new PH_DbContext(options); var repo = new UserRepo(actContext); // act var result = repo.GetMemberListAsync(); // assert // if it is needed to check the actual database here, // use a separate assertContext as well. Assert.NotNull(result); }
public void GetAdminListAsyncShouldReturnResult() { // arrange var options = new DbContextOptionsBuilder <PH_DbContext>() .UseInMemoryDatabase("GetAdminListAsyncShouldReturnResult") .Options; using var arrangeContext = new PH_DbContext(options); var id = 5; var UserId = 10; var newUser = new Users { Email = "dude" }; arrangeContext.Admin.Add(new Admins { Id = id, UsersID = UserId, User = newUser }); arrangeContext.SaveChanges(); using var actContext = new PH_DbContext(options); var repo = new AdminRepo(actContext); // act var result = repo.GetAdminListAsync(); // assert Assert.NotNull(result); }
public async void AddQuestionAsyncShouldAdd() { // arrange var options = new DbContextOptionsBuilder <PH_DbContext>() .UseInMemoryDatabase("AddQuestionAsyncShouldAdd") .Options; using var actContext = new PH_DbContext(options); var repo = new ForumRepo(actContext); Users newUsers = new Users() { FirstName = "Rando", LastName = "Random", Email = "*****@*****.**", Username = "******", Password = "******", Phone = "1231231234", //PointAvailable = 100 }; actContext.Add(newUsers); actContext.SaveChanges(); var newQuestion = new Question() { AuthorName = "randorandom" }; // act await repo.AddQuestionAsync(newQuestion); //actContext.SaveChanges(); // assert using var assertContext = new PH_DbContext(options); var ques = assertContext.Questions.Select(q => newQuestion); Assert.NotNull(ques); }