Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void notifyWithNotification()
        internal virtual void NotifyWithNotification()
        {
            string   message   = "foo";
            Listener listener1 = new Listener();
            Listener listener2 = new Listener();

            Listeners <Listener> listeners = NewListeners(listener1, listener2);

            listeners.Notify(listener => listener.process(message));

            assertEquals(message, listener1.Message);
            assertEquals(currentThread().Name, listener1.ThreadName);

            assertEquals(message, listener2.Message);
            assertEquals(currentThread().Name, listener2.ThreadName);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void notifyWithExecutorAndNotification() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void NotifyWithExecutorAndNotification()
        {
            string   message          = "foo";
            string   threadNamePrefix = "test-thread";
            Listener listener1        = new Listener();
            Listener listener2        = new Listener();

            Listeners <Listener> listeners = NewListeners(listener1, listener2);

            ExecutorService executor = newSingleThreadExecutor(named(threadNamePrefix));

            listeners.Notify(executor, listener => listener.process(message));
            executor.shutdown();
            executor.awaitTermination(1, TimeUnit.MINUTES);

            assertEquals(message, listener1.Message);
            assertThat(listener1.ThreadName, startsWith(threadNamePrefix));

            assertEquals(message, listener2.Message);
            assertThat(listener2.ThreadName, startsWith(threadNamePrefix));
        }