public void Correctly_sets_availability_status_for_administrator() { MockRepository mocks = new MockRepository(); IAdministratorSecurityChecker checker = mocks.CreateMock <IAdministratorSecurityChecker>(); IWebContext context = mocks.CreateMock <IWebContext>(); IAvailabilityStatusUpdater updater = mocks.CreateMock <IAvailabilityStatusUpdater>(); using (mocks.Record()) { Expect.Call(checker.IsCurrentUserAdministrator()).Return(true); updater.SetAvailabilityStatus(true); Expect.Call(context.GetCurrentUrl()).Return("http://mydomain/"); context.Redirect("http://mydomain/"); } using (mocks.Playback()) { ISecureAvailabilityStatusUpdater statusUpdater = new SecureAvailabilityStatusUpdater(checker, context, updater); string errorMessage = statusUpdater.SetStatus(true); Assert.That(errorMessage, Is.Empty); } }
public SecureAvailabilityStatusUpdater(IAdministratorSecurityChecker securityChecker, IWebContext context, IAvailabilityStatusUpdater statusUpdater) { _securityChecker = securityChecker; _context = context; _statusUpdater = statusUpdater; }