Class: StudentsTests

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/model_gem_source/students_tests.rb

Instance Method Summary collapse

Instance Method Details

#test_addObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/model_gem_source/students_tests.rb', line 10

def test_add
    @students = StudentsList.new(
        StudentsListDBAdapter.new(
            StudentsListDB
        )
    )

    @start_count = @students.count
    
    @students.add_student(
        Student.new(
            lastname: "AAA",
            firstname: "BBB",
            patronymic: "CCC",
            params: {
                email: "[email protected]"
            }
        )    
    )

    assert_equal(1, @students.count - @start_count)
end

#test_deleteObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/model_gem_source/students_tests.rb', line 33

def test_delete
    @students = StudentsList.new(
        StudentsListDBAdapter.new(
            StudentsListDB
        )
    )

    @students.add_student(
        Student.new(
            lastname: "AAA",
            firstname: "BBB",
            patronymic: "CCC",
            params: {
                email: "[email protected]"
            }
        )    
    )

    @students.add_student(
        Student.new(
            lastname: "AAA",
            firstname: "BBB",
            patronymic: "CCC",
            params: {
                email: "[email protected]"
            }
        )    
    )

    @current_count = @students.count

    @students_list = @students.get_students(0, 10, nil)

    @students.remove_student(@students_list[0].id)

    assert_equal(1, @current_count - @students.count)
end