Move HDD from a MacBook Pro (Mid 2012) model to another MacBook Pro (Mid 2012) model
As long as you're certain the replacement hardware is identical to your original, then yes this will work. One important caveat:

This is something I would not do without testing first. I'd invest in either a USB-SATA drive adapter or a cheap USB enclosure and use that to connect your old laptop's drive to the replacement laptop and see if it comes up as a bootable drive by holding down the option key at startup. If it shows up in the boot manager and successfully boots the system that way then it should be ok to swap it in. 

If you're unsure of how to verify if your replacement is the same build as your old laptop I'd recommend using this site: [http://www.chipmunk.nl/klantenservice/applemodel.html/] to do a comparison using the serial numbers of both systems.