[Datadude] Refactoring applies the wrong edits to Unit Tests - by Jamie Thomson

Status : 

 


1
0
Sign in
to vote
ID 668651 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 5/16/2011 1:24:35 AM
Access Restriction Public

Description

Hello,
I have discovered that refactoring of objects from Schema View can carry out incorrect edits on Unit tests. Here is the contents of one of my tests *prior* to refactoring:

SELECT	*
FROM	bi.ProcessMessageLog pml
INNER JOIN bi.[LogMessageType] lmt
	ON	pml.[LogMessageTypeId] = lmt.[LogMessageTypeId]
WHERE	pml.[LogMessage] = 'Skipped processing of message: IApplicationCanceled'
AND		lmt.[LogMessageType] = 'Warning';

The refactor operation that I want to carry out is to change the name of field lmt.[LogMessageType] to lmt.[LogMessageTypeName].

The Refactor Preview Changes window is shown here: http://cid-550f681dad532637.office.live.com/self.aspx/Public/Misc/20110516%20Refacoring%20preview%20changes.png (I will upload the screenshot to Connect also but of late Connect is simply losing attachments so as a failsafe I am putting it on Skydrive also)
Notice that I am renaming [LogMessageType] to [LogMessageTypeName]. Also notice the change that it wants to make to my Unit Test. the edit that it is going to carry out is completely wrong - effectively obliterating my code. After hitting "Apply" on the refactor here is the resultant code:

SELECT	*
FROM	bi.ProcessMessageLog pml
INNER JOIN bi.[LogMessageType] lmt
	ON	pml.[LogMessageTypeId] = lmt.[LogMessageTypeId]
WHERE	pml.[LogMessage] = 'Ski[LogMessageTypeName]of message: IApplicationCanceled'
AND		lmt.[LogMessageType] = 'Warning';

As you can see it has edited my code to the point that it will error when I run it (because it didn't rename the column).

This is not an isolated incident - it happens a lot.
Sign in to post a comment.
Posted by MS-Moderator08 on 5/27/2011 at 2:35 AM
Hello,

Sorry for bothering. Is there any update?

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.
Posted by MS-Moderator08 on 5/16/2011 at 2:04 AM
Thank you for reporting this issue. But we were not able to reproduce it with the steps you provided. Could you please attach a demo project to help us investigate this issue?