public void Add_ValidStudent_GetStudentById_CheckIsStudentCorrect() { var repository = new FakeRepository<Student>(); string firstName = "Nikolay"; string lastName = "Kostov"; var student = MakeSimpleStudent(firstName, lastName); repository.Entities.Add(student); var controller = new StudentsController(repository); var allStudents = controller.Get(); int studentId = 0; foreach (var st in allStudents) { studentId = st.StudentId; } var studentById = controller.Get(studentId); Assert.AreEqual(studentId, studentById.StudentId); Assert.AreEqual(firstName, studentById.FirstName); Assert.AreEqual(lastName, studentById.LastName); }
public void Add_ValidStudent_CheckIsAdded() { var repository = new FakeRepository<Student>(); string firstName = "Nikolay"; string lastName = "Kostov"; var student = MakeSimpleStudent(firstName, lastName); repository.Entities.Add(student); var controller = new StudentsController(repository); var students = controller.Get(); int count = 0; string firstNameInMemory = null; foreach (var st in students) { count++; firstNameInMemory = st.FirstName; } Assert.IsTrue(count == 1); Assert.AreEqual(firstName, firstNameInMemory); }