Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        public void BypassAllAuthenticatedUsers_Default_ShouldSucceed()
        {
            MiddlewareOptionsBuilder builder = new MiddlewareOptionsBuilder(_dirMapperSvc);

            builder.BypassAllAuthenticatedUsers();

            builder.GetOptions()
            .GetSingleOrDefault <BypassAllAuthenticatedUsersOption>()
            .ShouldNotBeNull();
        }
Ejemplo n.º 3
0
        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();
        }