public void GetState_AfterStoredState_ShouldRestoreSameState() { // store IStateStoreService stateStoreSvc1 = new StateStoreService(new InMemoryStateStore()); IDirectoryMapperService dirMapperSvc = FakeDirectoryMapperService.Create(); MiddlewareOptionsBuilder builder = new MiddlewareOptionsBuilder(dirMapperSvc); builder.BypassAllAuthenticatedUsers(); stateStoreSvc1.SetState(new MaintenanceState(null, isMaintenanceOn: true, builder.GetOptions())); // restore IStateStoreService stateStoreSvc2 = new StateStoreService(new InMemoryStateStore()); Func <MaintenanceState> testFunc = () => stateStoreSvc2.GetState(); MaintenanceState state = testFunc.ShouldNotThrow() .ShouldNotBeNull(); IMiddlewareOptionsContainer optionsContainer = state; optionsContainer.MiddlewareOptions .ShouldNotBeNull() .Any <BypassAllAuthenticatedUsersOption>() .ShouldBeTrue(); }
public void BypassAllAuthenticatedUsers_Default_ShouldSucceed() { MiddlewareOptionsBuilder builder = new MiddlewareOptionsBuilder(_dirMapperSvc); builder.BypassAllAuthenticatedUsers(); builder.GetOptions() .GetSingleOrDefault <BypassAllAuthenticatedUsersOption>() .ShouldNotBeNull(); }
public void SetState_WithValidState_ShouldNotThrow() { IStateStoreService stateStoreSvc = new StateStoreService(new InMemoryStateStore()); IDirectoryMapperService dirMapperSvc = FakeDirectoryMapperService.Create(); MiddlewareOptionsBuilder builder = new MiddlewareOptionsBuilder(dirMapperSvc); builder.BypassAllAuthenticatedUsers(); Action testAction = () => stateStoreSvc.SetState(new MaintenanceState(null, isMaintenanceOn: true, builder.GetOptions())); testAction.ShouldNotThrow(); }