public void ByIntId_Queryable_CanDisallowNull() { var data = new Permission[] { new FakeEntityWithId1(), new FakeEntityWithId2(), new FakeEntityWithId3(), }; data.AsQueryable().ById(2, false).ShouldNotBeNull(); var exception = Assert.Throws <InvalidOperationException>(() => data.AsQueryable().ById(int.MaxValue, false)); Assert.NotNull(exception); exception.Message.IndexOf("Sequence contains no matching element", StringComparison.CurrentCulture).ShouldEqual(0); }
public void ByIntIdAsync_Queryable_CanDisallowNull() { var data = new Permission[] { new FakeEntityWithId1(), new FakeEntityWithId2(), new FakeEntityWithId3(), }; var dbSet = new Mock <DbSet <Permission> >(MockBehavior.Strict).SetupDataAsync(data.AsQueryable()); dbSet.Object.AsQueryable().ByIdAsync(1, false).Result.ShouldNotBeNull(); var exception = Assert.Throws <InvalidOperationException>(() => dbSet.Object.AsQueryable().ByIdAsync(int.MaxValue, false).Result); Assert.NotNull(exception); exception.Message.IndexOf("Sequence contains no matching element", StringComparison.CurrentCulture).ShouldEqual(0); }
public void ByIntIdAsync_Queryable_CanDisallowNull() { var data = new Permission[] { new FakeEntityWithId1(), new FakeEntityWithId2(), new FakeEntityWithId3(), }; var dbSet = new Mock<DbSet<Permission>>(MockBehavior.Strict).SetupDataAsync(data.AsQueryable()); dbSet.Object.AsQueryable().ByIdAsync(1, false).Result.ShouldNotBeNull(); var exception = Assert.Throws<InvalidOperationException>(() => dbSet.Object.AsQueryable().ByIdAsync(int.MaxValue, false).Result); Assert.NotNull(exception); exception.Message.IndexOf("Sequence contains no matching element", StringComparison.CurrentCulture) .ShouldEqual(0); }
public void ByIntId_Queryable_CanDisallowNull() { var data = new Permission[] { new FakeEntityWithId1(), new FakeEntityWithId2(), new FakeEntityWithId3(), }; data.AsQueryable().ById(2, false).ShouldNotBeNull(); var exception = Assert.Throws<InvalidOperationException>(() => data.AsQueryable().ById(int.MaxValue, false)); Assert.NotNull(exception); exception.Message.IndexOf("Sequence contains no matching element", StringComparison.CurrentCulture) .ShouldEqual(0); }