velir_virtualbox 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.yardopts +3 -0
- data/Gemfile +16 -0
- data/LICENSE +19 -0
- data/Rakefile +37 -0
- data/Readme.md +70 -0
- data/docs/GettingStarted.md +196 -0
- data/docs/WhatsNew.md +12 -0
- data/features/README.md +33 -0
- data/features/global.feature +19 -0
- data/features/global_extra_data.feature +27 -0
- data/features/step_definitions/abstract_model_steps.rb +39 -0
- data/features/step_definitions/extra_data_steps.rb +36 -0
- data/features/step_definitions/global_steps.rb +29 -0
- data/features/step_definitions/nat_engine_steps.rb +76 -0
- data/features/step_definitions/network_adapter_steps.rb +38 -0
- data/features/step_definitions/shared_folder_steps.rb +76 -0
- data/features/step_definitions/snapshot_steps.rb +74 -0
- data/features/step_definitions/storage_controller_steps.rb +16 -0
- data/features/step_definitions/virtualbox_steps.rb +17 -0
- data/features/step_definitions/vm_steps.rb +50 -0
- data/features/support/env.rb +61 -0
- data/features/support/helpers.rb +38 -0
- data/features/support/hooks.rb +30 -0
- data/features/support/ordered_hash.rb +49 -0
- data/features/support/vboxmanage.rb +191 -0
- data/features/version.feature +16 -0
- data/features/vm.feature +13 -0
- data/features/vm_bios.feature +29 -0
- data/features/vm_cpu.feature +29 -0
- data/features/vm_extra_data.feature +35 -0
- data/features/vm_hw_virt.feature +29 -0
- data/features/vm_nat_engine.feature +57 -0
- data/features/vm_network_adapters.feature +27 -0
- data/features/vm_shared_folders.feature +42 -0
- data/features/vm_snapshots.feature +29 -0
- data/features/vm_storage_controllers.feature +11 -0
- data/lib/virtualbox.rb +11 -0
- data/lib/virtualbox/abstract_model.rb +281 -0
- data/lib/virtualbox/abstract_model/attributable.rb +290 -0
- data/lib/virtualbox/abstract_model/dirty.rb +177 -0
- data/lib/virtualbox/abstract_model/interface_attributes.rb +98 -0
- data/lib/virtualbox/abstract_model/relatable.rb +332 -0
- data/lib/virtualbox/abstract_model/validatable.rb +167 -0
- data/lib/virtualbox/abstract_model/version_matcher.rb +35 -0
- data/lib/virtualbox/appliance.rb +62 -0
- data/lib/virtualbox/audio_adapter.rb +52 -0
- data/lib/virtualbox/bios.rb +50 -0
- data/lib/virtualbox/com.rb +23 -0
- data/lib/virtualbox/com/abstract_enum.rb +43 -0
- data/lib/virtualbox/com/abstract_implementer.rb +45 -0
- data/lib/virtualbox/com/abstract_interface.rb +167 -0
- data/lib/virtualbox/com/base_interface.rb +38 -0
- data/lib/virtualbox/com/ffi/interface.rb +150 -0
- data/lib/virtualbox/com/ffi/interfaces.rb +63 -0
- data/lib/virtualbox/com/ffi/util.rb +121 -0
- data/lib/virtualbox/com/ffi/vboxxpcomc.rb +31 -0
- data/lib/virtualbox/com/ffi_interface.rb +96 -0
- data/lib/virtualbox/com/implementer/base.rb +59 -0
- data/lib/virtualbox/com/implementer/ffi.rb +381 -0
- data/lib/virtualbox/com/implementer/mscom.rb +189 -0
- data/lib/virtualbox/com/implementer/nil.rb +10 -0
- data/lib/virtualbox/com/interface/3.1.x/access_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/appliance.rb +22 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/3.1.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/3.1.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/3.1.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/guest_os_type.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/host.rb +42 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/3.1.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/3.1.x/hw_virt_ex_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/machine.rb +105 -0
- data/lib/virtualbox/com/interface/3.1.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/3.1.x/medium.rb +50 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/network_adapter.rb +30 -0
- data/lib/virtualbox/com/interface/3.1.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/3.1.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/progress.rb +63 -0
- data/lib/virtualbox/com/interface/3.1.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/3.1.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_controller.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/system_properties.rb +37 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_controller.rb +20 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/virtualbox.rb +67 -0
- data/lib/virtualbox/com/interface/3.1.x/vrdp_auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/vrdp_server.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/access_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/appliance.rb +22 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/3.2.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/3.2.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/3.2.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/guest.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/guest_os_type.rb +33 -0
- data/lib/virtualbox/com/interface/3.2.x/host.rb +43 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/hw_virt_ex_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/keyboard_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/machine.rb +118 -0
- data/lib/virtualbox/com/interface/3.2.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/3.2.x/medium.rb +51 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_alias_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_engine.rb +27 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_protocol.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/network_adapter.rb +34 -0
- data/lib/virtualbox/com/interface/3.2.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/3.2.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/3.2.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/pointing_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/progress.rb +63 -0
- data/lib/virtualbox/com/interface/3.2.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_controller.rb +24 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/system_properties.rb +42 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_controller.rb +21 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/virtualbox.rb +67 -0
- data/lib/virtualbox/com/interface/3.2.x/vrdp_auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/vrdp_server.rb +21 -0
- data/lib/virtualbox/com/interface/4.0.x/access_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/appliance.rb +23 -0
- data/lib/virtualbox/com/interface/4.0.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/4.0.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/4.0.x/cleanup_mode.rb +12 -0
- data/lib/virtualbox/com/interface/4.0.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/4.0.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/4.0.x/event_source.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/fault_tolerance_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/guest.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/guest_os_type.rb +33 -0
- data/lib/virtualbox/com/interface/4.0.x/host.rb +43 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/hw_virt_ex_property_type.rb +12 -0
- data/lib/virtualbox/com/interface/4.0.x/keyboard_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/lock_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/machine.rb +132 -0
- data/lib/virtualbox/com/interface/4.0.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/4.0.x/medium.rb +53 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/nat_alias_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/nat_engine.rb +27 -0
- data/lib/virtualbox/com/interface/4.0.x/nat_protocol.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/network_adapter.rb +35 -0
- data/lib/virtualbox/com/interface/4.0.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/4.0.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/4.0.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/4.0.x/pointing_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/progress.rb +64 -0
- data/lib/virtualbox/com/interface/4.0.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/4.0.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/4.0.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/4.0.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/4.0.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/storage_controller.rb +24 -0
- data/lib/virtualbox/com/interface/4.0.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/system_properties.rb +42 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_controller.rb +21 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/virtualbox.rb +50 -0
- data/lib/virtualbox/com/interface/4.0.x/vrde_server.rb +23 -0
- data/lib/virtualbox/com/mscom_interface.rb +44 -0
- data/lib/virtualbox/com/nil_interface.rb +7 -0
- data/lib/virtualbox/com/util.rb +32 -0
- data/lib/virtualbox/cpu.rb +61 -0
- data/lib/virtualbox/dhcp_server.rb +89 -0
- data/lib/virtualbox/dvd.rb +27 -0
- data/lib/virtualbox/exceptions.rb +39 -0
- data/lib/virtualbox/ext/byte_normalizer.rb +17 -0
- data/lib/virtualbox/ext/glob_loader.rb +35 -0
- data/lib/virtualbox/ext/logger.rb +38 -0
- data/lib/virtualbox/ext/platform.rb +31 -0
- data/lib/virtualbox/ext/subclass_listing.rb +24 -0
- data/lib/virtualbox/extra_data.rb +127 -0
- data/lib/virtualbox/forwarded_port.rb +222 -0
- data/lib/virtualbox/global.rb +96 -0
- data/lib/virtualbox/hard_drive.rb +246 -0
- data/lib/virtualbox/host.rb +71 -0
- data/lib/virtualbox/host_network_interface.rb +137 -0
- data/lib/virtualbox/hw_virtualization.rb +64 -0
- data/lib/virtualbox/lib.rb +84 -0
- data/lib/virtualbox/media.rb +20 -0
- data/lib/virtualbox/medium.rb +145 -0
- data/lib/virtualbox/medium_attachment.rb +61 -0
- data/lib/virtualbox/nat_engine.rb +71 -0
- data/lib/virtualbox/nat_forwarded_port.rb +171 -0
- data/lib/virtualbox/network_adapter.rb +166 -0
- data/lib/virtualbox/proxies/collection.rb +57 -0
- data/lib/virtualbox/shared_folder.rb +220 -0
- data/lib/virtualbox/snapshot.rb +185 -0
- data/lib/virtualbox/storage_controller.rb +160 -0
- data/lib/virtualbox/system_properties.rb +73 -0
- data/lib/virtualbox/usb_controller.rb +59 -0
- data/lib/virtualbox/usb_device_filter.rb +74 -0
- data/lib/virtualbox/version.rb +36 -0
- data/lib/virtualbox/virtual_system_description.rb +47 -0
- data/lib/virtualbox/vm.rb +649 -0
- data/lib/virtualbox/vrde_server.rb +57 -0
- data/test/test_helper.rb +18 -0
- data/test/virtualbox/abstract_model/attributable_test.rb +269 -0
- data/test/virtualbox/abstract_model/dirty_test.rb +83 -0
- data/test/virtualbox/abstract_model/interface_attributes_test.rb +194 -0
- data/test/virtualbox/abstract_model/relatable_test.rb +348 -0
- data/test/virtualbox/abstract_model/validatable_test.rb +308 -0
- data/test/virtualbox/abstract_model/version_matcher_test.rb +41 -0
- data/test/virtualbox/abstract_model_test.rb +462 -0
- data/test/virtualbox/appliance_test.rb +159 -0
- data/test/virtualbox/audio_adapter_test.rb +83 -0
- data/test/virtualbox/bios_test.rb +83 -0
- data/test/virtualbox/com/abstract_enum_test.rb +49 -0
- data/test/virtualbox/com/abstract_implementer_test.rb +40 -0
- data/test/virtualbox/com/abstract_interface_test.rb +140 -0
- data/test/virtualbox/com/ffi/interface_test.rb +249 -0
- data/test/virtualbox/com/ffi/util_test.rb +108 -0
- data/test/virtualbox/com/ffi_interface_test.rb +42 -0
- data/test/virtualbox/com/implementer/base_test.rb +38 -0
- data/test/virtualbox/com/implementer/ffi_test.rb +527 -0
- data/test/virtualbox/com/implementer/mscom_test.rb +247 -0
- data/test/virtualbox/com/mscom_interface_test.rb +17 -0
- data/test/virtualbox/com/util_test.rb +17 -0
- data/test/virtualbox/cpu_test.rb +103 -0
- data/test/virtualbox/dhcp_server_test.rb +165 -0
- data/test/virtualbox/dvd_test.rb +28 -0
- data/test/virtualbox/ext/byte_normalizer_test.rb +34 -0
- data/test/virtualbox/ext/platform_test.rb +50 -0
- data/test/virtualbox/ext/subclass_listing_test.rb +25 -0
- data/test/virtualbox/extra_data_test.rb +155 -0
- data/test/virtualbox/forwarded_port_test.rb +286 -0
- data/test/virtualbox/global_test.rb +46 -0
- data/test/virtualbox/hard_drive_test.rb +141 -0
- data/test/virtualbox/host_network_interface_test.rb +255 -0
- data/test/virtualbox/host_test.rb +94 -0
- data/test/virtualbox/hw_virtualization_test.rb +103 -0
- data/test/virtualbox/lib_test.rb +93 -0
- data/test/virtualbox/medium_attachment_test.rb +147 -0
- data/test/virtualbox/medium_test.rb +192 -0
- data/test/virtualbox/nat_engine_test.rb +106 -0
- data/test/virtualbox/nat_forwarded_port_test.rb +222 -0
- data/test/virtualbox/network_adapter_test.rb +191 -0
- data/test/virtualbox/proxies/collection_test.rb +102 -0
- data/test/virtualbox/shared_folder_test.rb +219 -0
- data/test/virtualbox/snapshot_test.rb +231 -0
- data/test/virtualbox/storage_controller_test.rb +197 -0
- data/test/virtualbox/system_properties_test.rb +87 -0
- data/test/virtualbox/usb_controller_test.rb +112 -0
- data/test/virtualbox/usb_device_filter_test.rb +93 -0
- data/test/virtualbox/version_test.rb +59 -0
- data/test/virtualbox/virtual_system_description_test.rb +61 -0
- data/test/virtualbox/vm_test.rb +633 -0
- data/test/virtualbox/vrde_server_test.rb +83 -0
- data/test/virtualbox_test.rb +11 -0
- data/virtualbox.gemspec +24 -0
- metadata +464 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class DVDTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = VirtualBox::DVD
|
6
|
+
end
|
7
|
+
|
8
|
+
context "device type" do
|
9
|
+
should "be :dvd" do
|
10
|
+
assert_equal :dvd, @klass.device_type
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "retrieving all dvds" do
|
15
|
+
setup do
|
16
|
+
@media = mock("media")
|
17
|
+
@media.expects(:dvds).returns([])
|
18
|
+
@global = mock("global")
|
19
|
+
@global.expects(:media).returns(@media)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "return an array of DVD objects" do
|
23
|
+
VirtualBox::Global.expects(:global).returns(@global)
|
24
|
+
result = VirtualBox::DVD.all
|
25
|
+
assert result.is_a?(Array)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path("../../../test_helper", __FILE__)
|
2
|
+
require 'virtualbox/ext/byte_normalizer'
|
3
|
+
|
4
|
+
class ByteNormalizerTest < Test::Unit::TestCase
|
5
|
+
class A
|
6
|
+
include VirtualBox::ByteNormalizer
|
7
|
+
end
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@instance = A.new
|
11
|
+
end
|
12
|
+
|
13
|
+
should "convert megabytes to bytes" do
|
14
|
+
expected = {
|
15
|
+
1 => 1_048_576,
|
16
|
+
345.4 => 362_178_150.4
|
17
|
+
}
|
18
|
+
|
19
|
+
expected.each do |input, out|
|
20
|
+
assert_equal out, @instance.megabytes_to_bytes(input)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
should "convert bytes to megabytes" do
|
25
|
+
expected = {
|
26
|
+
1_048_576 => 1,
|
27
|
+
362_178_150.4 => 345.4
|
28
|
+
}
|
29
|
+
|
30
|
+
expected.each do |input, out|
|
31
|
+
assert_equal out, @instance.bytes_to_megabytes(input)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path("../../../test_helper", __FILE__)
|
2
|
+
require 'virtualbox/ext/platform'
|
3
|
+
|
4
|
+
class PlatformTest < Test::Unit::TestCase
|
5
|
+
context "mac" do
|
6
|
+
should "return true if it contains darwin" do
|
7
|
+
success = ["i386-darwin", "i686-darwin10", "imadarwin"]
|
8
|
+
success.each do |item|
|
9
|
+
VirtualBox::Platform.stubs(:platform).returns(item)
|
10
|
+
assert VirtualBox::Platform.mac?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "windows" do
|
16
|
+
should "return true if it contains mswin" do
|
17
|
+
success = ["i386-mswin32", "i686-mswin64", "imswin"]
|
18
|
+
success.each do |item|
|
19
|
+
VirtualBox::Platform.stubs(:platform).returns(item)
|
20
|
+
assert VirtualBox::Platform.windows?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
should "return true if it contains mingw" do
|
25
|
+
success = ["i386-mingw32", "i686-mingw64", "mingw"]
|
26
|
+
success.each do |item|
|
27
|
+
VirtualBox::Platform.stubs(:platform).returns(item)
|
28
|
+
assert VirtualBox::Platform.windows?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
should "return true if it contains cygwin" do
|
33
|
+
success = ["i386-cygwin", "i686-cygwin64", "cygwin"]
|
34
|
+
success.each do |item|
|
35
|
+
VirtualBox::Platform.stubs(:platform).returns(item)
|
36
|
+
assert VirtualBox::Platform.windows?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "linux" do
|
42
|
+
should "return true if it contains linux" do
|
43
|
+
success = ["i386-linux", "i686-linux241", "linux"]
|
44
|
+
success.each do |item|
|
45
|
+
VirtualBox::Platform.stubs(:platform).returns(item)
|
46
|
+
assert VirtualBox::Platform.linux?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path("../../../test_helper", __FILE__)
|
2
|
+
require 'virtualbox/ext/subclass_listing'
|
3
|
+
|
4
|
+
class SubclassListingTest < Test::Unit::TestCase
|
5
|
+
class A
|
6
|
+
include VirtualBox::SubclassListing
|
7
|
+
end
|
8
|
+
class B < A; end
|
9
|
+
class C < B; end
|
10
|
+
class D < A; end
|
11
|
+
class E
|
12
|
+
include VirtualBox::SubclassListing
|
13
|
+
end
|
14
|
+
class F < E; end
|
15
|
+
|
16
|
+
should "list subclasses, including sub-subclasses, etc" do
|
17
|
+
assert_equal [F], E.subclasses
|
18
|
+
assert_equal [C], B.subclasses
|
19
|
+
assert_equal [B, C, D], A.subclasses.sort_by { |c| c.name }
|
20
|
+
end
|
21
|
+
|
22
|
+
should "list direct subclasses if flag is set" do
|
23
|
+
assert_equal [B, D], A.subclasses(true).sort_by { |c| c.name }
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class ExtraDataTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@parent = mock("parent")
|
6
|
+
@interface = mock("interface")
|
7
|
+
@ed = VirtualBox::ExtraData.new(@parent, @interface)
|
8
|
+
@ed["foo"] = "bar"
|
9
|
+
@ed.clear_dirty!
|
10
|
+
end
|
11
|
+
|
12
|
+
context "relationships" do
|
13
|
+
setup do
|
14
|
+
@caller = mock("caller")
|
15
|
+
@caller.stubs(:name).returns("foocaller")
|
16
|
+
end
|
17
|
+
|
18
|
+
context "populating" do
|
19
|
+
setup do
|
20
|
+
@interface = mock("interface")
|
21
|
+
@interface.stubs(:get_extra_data_keys).returns([])
|
22
|
+
end
|
23
|
+
|
24
|
+
should "return a ExtraData object" do
|
25
|
+
result = VirtualBox::ExtraData.populate_relationship(@caller, @interface)
|
26
|
+
assert result.is_a?(VirtualBox::ExtraData)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "not be dirty" do
|
30
|
+
result = VirtualBox::ExtraData.populate_relationship(@caller, @interface)
|
31
|
+
assert !result.changed?
|
32
|
+
end
|
33
|
+
|
34
|
+
should "add the value of each key to the ED hash" do
|
35
|
+
expected_hash = { :a => 1, :b => 2, :c => 4 }
|
36
|
+
@interface.expects(:get_extra_data_keys).returns(expected_hash.keys)
|
37
|
+
|
38
|
+
expected_hash.each do |k, v|
|
39
|
+
@interface.expects(:get_extra_data).with(k).returns(v)
|
40
|
+
end
|
41
|
+
|
42
|
+
result = VirtualBox::ExtraData.populate_relationship(@caller, @interface)
|
43
|
+
assert_equal expected_hash.length, result.length
|
44
|
+
result.each do |k, v|
|
45
|
+
assert_equal expected_hash[k], v
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "saving" do
|
51
|
+
should "call save on the ExtraData object" do
|
52
|
+
object = mock("object")
|
53
|
+
object.expects(:save).once
|
54
|
+
|
55
|
+
VirtualBox::ExtraData.save_relationship(@caller, object)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "setting dirty state" do
|
61
|
+
setup do
|
62
|
+
@ed = VirtualBox::ExtraData.new(@parent, @interface)
|
63
|
+
end
|
64
|
+
|
65
|
+
should "not be dirty initially" do
|
66
|
+
assert !@ed.changed?
|
67
|
+
end
|
68
|
+
|
69
|
+
should "be dirty when setting a value" do
|
70
|
+
@ed["foo"] = "bar"
|
71
|
+
assert @ed.changed?
|
72
|
+
assert @ed.changes.has_key?(:foo)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "global extra data" do
|
77
|
+
setup do
|
78
|
+
global = mock("global")
|
79
|
+
global.expects(:extra_data).once.returns("foo")
|
80
|
+
VirtualBox::Global.expects(:global).returns(global)
|
81
|
+
@global = VirtualBox::ExtraData.global(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
should "call the global extra data if it has never been loaded" do
|
85
|
+
assert_equal "foo", VirtualBox::ExtraData.global
|
86
|
+
end
|
87
|
+
|
88
|
+
should "return the same object if it exists for global data, rather than recreating it" do
|
89
|
+
VirtualBox::Global.expects(:global).never
|
90
|
+
assert_equal @global, VirtualBox::ExtraData.global
|
91
|
+
end
|
92
|
+
|
93
|
+
should "return a new object if reload is true" do
|
94
|
+
global = mock("global")
|
95
|
+
global.expects(:extra_data).once.returns("bar")
|
96
|
+
VirtualBox::Global.expects(:global).returns(global)
|
97
|
+
assert !@global.equal?(VirtualBox::ExtraData.global(true))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "constructor" do
|
102
|
+
should "set the parent and interface with the given argument" do
|
103
|
+
ed = VirtualBox::ExtraData.new("JOEY", @interface)
|
104
|
+
assert_equal "JOEY", ed.parent
|
105
|
+
assert_equal @interface, ed.interface
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "saving extra data" do
|
110
|
+
setup do
|
111
|
+
@interface.stubs(:set_extra_data)
|
112
|
+
end
|
113
|
+
|
114
|
+
should "only save changed keys" do
|
115
|
+
@interface.expects(:set_extra_data).never
|
116
|
+
@interface.expects(:set_extra_data).with("bar", "baz").once
|
117
|
+
|
118
|
+
@ed["bar"] = "baz"
|
119
|
+
@ed.save
|
120
|
+
end
|
121
|
+
|
122
|
+
should "convert values to strings" do
|
123
|
+
@interface.expects(:set_extra_data).never
|
124
|
+
@interface.expects(:set_extra_data).with("bar", "7").once
|
125
|
+
|
126
|
+
@ed["bar"] = 7
|
127
|
+
@ed.save
|
128
|
+
end
|
129
|
+
|
130
|
+
should "clear the dirty status of keys" do
|
131
|
+
@ed["bar"] = "baz"
|
132
|
+
assert @ed.bar_changed?
|
133
|
+
@ed.save
|
134
|
+
assert !@ed.bar_changed?
|
135
|
+
end
|
136
|
+
|
137
|
+
should "remove nil keys from the hash" do
|
138
|
+
@ed["bar"] = "baz"
|
139
|
+
@ed.save
|
140
|
+
@ed["bar"] = nil
|
141
|
+
assert @ed.bar_changed?
|
142
|
+
@ed.save
|
143
|
+
assert !@ed.keys.include?("bar")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "deleteting extra data" do
|
148
|
+
should "remove it from the interface and the hash" do
|
149
|
+
key = :foo
|
150
|
+
@interface.expects(:set_extra_data).with(key.to_s, nil).once
|
151
|
+
@ed.expects(:hash_delete).with(key.to_s)
|
152
|
+
@ed.delete(key)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class ForwardedPortTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = VirtualBox::ForwardedPort
|
6
|
+
|
7
|
+
@nic = mock("nic")
|
8
|
+
@nic.stubs(:adapter_type).returns(:foo)
|
9
|
+
@nics = [@nic]
|
10
|
+
|
11
|
+
@caller = mock("caller")
|
12
|
+
@caller.stubs(:network_adapters).returns(@nics)
|
13
|
+
|
14
|
+
@interface = mock("interface")
|
15
|
+
end
|
16
|
+
|
17
|
+
context "validations" do
|
18
|
+
setup do
|
19
|
+
@collection = VirtualBox::Proxies::Collection.new(@caller)
|
20
|
+
|
21
|
+
@port = @klass.new
|
22
|
+
@port.name = "foo"
|
23
|
+
@port.guestport = "22"
|
24
|
+
@port.hostport = "2222"
|
25
|
+
@port.added_to_relationship(@collection)
|
26
|
+
end
|
27
|
+
|
28
|
+
should "be valid with all fields" do
|
29
|
+
assert @port.valid?
|
30
|
+
end
|
31
|
+
|
32
|
+
should "be invalid with no name" do
|
33
|
+
@port.name = nil
|
34
|
+
assert !@port.valid?
|
35
|
+
end
|
36
|
+
|
37
|
+
should "be invalid with no guest port" do
|
38
|
+
@port.guestport = nil
|
39
|
+
assert !@port.valid?
|
40
|
+
end
|
41
|
+
|
42
|
+
should "be invalid with no host port" do
|
43
|
+
@port.hostport = nil
|
44
|
+
assert !@port.valid?
|
45
|
+
end
|
46
|
+
|
47
|
+
should "be invalid if not in a relationship" do
|
48
|
+
@port.write_attribute(:parent, nil)
|
49
|
+
assert !@port.valid?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with an instance" do
|
54
|
+
setup do
|
55
|
+
@port = @klass.new({
|
56
|
+
:name => "foo",
|
57
|
+
:guestport => "22",
|
58
|
+
:hostport => "2222"
|
59
|
+
})
|
60
|
+
|
61
|
+
@collection = VirtualBox::Proxies::Collection.new(@caller)
|
62
|
+
@collection << @port
|
63
|
+
|
64
|
+
@port.clear_dirty!
|
65
|
+
|
66
|
+
@ed = mock("extradata")
|
67
|
+
@ed.stubs(:[]=)
|
68
|
+
@ed.stubs(:save)
|
69
|
+
@ed.stubs(:delete)
|
70
|
+
@caller.stubs(:extra_data).returns(@ed)
|
71
|
+
end
|
72
|
+
|
73
|
+
context "initializing a new record" do
|
74
|
+
setup do
|
75
|
+
@port = @klass.new
|
76
|
+
end
|
77
|
+
|
78
|
+
should "be a new record" do
|
79
|
+
assert @port.new_record?
|
80
|
+
end
|
81
|
+
|
82
|
+
should "not be dirty" do
|
83
|
+
assert !@port.changed?
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "device" do
|
88
|
+
setup do
|
89
|
+
@port.new_record!
|
90
|
+
@port.added_to_relationship(@collection)
|
91
|
+
end
|
92
|
+
|
93
|
+
should "return the value set if it was set" do
|
94
|
+
@port.device = "foo"
|
95
|
+
assert_equal "foo", @port.device
|
96
|
+
end
|
97
|
+
|
98
|
+
should "return the default if parent is nil" do
|
99
|
+
@port.expects(:parent).returns(nil)
|
100
|
+
assert_equal "pcnet", @port.device
|
101
|
+
end
|
102
|
+
|
103
|
+
should "return the default if the record is existing" do
|
104
|
+
@nic.expects(:adapter_type).never
|
105
|
+
@port.existing_record!
|
106
|
+
assert_equal "pcnet", @port.device
|
107
|
+
end
|
108
|
+
|
109
|
+
should "return pcnet if card is a Am79C970A type" do
|
110
|
+
@nic.expects(:adapter_type).returns(:Am79C970A)
|
111
|
+
assert_equal "pcnet", @port.device
|
112
|
+
end
|
113
|
+
|
114
|
+
should "return pcnet if card is a Am79C973 type" do
|
115
|
+
@nic.expects(:adapter_type).returns(:Am79C973)
|
116
|
+
assert_equal "pcnet", @port.device
|
117
|
+
end
|
118
|
+
|
119
|
+
should "return e1000 if card is a 82540EM type" do
|
120
|
+
@nic.expects(:adapter_type).returns(:I82540EM)
|
121
|
+
assert_equal "e1000", @port.device
|
122
|
+
end
|
123
|
+
|
124
|
+
should "return e1000 if card is a 82543GC type" do
|
125
|
+
@nic.expects(:adapter_type).returns(:I82543GC)
|
126
|
+
assert_equal "e1000", @port.device
|
127
|
+
end
|
128
|
+
|
129
|
+
should "return e1000 if card is a 82545EM type" do
|
130
|
+
@nic.expects(:adapter_type).returns(:I82545EM)
|
131
|
+
assert_equal "e1000", @port.device
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "saving" do
|
136
|
+
context "an existing record" do
|
137
|
+
setup do
|
138
|
+
@port.existing_record!
|
139
|
+
end
|
140
|
+
|
141
|
+
should "not do anything and return true if its unchanged" do
|
142
|
+
@caller.expects(:extra_data).never
|
143
|
+
assert @port.save
|
144
|
+
end
|
145
|
+
|
146
|
+
should "clear the dirty state after saving" do
|
147
|
+
@port.name = "diff"
|
148
|
+
@port.save
|
149
|
+
assert !@port.changed?
|
150
|
+
end
|
151
|
+
|
152
|
+
should "call destroy if the name changed" do
|
153
|
+
@port.name = "diff"
|
154
|
+
@port.expects(:destroy).once
|
155
|
+
@port.save
|
156
|
+
end
|
157
|
+
|
158
|
+
should "not call destroy if the name didn't change" do
|
159
|
+
assert !@port.name_changed?
|
160
|
+
@port.expects(:destroy).never
|
161
|
+
@port.save
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context "a new record" do
|
166
|
+
setup do
|
167
|
+
@port.stubs(:valid?).returns(true)
|
168
|
+
@port.new_record!
|
169
|
+
assert @port.new_record?
|
170
|
+
end
|
171
|
+
|
172
|
+
should "no longer be a new record after saving" do
|
173
|
+
@port.save
|
174
|
+
assert !@port.new_record?
|
175
|
+
end
|
176
|
+
|
177
|
+
should "raise a ValidationFailedException if invalid and raise_errors is true" do
|
178
|
+
@port.expects(:valid?).returns(false)
|
179
|
+
assert_raises(VirtualBox::Exceptions::ValidationFailedException) {
|
180
|
+
@port.save
|
181
|
+
}
|
182
|
+
end
|
183
|
+
|
184
|
+
should "call save on the extra_data" do
|
185
|
+
@ed = mock("ed")
|
186
|
+
@ed.expects(:[]=).times(3)
|
187
|
+
@ed.expects(:save).once
|
188
|
+
@caller.expects(:extra_data).times(4).returns(@ed)
|
189
|
+
@port.save
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context "key prefix" do
|
195
|
+
should "return a proper key prefix constructed with the attributes" do
|
196
|
+
assert_equal "VBoxInternal\/Devices\/#{@port.device}\/#{@port.instance}\/LUN#0\/Config\/#{@port.name}\/", @port.key_prefix
|
197
|
+
end
|
198
|
+
|
199
|
+
should "return with previous name if parameter is true" do
|
200
|
+
@port.name = "diff"
|
201
|
+
assert @port.name_changed?
|
202
|
+
assert_equal "VBoxInternal\/Devices\/#{@port.device}\/#{@port.instance}\/LUN#0\/Config\/#{@port.name_was}\/", @port.key_prefix(true)
|
203
|
+
end
|
204
|
+
|
205
|
+
should "not use previous name if parameter is true and name didn't change" do
|
206
|
+
assert !@port.name_changed?
|
207
|
+
assert_equal "VBoxInternal\/Devices\/#{@port.device}\/#{@port.instance}\/LUN#0\/Config\/#{@port.name}\/", @port.key_prefix(true)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "destroying" do
|
212
|
+
setup do
|
213
|
+
@port.existing_record!
|
214
|
+
end
|
215
|
+
|
216
|
+
should "remove itself from it's collection" do
|
217
|
+
assert @collection.include?(@port)
|
218
|
+
@port.destroy
|
219
|
+
assert !@collection.include?(@port)
|
220
|
+
end
|
221
|
+
|
222
|
+
should "call delete on the extra data for each key" do
|
223
|
+
@ed = mock("ed")
|
224
|
+
@ed.expects(:delete).times(3)
|
225
|
+
@caller.expects(:extra_data).times(3).returns(@ed)
|
226
|
+
@port.destroy
|
227
|
+
end
|
228
|
+
|
229
|
+
should "do nothing if the record is new" do
|
230
|
+
@port.new_record!
|
231
|
+
@caller.expects(:extra_data).never
|
232
|
+
@port.destroy
|
233
|
+
end
|
234
|
+
|
235
|
+
should "be a new record after destroying" do
|
236
|
+
@port.destroy
|
237
|
+
assert @port.new_record?
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
context "relationships" do
|
243
|
+
context "saving" do
|
244
|
+
should "call #save on every object" do
|
245
|
+
objects = []
|
246
|
+
5.times do |i|
|
247
|
+
object = mock("object#{i}")
|
248
|
+
object.expects(:save).once
|
249
|
+
objects.push(object)
|
250
|
+
end
|
251
|
+
|
252
|
+
VirtualBox::ForwardedPort.save_relationship(@caller, objects)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context "populating" do
|
257
|
+
setup do
|
258
|
+
@caller.stubs(:extra_data).returns({
|
259
|
+
"invalid" => "7",
|
260
|
+
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" => "22",
|
261
|
+
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" => "2222",
|
262
|
+
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" => "TCP"
|
263
|
+
})
|
264
|
+
|
265
|
+
@objects = VirtualBox::ForwardedPort.populate_relationship(@caller, {})
|
266
|
+
end
|
267
|
+
|
268
|
+
should "return an array of ForwardedPorts" do
|
269
|
+
assert @objects.is_a?(VirtualBox::Proxies::Collection)
|
270
|
+
assert @objects.all? { |o| o.is_a?(VirtualBox::ForwardedPort) }
|
271
|
+
end
|
272
|
+
|
273
|
+
should "have the proper data" do
|
274
|
+
object = @objects.first
|
275
|
+
assert_equal "22", object.guestport
|
276
|
+
assert_equal "2222", object.hostport
|
277
|
+
assert_equal "TCP", object.protocol
|
278
|
+
assert_equal @objects, object.parent_collection
|
279
|
+
end
|
280
|
+
|
281
|
+
should "be existing records" do
|
282
|
+
assert !@objects.first.new_record?
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|