public void GetDrainStatus_HostRunning_ReturnsExpected(int outstandingRetries, int outstandingInvocations, DrainModeState expectedState) { var scriptHostManagerMock = new Mock <IScriptHostManager>(MockBehavior.Strict); var functionActivityStatusProvider = new Mock <IFunctionActivityStatusProvider>(MockBehavior.Strict); var drainModeManager = new Mock <IDrainModeManager>(MockBehavior.Strict); functionActivityStatusProvider.Setup(x => x.GetStatus()).Returns(new FunctionActivityStatus() { OutstandingRetries = outstandingRetries, OutstandingInvocations = outstandingInvocations }); var serviceProviderMock = scriptHostManagerMock.As <IServiceProvider>(); serviceProviderMock.Setup(x => x.GetService(typeof(IFunctionActivityStatusProvider))).Returns(functionActivityStatusProvider.Object); serviceProviderMock.Setup(x => x.GetService(typeof(IDrainModeManager))).Returns(drainModeManager.Object); drainModeManager.Setup(x => x.IsDrainModeEnabled).Returns(expectedState != DrainModeState.Disabled); var result = (OkObjectResult)_hostController.DrainStatus(scriptHostManagerMock.Object); Assert.Equal(expectedState, (result.Value as DrainModeStatus).State); }