public void It_should_throw_exception() { // ARRANGE var builder = Fixture.DbContextBuilder; var entity = new Customer(); // not of type EntityTypeConfiguration and of non-generic var baseType = entity.GetType().BaseType; // ASSERT var exception = Assert.Throws<InvalidOperationException>(() => { // ACT var result = builder.IsMappingClass(baseType); }); Assert.AreEqual("This operation is only valid on generic types.", exception.Message); }