public void FindByAsync_Should_Should_Return_The_Dummy_Data_And_All_Count_As_More_Than_One(Mock <ISessionManager> mockSessionManager, DefaultSession session, Dummy data1, Dummy data2) { //Arrange mockSessionManager.Setup(m => m.Current) .Returns(session); var options = new DbContextOptionsBuilder <DummyContext>() .UseInMemoryDatabase("DummyDb") .Options; string name = "berdan"; data1.Name = name; data2.Name = name; using (var context = new DummyContext(options, mockSessionManager.Object)) { var repository = new WriteRepository <DummyContext, Dummy>(context); repository.Add(data1); repository.Add(data2); } //Act List <Dummy> list; using (var context = new DummyContext(options, mockSessionManager.Object)) { var repository = new ReadRepository <DummyContext, Dummy>(context); list = repository.FindByAsync(e => e.Name == name).Result; } //Assert list.Count.Should().BeGreaterThan(1); }
public void FindByAsync_Should_Return_The_Dummy_Data_And_All_Count_As_One(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 List <Dummy> list; using (var context = new DummyContext(options, mockSessionManager.Object)) { var repository = new ReadRepository <DummyContext, Dummy>(context); list = repository.FindByAsync(e => e.Id == data.Id).Result; } //Assert list.Count.Should().Be(1); list.First().Should().BeEquivalentTo(data); }