Example #1
0
 public static ApplicationState Reduce(ApplicationState state, IAction action)
 {
     return(action switch
     {
         InitializeAction _ => state with {
             Message = "Initialize Action"
         },
Example #2
0
 public static void AddInitializeAction(int order, InitializeAction action)
 {
     if (!hcs.TryAdd(order, action))
     {
         throw new InitializationException("order is already in use");
     }
     
 }
Example #3
0
        public GameStore Init(Version version, GameBoard board = null)
        {
            var action = new InitializeAction {
                Version = version, Board = board
            };

            return(Evaluate(m_reducer.Apply(action, Evaluator.InitialStore)));
        }
Example #4
0
 public GameBoard Apply(IAction action, GameBoard store)
 {
     return(action switch
     {
         InitializeAction ia => ia.Board ?? BoardFactory.Instance.Create(ia.Version),
         MoveAction ma => Move(store, ma.Move),
         NextPlayerAction npa => RemoveKing(store, npa.CurrentColor),
         _ => store
     });
Example #5
0
        public void InitializeAsync_When_NotAwaitingAndUsingYield_Then_ManualResetEventShouldNotYetHaveBeenSet()
        {
            var manualResetEvent = new ManualResetEventSlim(false);
            var testee           = new InitializeAction(
                () =>
            {
                Thread.Sleep(10);
                manualResetEvent.Set();
            },
                true);

            _ = testee.InitializeAsync();

            manualResetEvent.IsSet.Should().BeFalse();
        }
Example #6
0
        public async Task InitializeAsync_When_Awaiting_Then_ManualResetEventShouldBeSet(bool useYield)
        {
            var manualResetEvent = new ManualResetEventSlim(false);
            var testee           = new InitializeAction(
                () =>
            {
                Thread.Sleep(10);
                manualResetEvent.Set();
            },
                useYield);

            await testee.InitializeAsync();

            manualResetEvent.IsSet.Should().BeTrue();
        }
 public DefaultInitializationInput(InitializeAction initializeAction)
 {
     ShardId           = initializeAction.ShardId;
     SequenceNumber    = initializeAction.SequenceNumber;
     SubSequenceNumber = initializeAction.SubSequenceNumber;
 }
Example #8
0
        public ThreadManager <TAction> SetInitializeAction(InitializeAction <TAction> initializeAction)
        {
            _initializeAction = initializeAction;

            return(this);
        }
Example #9
0
 private void initActionList()
 {
     if (this.InvokeRequired)
     {
         InitializeAction actionControl = new InitializeAction(LoadActionList);
         this.Invoke(actionControl);
     }
     else
     {
         this.LoadActionList();
     }
 }