Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleStress() throws java.util.concurrent.ExecutionException, InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldHandleStress()
        {
            // given
            int n = 1000;
            TestStateMachine stateMachine = new TestStateMachine();
            ExecutorService  executor     = Executors.newFixedThreadPool(3);

            // when
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> collect = executor.submit(stress(n, () -> collect(stateMachine)));
            Future <object> collect = executor.submit(Stress(n, () => collect(stateMachine)));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> stop = executor.submit(stress(n, () -> stateMachine.stop(Long.MAX_VALUE)));
            Future <object> stop = executor.submit(Stress(n, () => stateMachine.Stop(long.MaxValue)));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> clear = executor.submit(stress(n, stateMachine::clear));
            Future <object> clear = executor.submit(Stress(n, stateMachine.clear));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> status = executor.submit(stress(n, stateMachine::status));
            Future <object> status = executor.submit(Stress(n, stateMachine.status));

            // then without illegal transitions or exceptions
            collect.get();
            stop.get();
            clear.get();
            status.get();
            executor.shutdown();
        }
Ejemplo n.º 2
0
        public void StopCallsExit()
        {
            var sm = new TestStateMachine();

            sm.State<IdleState>()
                .On(TelephoneTrigger.PickingUpPhone).GoesTo<CountingState>();
            sm.State<CountingState>()
                .On(TelephoneTrigger.HangingUp).GoesTo<IdleState>();

            sm.Start();

            sm.Trigger(TelephoneTrigger.PickingUpPhone);
            sm.Trigger(TelephoneTrigger.HangingUp);
            sm.Trigger(TelephoneTrigger.PickingUpPhone);

            Assert.IsTrue((sm.EnteringCount == 2) && (sm.ExitingCount == 1), "Unexpected EnteringCount / ExitingCount!");

            sm.Stop();

            Assert.IsTrue((sm.EnteringCount == 2) && (sm.ExitingCount == 2), "Unexpected EnteringCount / ExitingCount on Stop!");
        }