Ejemplo n.º 1
0
        public void CanCreate()
        {
            var studentToCreateDto = new StudentDto { LastName = "Cobretti" };
            var createdStudent = new Student { Id = 1, LastName = studentToCreateDto.LastName };

            _studentRepository.Create(Arg.Any<Student>()).Returns(createdStudent);

            var createdStudentDto = _studentFacade.Create(studentToCreateDto);

            _studentRepository.Received().Create(Arg.Any<Student>());
            Assert.NotNull(createdStudentDto);
            Assert.Equal(createdStudent.Id, createdStudentDto.Id);
        }
Ejemplo n.º 2
0
        public void CanUpdate()
        {
            var updatedStudent = new Student { Id = 1, LastName = "Cobretti" };
            var studentToUpdateDto = new StudentDto { Id = updatedStudent.Id, LastName = updatedStudent.LastName };

            _studentRepository.Update(Arg.Any<Student>()).Returns(updatedStudent);

            var updatedStudentDto = _studentFacade.Update(studentToUpdateDto);

            _studentRepository.Received().Update(Arg.Any<Student>());
            Assert.NotNull(updatedStudentDto);
            Assert.Equal(updatedStudentDto.Id, updatedStudentDto.Id);
            Assert.Equal(updatedStudentDto.LastName, updatedStudentDto.LastName);
        }
Ejemplo n.º 3
0
        public void CanGet()
        {
            _server.Run((baseUri, server) =>
            {
                server.RegisterInstance(_studentFacade);

                var student = new StudentDto { Id = 1, LastName = "Cobretti" };

                _studentFacade.Get(student.Id).ReturnsForAnyArgs(student);

                var foundStudent = DomainAgent.CreateStudentRestClient(baseUri).Get(student.Id);

                _studentFacade.Received().Get(student.Id);
                Assert.NotNull(foundStudent);
                Assert.Equal(student.Id, foundStudent.Id);
            });
        }
Ejemplo n.º 4
0
        public void CanCreate()
        {
            _server.Run((baseUri, server) =>
            {
                server.RegisterInstance(_studentFacade);

                var studentToCreateDto = new StudentDto { LastName = "Rambo" };
                var createdStudentDto = new StudentDto { Id = 1, LastName = studentToCreateDto.LastName };

                _studentFacade.Create(Arg.Any<StudentDto>()).ReturnsForAnyArgs(createdStudentDto);

                var student = DomainAgent.CreateStudentRestClient(baseUri).Create(studentToCreateDto);

                _studentFacade.Received().Create(Arg.Any<StudentDto>());
                Assert.NotNull(student);
                Assert.True(student.Id > 0);
                Assert.Equal(studentToCreateDto.LastName, student.LastName);
            });
        }
Ejemplo n.º 5
0
        public StudentDto Update(StudentDto student)
        {
            var updatedStudent = _studentRepository.Update(new Student
            {
                Id = student.Id,
                FirstName = student.FirstName,
                LastName = student.LastName
            });

            if (updatedStudent == null)
            {
                return null;
            }

            return new StudentDto
            {
                Id = updatedStudent.Id,
                FirstName = updatedStudent.FirstName,
                LastName = updatedStudent.LastName
            };
        }
Ejemplo n.º 6
0
        public StudentDto Create(StudentDto student)
        {
            var createdStudent = _studentRepository.Create(new Student
            {
                Id = student.Id,
                FirstName = student.FirstName,
                LastName = student.LastName
            });

            if (createdStudent == null)
            {
                return null;
            }

            return new StudentDto
            {
                Id = createdStudent.Id,
                FirstName = createdStudent.FirstName,
                LastName = createdStudent.LastName
            };
        }
Ejemplo n.º 7
0
 public StudentDto Update(StudentDto student)
 {
     return _studentFacade.Update(student);
 }
Ejemplo n.º 8
0
 public StudentDto Create(StudentDto student)
 {
     return _studentFacade.Create(student);
 }
Ejemplo n.º 9
0
 public StudentDto Update(StudentDto student)
 {
     return _studentClient.Update(student);
 }
Ejemplo n.º 10
0
 public StudentDto Create(StudentDto student)
 {
     return _studentClient.Create(student);
 }
Ejemplo n.º 11
0
 public StudentDto Update(StudentDto student)
 {
     return Put<StudentDto, StudentDto>("api/student", student);
 }
Ejemplo n.º 12
0
 public StudentDto Create(StudentDto student)
 {
     return Post<StudentDto, StudentDto>("api/student", student);
 }