Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInstantiateLazilyOnFirstSelect()
        public virtual void ShouldInstantiateLazilyOnFirstSelect()
        {
            // given
            System.Func <IndexSlot, string> factory  = SlotToStringFunction();
            LazyInstanceSelector <string>   selector = new LazyInstanceSelector <string>(factory);

            // when
            foreach (IndexSlot slot in values())
            {
                foreach (IndexSlot candidate in values())
                {
                    // then
                    if (( int )candidate < ( int )slot)
                    {
                        verify(factory, times(1)).apply(candidate);
                        selector.Select(candidate);
                        verify(factory, times(1)).apply(candidate);
                    }
                    else if (candidate == slot)
                    {
                        verify(factory, times(0)).apply(candidate);
                        selector.Select(candidate);
                        verify(factory, times(1)).apply(candidate);
                    }
                    else
                    {
                        assertNull(selector.GetIfInstantiated(candidate));
                    }
                }
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseAllInstantiated()
        public virtual void ShouldCloseAllInstantiated()
        {
            // given
            System.Func <IndexSlot, string> factory  = SlotToStringFunction();
            LazyInstanceSelector <string>   selector = new LazyInstanceSelector <string>(factory);

            selector.Select(NUMBER);
            selector.Select(STRING);

            // when
            System.Action <string> consumer = mock(typeof(System.Action));
            selector.Close(consumer);

            // then
            verify(consumer, times(1)).accept(NUMBER.ToString());
            verify(consumer, times(1)).accept(STRING.ToString());
            verifyNoMoreInteractions(consumer);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPreventInstantiationAfterClose()
        public virtual void ShouldPreventInstantiationAfterClose()
        {
            // given
            System.Func <IndexSlot, string> factory  = SlotToStringFunction();
            LazyInstanceSelector <string>   selector = new LazyInstanceSelector <string>(factory);

            selector.Select(NUMBER);
            selector.Select(STRING);

            // when
            selector.Close(mock(typeof(System.Action)));

            // then
            try
            {
                selector.Select(TEMPORAL);
                fail("Should have failed");
            }
            catch (System.InvalidOperationException)
            {
                // then good
            }
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPerformActionOnAll()
        public virtual void ShouldPerformActionOnAll()
        {
            // given
            System.Func <IndexSlot, string> factory  = SlotToStringFunction();
            LazyInstanceSelector <string>   selector = new LazyInstanceSelector <string>(factory);

            selector.Select(STRING);

            // when
            System.Action <string> consumer = mock(typeof(System.Action));
            selector.ForAll(consumer);

            // then
            foreach (IndexSlot slot in Enum.GetValues(typeof(IndexSlot)))
            {
                verify(consumer, times(1)).accept(slot.ToString());
            }
            verifyNoMoreInteractions(consumer);
        }