// GET api/Students public IEnumerable <StudentServiceModel> Get() { var result = studentsRepository.All().Select(x => new StudentServiceModel { FirstName = x.FirstName, LastName = x.LastName, Level = x.Level, StudentIdentification = x.StudentIdentification }).ToList(); return(result); }
public void Get() { // Arrange StudentsRepository repository = new StudentsRepository(new StudentsEntities()); // Act IEnumerable<Student> result = repository.All(); // Assert Student expectedStudent = new Student() { firstName = "pesho", lastName = "peshev", age = 20, grade = 5 }; var resultStudentAtOne = result.ElementAt(1); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count()); Assert.AreEqual(expectedStudent.firstName, resultStudentAtOne.firstName); Assert.AreEqual(expectedStudent.firstName, resultStudentAtOne.firstName); Assert.AreEqual(expectedStudent.lastName, resultStudentAtOne.lastName); Assert.AreEqual(expectedStudent.age, resultStudentAtOne.age); Assert.AreEqual(expectedStudent.grade, resultStudentAtOne.grade); }
public void Post() { // Arrange var repository = new StudentsRepository(new StudentsEntities()); // Act Student newStudent = new Student() { firstName = "kiro", lastName = "ivanov", age = 20, grade = 7 }; repository.Add(newStudent); // Assert var count = repository.All().Count(); Assert.AreEqual(3, count); }
public void Delete() { // Arrange var repository = new StudentsRepository(new StudentsEntities()); // Act repository.Delete(2); // Assert var count = repository.All().Count(); Assert.AreEqual(1, count); }