public void Should_enable_load_balancing_when_requested() { ApplicationInstance instance = new ApplicationInstance(); instance.AvailableForLoadBalancing = false; MockRepository mocks = new MockRepository(); IApplicationInstanceContext instanceContext = mocks.CreateMock<IApplicationInstanceContext>(); IWebContext context = mocks.CreateMock<IWebContext>(); ISecureAvailabilityStatusUpdater updater = mocks.CreateMock<ISecureAvailabilityStatusUpdater>(); using (mocks.Record()) { Expect.Call(instanceContext.GetCurrent()).Return(instance); Expect.Call(context.GetRequestItem(LoadBalanceStatusManager.ENABLED_PARAM)).Return("True"); Expect.Call(updater.SetStatus(true)).Return("My error message"); } using (mocks.Playback()) { ILoadBalanceStatusManager manager = new LoadBalanceStatusManager(instanceContext, context, updater); string errorMessage = manager.HandleLoadBalanceRequest(); Assert.That(errorMessage, Is.EqualTo("My error message")); } }
public void Return_normal_status_200_message_if_instance_should_be_online_and_status_not_being_changed() { ApplicationInstance instance = new ApplicationInstance(); instance.AvailableForLoadBalancing = true; MockRepository mocks = new MockRepository(); IApplicationInstanceContext instanceContext = mocks.CreateMock<IApplicationInstanceContext>(); IWebContext context = mocks.CreateMock<IWebContext>(); using (mocks.Record()) { Expect.Call(instanceContext.GetCurrent()).Return(instance); Expect.Call(context.GetRequestItem(LoadBalanceStatusManager.ENABLED_PARAM)).Return(null); } using (mocks.Playback()) { ILoadBalanceStatusManager manager = new LoadBalanceStatusManager(instanceContext, context, null); string errorMessage = manager.HandleLoadBalanceRequest(); Assert.That(errorMessage, Is.Empty); } }