ice maker not working

Ice maker is not getting water. I switched the plug on the water inlet valve and water goes into the tray when I push the water switch. I checked the optics in the door and they seem to be working fine. How do I check to see if the ice maker tray is bad? What makes the water inlet valve switch on? Any help would be greatly appreciated.