|
8 | 8 | using Microsoft.AspNetCore.Razor.Test.Common; |
9 | 9 | using Microsoft.CodeAnalysis; |
10 | 10 | using Microsoft.CodeAnalysis.ExternalAccess.Razor; |
| 11 | +using Microsoft.CodeAnalysis.Razor.Workspaces; |
| 12 | +using Microsoft.CodeAnalysis.Remote.Razor; |
11 | 13 | using Microsoft.CodeAnalysis.Testing; |
12 | 14 | using Microsoft.CodeAnalysis.Text; |
13 | 15 | using Xunit; |
@@ -847,6 +849,184 @@ The end. |
847 | 849 | """) |
848 | 850 | ]); |
849 | 851 |
|
| 852 | + [Fact] |
| 853 | + public Task Component_OwnFile_WithCss() |
| 854 | + => VerifyRenamesAsync( |
| 855 | + input: $""" |
| 856 | + This is a Razor document. |
| 857 | +
|
| 858 | + <Fi$$le1 /> |
| 859 | + <File1></File1> |
| 860 | + <File1> |
| 861 | + </File1> |
| 862 | +
|
| 863 | + The end. |
| 864 | + """, |
| 865 | + additionalFiles: [ |
| 866 | + (FilePath("File1.razor.css"), "") |
| 867 | + ], |
| 868 | + newName: "ABetterName", |
| 869 | + expected: """ |
| 870 | + This is a Razor document. |
| 871 | +
|
| 872 | + <ABetterName /> |
| 873 | + <ABetterName></ABetterName> |
| 874 | + <ABetterName> |
| 875 | + </ABetterName> |
| 876 | +
|
| 877 | + The end. |
| 878 | + """, |
| 879 | + newFileUri: FileUri("ABetterName.razor"), |
| 880 | + additionalExpectedFiles: [ |
| 881 | + (FileUri("ABetterName.razor.css"), "")]); |
| 882 | + |
| 883 | + [Fact] |
| 884 | + public Task Component_OwnFile_WithCodeBehind() |
| 885 | + => VerifyRenamesAsync( |
| 886 | + input: $""" |
| 887 | + This is a Razor document. |
| 888 | +
|
| 889 | + <Fi$$le1 /> |
| 890 | + <File1></File1> |
| 891 | + <File1> |
| 892 | + </File1> |
| 893 | +
|
| 894 | + The end. |
| 895 | + """, |
| 896 | + additionalFiles: [ |
| 897 | + (FilePath("File1.razor.cs"), """ |
| 898 | + namespace SomeProject; |
| 899 | +
|
| 900 | + // This class name should change, but we don't support that yet |
| 901 | + public partial class File1 |
| 902 | + { |
| 903 | + } |
| 904 | + """) |
| 905 | + ], |
| 906 | + newName: "ABetterName", |
| 907 | + expected: """ |
| 908 | + This is a Razor document. |
| 909 | +
|
| 910 | + <ABetterName /> |
| 911 | + <ABetterName></ABetterName> |
| 912 | + <ABetterName> |
| 913 | + </ABetterName> |
| 914 | +
|
| 915 | + The end. |
| 916 | + """, |
| 917 | + newFileUri: FileUri("ABetterName.razor"), |
| 918 | + additionalExpectedFiles: [ |
| 919 | + (FileUri("ABetterName.razor.cs"), """ |
| 920 | + namespace SomeProject; |
| 921 | +
|
| 922 | + // This class name should change, but we don't support that yet |
| 923 | + public partial class File1 |
| 924 | + { |
| 925 | + } |
| 926 | + """)]); |
| 927 | + |
| 928 | + [Fact] |
| 929 | + public Task Component_WithOtherFile_WithCss() |
| 930 | + => VerifyRenamesAsync( |
| 931 | + input: $""" |
| 932 | + This is a Razor document. |
| 933 | +
|
| 934 | + <Comp$$onent /> |
| 935 | + <Component></Component> |
| 936 | + <Component> |
| 937 | + </Component> |
| 938 | +
|
| 939 | + The end. |
| 940 | + """, |
| 941 | + additionalFiles: [ |
| 942 | + (FilePath("Component.razor.css"), ""), |
| 943 | + (FilePath("Component.razor"), """ |
| 944 | + <Component /> |
| 945 | + <Component></Component> |
| 946 | + <Component> |
| 947 | + </Component> |
| 948 | + """) |
| 949 | + ], |
| 950 | + newName: "DifferentName", |
| 951 | + expected: """ |
| 952 | + This is a Razor document. |
| 953 | +
|
| 954 | + <DifferentName /> |
| 955 | + <DifferentName></DifferentName> |
| 956 | + <DifferentName> |
| 957 | + </DifferentName> |
| 958 | +
|
| 959 | + The end. |
| 960 | + """, |
| 961 | + additionalExpectedFiles: [ |
| 962 | + (FileUri("DifferentName.razor.css"), ""), |
| 963 | + (FileUri("DifferentName.razor"), """ |
| 964 | + <DifferentName /> |
| 965 | + <DifferentName></DifferentName> |
| 966 | + <DifferentName> |
| 967 | + </DifferentName> |
| 968 | + """), |
| 969 | + ]); |
| 970 | + |
| 971 | + [Fact] |
| 972 | + public Task Component_WithOtherFile_WithCodeBehindAndCss() |
| 973 | + => VerifyRenamesAsync( |
| 974 | + input: $""" |
| 975 | + This is a Razor document. |
| 976 | +
|
| 977 | + <Comp$$onent /> |
| 978 | + <Component></Component> |
| 979 | + <Component> |
| 980 | + </Component> |
| 981 | +
|
| 982 | + The end. |
| 983 | + """, |
| 984 | + additionalFiles: [ |
| 985 | + (FilePath("Component.razor.css"), ""), |
| 986 | + (FilePath("Component.razor.cs"), """ |
| 987 | + namespace SomeProject; |
| 988 | +
|
| 989 | + // This class name should change, but we don't support that yet |
| 990 | + public partial class Component |
| 991 | + { |
| 992 | + } |
| 993 | + """), |
| 994 | + (FilePath("Component.razor"), """ |
| 995 | + <Component /> |
| 996 | + <Component></Component> |
| 997 | + <Component> |
| 998 | + </Component> |
| 999 | + """) |
| 1000 | + ], |
| 1001 | + newName: "DifferentName", |
| 1002 | + expected: """ |
| 1003 | + This is a Razor document. |
| 1004 | +
|
| 1005 | + <DifferentName /> |
| 1006 | + <DifferentName></DifferentName> |
| 1007 | + <DifferentName> |
| 1008 | + </DifferentName> |
| 1009 | +
|
| 1010 | + The end. |
| 1011 | + """, |
| 1012 | + additionalExpectedFiles: [ |
| 1013 | + (FileUri("DifferentName.razor.css"), ""), |
| 1014 | + (FileUri("DifferentName.razor.cs"), """ |
| 1015 | + namespace SomeProject; |
| 1016 | +
|
| 1017 | + // This class name should change, but we don't support that yet |
| 1018 | + public partial class Component |
| 1019 | + { |
| 1020 | + } |
| 1021 | + """), |
| 1022 | + (FileUri("DifferentName.razor"), """ |
| 1023 | + <DifferentName /> |
| 1024 | + <DifferentName></DifferentName> |
| 1025 | + <DifferentName> |
| 1026 | + </DifferentName> |
| 1027 | + """), |
| 1028 | + ]); |
| 1029 | + |
850 | 1030 | private async Task VerifyRenamesAsync( |
851 | 1031 | string input, |
852 | 1032 | string newName, |
|
0 commit comments