问题描述
我有一个 Setup.recipe.json 文件,其中存在一个带有 html 字符串的内容项,其中包含德语“变音”字符,例如 "ö"、"ü" 等。我尝试向配方文件中添加几个设置,然后我还启用了所有“国际化”模块,并将此代码段添加到我的 Startup.cs 文件中:
class ApiServiceTest {
private lateinit var client: okhttp3.OkHttpClient
private lateinit var apiService: ApiService
@BeforeEach
fun setup() {
// Setup a new mock for each test case
client = mockk(relaxed = true)
apiService = ApiService(client)
}
@Test
fun `test with mockedCallback`() {
val mockedCall = mockk<Call>(relaxed = true)
every { mockedCall.enqueue(any()) } answers {
//Get the callback from the arguments
val callback = args[0] as Callback
// Create a fakeRequest
val fakeRequest = okhttp3.Request.Builder().url("https://someendpoint.com.br/").build()
// Create the response you need to test,it can be failure or success
val errorResponse = Response.Builder()
.request(fakeRequest)
.protocol(Protocol.HTTP_1_1)
.code(400)
.message("Error")
.build()
//Call the callback with the mocked response you created.
callback.onResponse(mockedCall,errorResponse)
}
// Setup the client mock to return the mocked call you created
every {
client.newCall(any())
} returns mockedCall
apiService.makeApiCall()
// Verify whatever you need to test your logic to handle each case.
}
}
尽管有这些,但在保存和发布内容后,我无法在内容中显示这些字符。任何帮助,将不胜感激。提前致谢。
解决方法
我建议在问题或讨论中的 https://github.com/OrchardCMS/OrchardCore 存储库中提出此类问题。