示例#1
0
        public SpecialtyDto UpdateSpecialty(int id, SpecialtyDto specialty)
        {
            if (id <= 0)
            {
                RaiseNotification(nameof(id));
            }

            if (specialty == null)
            {
                RaiseNotification(nameof(specialty));
            }

            if (Notification.HasNotification())
            {
                return(new SpecialtyDto());
            }

            var specialtyBuilder = new SpecialtyBuilder(Notification)
                                   .WithId(id)
                                   .WithDescription(specialty.Description);

            _service.UpdateSpecialty(specialtyBuilder);

            specialty.Id = id;
            return(specialty);
        }
示例#2
0
        public void Create_Valid_Specialty()
        {
            // Arrange
            var builder = new SpecialtyBuilder(LocalNotification)
                          .WithDescription("Pediatria");

            // Act
            builder.Build();

            // Assert
            Assert.False(LocalNotification.HasNotification());
        }
示例#3
0
        public void Specialty_Service_Insert_Valid_Specialty()
        {
            // Arrange
            var specialtyBuilder = new SpecialtyBuilder(LocalNotification)
                                   .WithDescription("Cirurgia Vascular");

            // Act
            var responseBase = _specialtyService.CreateSpecialty(specialtyBuilder);

            // Assert
            Assert.False(LocalNotification.HasNotification());
            Assert.NotEqual(responseBase, 0);
        }
示例#4
0
        public void Specialty_Service_Update_Valid_Specialty()
        {
            // Arrange
            var specialtyBuilder = new SpecialtyBuilder(LocalNotification)
                                   .WithId(1)
                                   .WithDescription("Cirurgia Vascular");

            // Act
            _specialtyService.UpdateSpecialty(specialtyBuilder);

            // Assert
            Assert.False(LocalNotification.HasNotification());
        }
示例#5
0
        public void Create_Specialty_With_Invalid_Description()
        {
            // Arrange
            var builder = new SpecialtyBuilder(LocalNotification)
                          .WithDescription(null);

            // Act
            builder.Build();

            // Assert
            Assert.True(LocalNotification.HasNotification());
            var notifications = LocalNotification.GetAll();

            Assert.True(notifications.Any(a => a.Message == Specialty.Error.SpecialtyDescriptionMustHaveValue.ToString()));
        }
示例#6
0
        public void Specialty_Service_Update_Not_Accept_Non_Existing_Specialty()
        {
            // Arrange
            var specialtyBuilder = new SpecialtyBuilder(LocalNotification)
                                   .WithId(99)
                                   .WithDescription("Cirurgia Vascular");

            // Act
            _specialtyService.UpdateSpecialty(specialtyBuilder);

            // Assert
            Assert.True(LocalNotification.HasNotification());
            var notifications = LocalNotification.GetAll();

            Assert.True(notifications.Any(a => a.Message == Specialty.Error.CouldNotFindSpecialty.ToString()));
        }
示例#7
0
        public SpecialtyDto CreateSpecialty(SpecialtyDto specialty)
        {
            if (specialty == null)
            {
                RaiseNotification(nameof(specialty));
            }

            if (Notification.HasNotification())
            {
                return(new SpecialtyDto());
            }

            var specialtyBuilder = new SpecialtyBuilder(Notification)
                                   .WithId(specialty.Id)
                                   .WithDescription(specialty.Description);

            specialty.Id = _service.CreateSpecialty(specialtyBuilder);

            return(specialty);
        }