public async Task Current_WhenCalled_ReturnsItem() { // Arrange var heroes = HeroBuilder.CreateAListOfHeros(); var enumerator = new MockDbSetAsyncEnumerator <HeroEntity>(heroes.GetEnumerator()) as IAsyncEnumerator <HeroEntity>; // Act while (await enumerator.MoveNext(CancellationToken.None)) { var current = enumerator.Current; // Assert Assert.IsTrue(heroes.Any(h => h == current)); } }
public void DbContext_IsInitializedWithMockDbSet_TheDbSetIsAccessible() { // Arrange var mockDbSet = new MockDbSet <HeroEntity>(HeroBuilder.CreateAListOfHeros()); // Act var dbcontext = new HeroesDbContext() { Heroes = mockDbSet }; // Assert Assert.IsNotNull(dbcontext.Heroes); Assert.IsTrue(dbcontext.Heroes.Any()); }
public async Task MoveNext_WhenCalled_ReturnsFalseIfAtEnd() { // Arrange var heroes = HeroBuilder.CreateAListOfHeros(); var enumerator = new MockDbSetAsyncEnumerator <HeroEntity>(heroes.GetEnumerator()) as IAsyncEnumerator <HeroEntity>; var count = 0; // Act while (await enumerator.MoveNext(CancellationToken.None)) { count++; } // Assert Assert.AreEqual(heroes.Count(), count); }