예제 #1
0
def test_add():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.add(5)

    assert sourcer.value == 7
예제 #2
0
def test_subtract():
    sourcer = EventSourcer()

    sourcer.subtract(2)
    sourcer.subtract(5)

    assert sourcer.value == -7
예제 #3
0
def test_bulk_undo_overstep():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.subtract(5)
    sourcer.bulk_undo(5)

    assert sourcer.value == 0
예제 #4
0
def test_bulk_undo():
    sourcer = EventSourcer()

    sourcer.add(1)
    sourcer.add(2)
    sourcer.add(3)
    sourcer.add(4)
    sourcer.add(5)
    sourcer.bulk_undo(3)

    assert sourcer.value == 3
예제 #5
0
def test_undo():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.add(2)
    sourcer.add(2)
    sourcer.add(2)
    sourcer.undo()

    assert sourcer.value == 6
예제 #6
0
def test_pow():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.pow(3)
    
    assert sourcer.value == 8
예제 #7
0
def test_multiply():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.multiply(2)
    
    assert sourcer.value == 4
예제 #8
0
def test_divide_big_divisor():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.divide(3)
    
    assert sourcer.value == 0
예제 #9
0
def test_divide_even():
    sourcer = EventSourcer()

    sourcer.add(6)
    sourcer.divide(2)
    
    assert sourcer.value == 3
예제 #10
0
def test_divide_odd():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.divide(2)
    
    assert sourcer.value == 2
예제 #11
0
def test_pow_float():
    sourcer = EventSourcer()

    sourcer.add(4)
    sourcer.pow(0.5)
    
    assert sourcer.value == 2
    assert isinstance(sourcer.value, int)
예제 #12
0
def test_redo_with_no_redo_step():
    sourcer = EventSourcer()

    sourcer.redo()

    assert sourcer.value == 0
예제 #13
0
def test_undo_no_actions():
    sourcer = EventSourcer()

    sourcer.undo()

    assert sourcer.value == 0
예제 #14
0
def test_bulk_redo():
    sourcer = EventSourcer()

    sourcer.add(1)
    sourcer.add(1)
    sourcer.add(1)
    sourcer.add(1)
    sourcer.add(1)
    sourcer.undo()
    sourcer.undo()
    sourcer.undo()
    sourcer.undo()

    sourcer.bulk_redo(4)

    assert sourcer.value == 5
예제 #15
0
def test_redo():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.undo()
    sourcer.undo()
    sourcer.add(1)
    sourcer.redo()

    assert sourcer.value == 11
예제 #16
0
def test_bulk_redo_overstep():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.undo()
    sourcer.undo()
    sourcer.undo()
    sourcer.bulk_redo(5)

    assert sourcer.value == 25