package com.github.davidmoten.rx2.internal.flowable.buffertofile;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.util.concurrent.Callable;

import org.junit.Assert;
import org.junit.Test;

public class PageListTest {

    private static final Callable<File> factory = new Callable<File>() {
        int i = 0;

        @Override
        public File call() throws Exception {
            return new File("target/test" + (++i));
        }
    };

    @Test
    public void testPutOneAndReadLessThanPageSize() {
        PageList p = new PageList(factory, 8);
        p.put(1);
        assertEquals(1, p.read());
    }

    @Test
    public void testPutTwoAndReadLessThanPageSize() {
        PageList p = new PageList(factory, 12);
        p.put(1);
        p.put(2);
        assertEquals(1, p.read());
        assertEquals(2, p.read());
    }
    
    @Test
    public void testPutTwoAndReadEqualsPageSize() {
        PageList p = new PageList(factory, 8);
        p.put(1);
        p.put(2);
        assertEquals(1, p.read());
        assertEquals(2, p.read());
    }
    
    @Test
    public void testPutTwoAndReadMoreThanPageSize() {
        PageList p = new PageList(factory, 5);
        p.put(1);
        p.put(2);
        assertEquals(1, p.read());
        assertEquals(2, p.read());
    }

}

@@ -177,34 +177,8 @@
 %0D%0A%0D%0A
-import org.junit.Assert;%0D%0A
 impo
@@ -197,16 +197,16 @@
 .Test;%0D%0A
+
 %0D%0Apublic
@@ -868,38 +868,34 @@
 ead());%0D%0A    %7D%0D%0A
-    
 %0D%0A
+
     @Test%0D%0A    p
@@ -1111,14 +1111,10 @@
  %7D%0D%0A
-    
 %0D%0A
+
     
@@ -1342,11 +1342,459 @@
    %7D%0D%0A%0D%0A
+    @Test%0D%0A    public void testPutSixAndReadMultiplePages() %7B%0D%0A        PageList p = new PageList(factory, 5);%0D%0A        p.put(1);%0D%0A        p.put(2);%0D%0A        p.put(3);%0D%0A        p.put(4);%0D%0A        p.put(5);%0D%0A        p.put(6);%0D%0A        assertEquals(1, p.read());%0D%0A        assertEquals(2, p.read());%0D%0A        assertEquals(3, p.read());%0D%0A        assertEquals(4, p.read());%0D%0A        assertEquals(5, p.read());%0D%0A        assertEquals(6, p.read());%0D%0A    %7D%0D%0A
 %7D%0D%0A

add tests