0

Need to create unit test cases using NUnit Test Cases in a C# Application. All Test Cases are working as expected except created for Methods referring to resource files inside it for some culture related descriptions

Getting Below Mentioned Error on Running Test Cases {"Could not load file or assembly 'App_GlobalResources' or one of its dependencies. The system cannot find the file specified.":"App_GlobalResources"}

---- Method Code Referring Resource Files ----

                listEmployees = (from u in context.EmployeeMaster
                                 select new Employee()
                                 {
                                     EmployeeId = u.EmployeeId,
                                     EmployeeName = u.EmployeeName,
                                     CreatedDate = u.CreatedDate,
                                     CreatedBy = u.CreatedBy,
                                     ModifiedDate = u.ModifiedDate,
                                     ModifiedBy = u.ModifiedBy,
                                     status = (u.IsActive) ? @Resources.Resource.Active : @Resources.Resource.InActive
                                 }
                              ).ToList();

Please suggest

Garg Mankush
  • 59
  • 1
  • 6
  • There is an existing thread for that already https://stackoverflow.com/questions/4153748/app-globalresources-not-loading-in-a-unit-test-case – Pavel Anikhouski Mar 25 '19 at 08:00
  • Thanks Pavel, But if its possible without moving resources out of 'App_GlobalResources ' folder as in that case need to modify entire application wherever it is used. If possible can you please help me with one example for handling resources using mocking HttpContext explained in provided link, Thanks in advance – Garg Mankush Mar 27 '19 at 11:15
  • Just check out MS Fakes..: https://social.msdn.microsoft.com/Forums/vstudio/en-US/4e423407-300d-46ba-bfc9-30465fb18f07/how-to-fake-httpcontextcurrent-using-shim?forum=vstest – Steve Apr 01 '19 at 08:58

0 Answers0