public void GetById_Should_Return_The_Expected_Data(Mock <ISessionManager> mockSessionManager, DefaultSession session, Dummy data) { //Arrange mockSessionManager.Setup(m => m.Current) .Returns(session); var options = new DbContextOptionsBuilder <DummyContext>() .UseInMemoryDatabase("DummyDb") .Options; using (var context = new DummyContext(options, mockSessionManager.Object)) { var repository = new WriteRepository <DummyContext, Dummy>(context); repository.Add(data); } //Act Dummy dummyData; using (var context = new DummyContext(options, mockSessionManager.Object)) { var repository = new ReadRepository <DummyContext, Dummy>(context); dummyData = repository.GetById(data.Id); } //Assert dummyData.Should().BeEquivalentTo(data); }