public void GetQuizByNameOrIdReturnsTitleByTitle() { //arrange var options = new DbContextOptionsBuilder <DatLib.Entities.ecgbhozpContext>() .UseInMemoryDatabase("GetQuizByNameOrIdReturnsTitleByTitle") .Options; using var arrangeContext = new DatLib.Entities.ecgbhozpContext(options); //int Id = 102; string testTitle = "TestTitle3"; arrangeContext.Title.Add(new DatLib.Entities.Title { TitleId = 101, TitleString = "TestTitle1", CreatorId = 51 }); arrangeContext.Title.Add(new DatLib.Entities.Title { TitleId = 102, TitleString = "testTitle2", CreatorId = 502 }); arrangeContext.Title.Add(new DatLib.Entities.Title { TitleId = 103, TitleString = testTitle, CreatorId = 53 }); arrangeContext.Title.Add(new DatLib.Entities.Title { TitleId = 104, TitleString = testTitle, CreatorId = 54 }); arrangeContext.SaveChanges();//save the changes before running the test! //act using var actContext = new DatLib.Entities.ecgbhozpContext(options); var repo = new TakeAQuizRepository(actContext); var actual = repo.GetQuizByNameOrId(title: testTitle).ToList(); //assert Assert.Equal(expected: 2, actual: actual.Count); }
public void GetQuizReturnsNullWithNoParams() { //arrange var options = new DbContextOptionsBuilder <DatLib.Entities.ecgbhozpContext>() .UseInMemoryDatabase("GetQuizReturnsNullWithNoParams") .Options; using var arrangeContext = new DatLib.Entities.ecgbhozpContext(options); using var actContext = new DatLib.Entities.ecgbhozpContext(options); var repo = new TakeAQuizRepository(actContext); //act var actual = repo.GetQuiz(); //assert Assert.Null(actual); }