I will visit Toronto this summer. I have a US VISA credit card and a US MasterCard debit card. Do stores there usually accept these two cards? If so, which one has the cheaper transaction fee, or are both expensive and it's better to use cash?
Almost all stores will accept both these cards. Mastercard and Visa are accepted everywhere credit cards are accepted in Canada which is most places. Some stores are cash-only or debit only but not many of them are left.
Whichever one will have the lowest fee will depend on the particular card you have. When you got each card, it will have come with a cardholder agreement. On it, each one will specify the foreign transaction fee charged. This is a percentage of the sale, usually around 2.5% but there exists cards with 0% and I have seen up to 3.5%. If you no longer have the agreement, go to the website of each bank that issues your cards and look for the information there.
It is good to have cash for things like bus fares and small items but getting cash only means that you paid the transaction fee ahead of time when you did the conversion. You usually would have to pay it again even to convert unspent foreign currency, although some places have a buy-back contract that lets you get back converted currency up to a certain number of days after you converted with them.
Debit card transactions on the other hand do not usually work between Canada and the US. You may use your US debit card to withdraw cash from most Canadian ATMs which will give you a good rate plus some fees. For small withdraws fees are usually steep since there is often a flat amount plus a percentage.