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);
        }
        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);
        }
        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);
            });
        }
        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);
            });
        }
Beispiel #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
            };
        }
Beispiel #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
            };
        }
 public StudentDto Update(StudentDto student)
 {
     return _studentFacade.Update(student);
 }
 public StudentDto Create(StudentDto student)
 {
     return _studentFacade.Create(student);
 }
 public StudentDto Update(StudentDto student)
 {
     return _studentClient.Update(student);
 }
Beispiel #10
0
 public StudentDto Create(StudentDto student)
 {
     return _studentClient.Create(student);
 }
Beispiel #11
0
 public StudentDto Update(StudentDto student)
 {
     return Put<StudentDto, StudentDto>("api/student", student);
 }
Beispiel #12
0
 public StudentDto Create(StudentDto student)
 {
     return Post<StudentDto, StudentDto>("api/student", student);
 }