In a saucepan, whisk together heavy cream, flour, butter, garlic, salt and pepper over medium-low heat. Continue to whisk until thickened, about 5 minutes. Add mushrooms and simmer for another 15 minutes.
Bring a large pot of salted water to a boil. Blanch the green beans for 60 seconds. Drain and rinse in cold water.
Heat olive oil in a skillet over medium high heat. Add onions and cook until they start to brown.
To assemble, spread green beans in a 9x13 inch casserole dish. Pour over the mushroom sauce. Spread onions on top. Bake, uncovered, for 30 minutes. Serve hot.