public void DeveRetornarTrueQuandoActivaterActivate() { var activater = new Activater(false); activater.Activate(); Assert.True(activater.Active); }
public void DeveReotnarFalseQuandoActivaterInactivate() { var activater = new Activater(true); activater.Inactivate(); Assert.False(activater.Active); }
public EventDto UpdateEvent(EventDto dto) { try { //##### Manual Create a new Event var Adrress = new Address(dto.Street, dto.Number, dto.Neigborhood, dto.City, dto.State, dto.Country, dto.ZipCode); var maintenanceDate = new MaintenanceDate(dto.RegisterDate, dto.LastUpdateDate); var activater = new Activater(dto.Active); var Event = new Event(dto.Id.Value, Adrress, dto.DateEvent, dto.Theme, dto.Capacity, maintenanceDate, activater); var LotRemove = _uow.LotRepository.Get(a => !dto.Lots.Select(c => c.Id).Contains(a.Id) && a.EventId == dto.Id); var LotAdd = new List <Lot>(); var LotUpdate = new List <Lot>(); foreach (var LotIn in dto.Lots.Where(c => c.Id == 0)) { var bb = new Lot(null, LotIn.Description, LotIn.CurrentEvent, Event, new Activater(LotIn.Active)); AddNotifications(bb); LotAdd.Add(bb); } foreach (var LotUp in dto.Lots.Where(c => c.Id != 0)) { var bb = new Lot(LotUp.Id, LotUp.Description, LotUp.CurrentEvent, Event, new Activater(LotUp.Active)); LotUpdate.Add(bb); AddNotifications(bb); } AddNotifications(Event); if (Valid) { _uow.EventRepository.Update(Event); _uow.LotRepository.DeleteRange(LotRemove); _uow.LotRepository.AddRange(LotAdd); _uow.LotRepository.UpdateRange(LotUpdate); _uow.Commit(); } Event.AddLots(LotUpdate); Event.AddLots(LotAdd); return(_mapper.Map <EventDto>(Event)); } catch (Exception ex) { throw ex; } }
public Lot(int?id, string description, bool?currentEvent, Event _event, Activater activater) //) { Id = id; Description = description; CurrentEvent = currentEvent != null ? currentEvent : false; Event = _event; Activater = activater != null ? activater : new Activater(true); AddNotifications(new Contract() .Requires() .HasMinLen(Description, 5, "Lot.Description", $"A descrição do lote {Id}.{Description} deve ter pelo menos 3 caracteres.") .HasMaxLen(Description, 150, "Lot.Description", $"A descrição do lote {Id}.{Description} deve ter no maximo 150 caracteres.") //.IsNotNull(Event, "Lot.Event", "Deve ser informado o evento para o lote") ); }
public void DeveRetornarObjectQuandoCriarNovoActivater() { var activater = new Activater(); Assert.IsType <Activater>(activater); }
public void DeveRetornarFalseQuandoCriarNovoActivaterComParametroFalse() { var activater = new Activater(false); Assert.False(activater.Active); }
public void DeveRetornarTrueQuandoCriarNovoActivaterComParametroTrue() { var activater = new Activater(true); Assert.True(activater.Active); }
public Event(int?id, Address address, DateTime?dateEvent, string theme, int capacity, MaintenanceDate maintenanceDate, Activater activater) { Id = id; Address = address; DateEvent = dateEvent; Theme = theme; Capacity = capacity; _Lotes = new List <Lot>(); MaintenanceDate = maintenanceDate == null ? new MaintenanceDate(null, null) : maintenanceDate; Activater = activater == null ? new Activater(null) : activater; AddNotifications( new Contract() .Requires() .IsLowerOrEqualsThan(1, Capacity, "Capacity", "A capacidade deve ser informada.") ); AddNotifications(Address); }