public void AssignSubZoneToAZoneWithoutCapacityTest() { ZoneDTO zone = new ZoneDTO(); zone.Name = "Zona 1"; zone.MaxCapacity = 60; zone.Id = Guid.NewGuid(); ZoneDTO subZone = new ZoneDTO(); subZone.Name = "SubZona 1"; subZone.MaxCapacity = 70; subZone.Id = Guid.NewGuid(); List <ZoneDTO> subZones = new List <ZoneDTO>(); subZones.Add(subZone); zone.SubZones = subZones; var mockZoneDAO = new Mock <ZoneDAO>(); var mockFlowDAO = new Mock <FlowDAO>(); var mockVehicleDAO = new Mock <VehicleDAO>(); mockZoneDAO.Setup(z => z.FindZoneById(zone.Id)).Returns(zone); mockZoneDAO.Setup(z => z.FindZoneById(subZone.Id)).Returns(subZone); mockZoneDAO.Setup(z => z.GetZoneCapacityLeft(zone.Id)).Returns(60); mockZoneDAO.Setup(z => z.AssignZone(subZone.Id, zone.Id)).Throws(new ZoneOutOfCapacityException()); var zoneService = new ZoneServiceImp(mockZoneDAO.Object, mockFlowDAO.Object, mockVehicleDAO.Object); zoneService.AssignZone(subZone.Id, zone.Id); }
public void AssignZoneSuccessfullyTest() { ZoneDTO zone = new ZoneDTO(); zone.Name = "Zona 1"; zone.MaxCapacity = 60; zone.Id = Guid.NewGuid(); ZoneDTO subZone = new ZoneDTO(); subZone.Name = "SubZona 1"; subZone.MaxCapacity = 60; subZone.Id = Guid.NewGuid(); List <ZoneDTO> subZones = new List <ZoneDTO>(); subZones.Add(subZone); zone.SubZones = subZones; var mockZoneDAO = new Mock <ZoneDAO>(); var mockFlowDAO = new Mock <FlowDAO>(); var mockVehicleDAO = new Mock <VehicleDAO>(); mockZoneDAO.Setup(z => z.FindZoneById(zone.Id)).Returns(zone); mockZoneDAO.Setup(z => z.FindZoneById(subZone.Id)).Returns(subZone); mockZoneDAO.Setup(z => z.GetZoneCapacityLeft(zone.Id)).Returns(60); mockZoneDAO.Setup(z => z.AssignZone(subZone.Id, zone.Id)).Verifiable(); var zoneService = new ZoneServiceImp(mockZoneDAO.Object, mockFlowDAO.Object, mockVehicleDAO.Object); zoneService.AssignZone(subZone.Id, zone.Id); }