コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPickFirstAvailableCandidateLongArray()
        public virtual void ShouldPickFirstAvailableCandidateLongArray()
        {
            // GIVEN
            NumberArrayFactory factory = new NumberArrayFactory_Auto(NO_MONITOR, NumberArrayFactory.HEAP);

            // WHEN
            LongArray array = factory.NewLongArray(KILO, -1);

            array.Set(KILO - 10, 12345);

            // THEN
            assertTrue(array is HeapLongArray);
            assertEquals(12345, array.Get(KILO - 10));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPickFirstAvailableCandidateLongArrayWhenSomeDontHaveEnoughMemory()
        public virtual void ShouldPickFirstAvailableCandidateLongArrayWhenSomeDontHaveEnoughMemory()
        {
            // GIVEN
            NumberArrayFactory lowMemoryFactory = mock(typeof(NumberArrayFactory));

            doThrow(typeof(System.OutOfMemoryException)).when(lowMemoryFactory).newLongArray(anyLong(), anyLong(), anyLong());
            NumberArrayFactory factory = new NumberArrayFactory_Auto(NO_MONITOR, lowMemoryFactory, NumberArrayFactory.HEAP);

            // WHEN
            LongArray array = factory.NewLongArray(KILO, -1);

            array.Set(KILO - 10, 12345);

            // THEN
            verify(lowMemoryFactory, times(1)).newLongArray(KILO, -1, 0);
            assertTrue(array is HeapLongArray);
            assertEquals(12345, array.Get(KILO - 10));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowOomOnNotEnoughMemory()
        public virtual void ShouldThrowOomOnNotEnoughMemory()
        {
            // GIVEN
            FailureMonitor     monitor          = new FailureMonitor();
            NumberArrayFactory lowMemoryFactory = mock(typeof(NumberArrayFactory));

            doThrow(typeof(System.OutOfMemoryException)).when(lowMemoryFactory).newLongArray(anyLong(), anyLong(), anyLong());
            NumberArrayFactory factory = new NumberArrayFactory_Auto(monitor, lowMemoryFactory);

            // WHEN
            try
            {
                factory.NewLongArray(KILO, -1);
                fail("Should have thrown");
            }
            catch (System.OutOfMemoryException)
            {
                // THEN OK
                assertFalse(monitor.Called);
            }
        }