C
C#5mo ago
Raki

Please help, Hi I need to write unit test for the following methods

I have my code with 3 to 4 methods I need to write unit test for them Any ideas. As you can see all are method which only calls http methods. I already wrote few to check whether they call the correct entry in xunit similar to below. Reaching to the community for your code review comments for the fiddler code and possibility of any unit testing beyond the one which I have written below. https://paste.mod.gg/wvyxvurvrzuh/0
c#
[Fact]
public async Task ContentfulManagementClient_CreateEntry_IfSlugAndPreviousSlugDifferent()
{
//// Arrange
var contentTypeId = "pagePatientProfessionalArticle";
var entryId = "test";
var slug = "/newtest1";
var previousSlug = "/newtest2";

var r = new StreamReader("../../../mockdata/RedirectEntryModel.json");
var json = r.ReadToEnd();

SetupResponseJson(HttpStatusCode.OK, json);

// act
await _sut.HandleRedirectAsync(slug, previousSlug, contentTypeId, entryId);

//act
AssertRequest(HttpMethod.Put, $"/entries/{entryId}/published");
}
c#
[Fact]
public async Task ContentfulManagementClient_CreateEntry_IfSlugAndPreviousSlugDifferent()
{
//// Arrange
var contentTypeId = "pagePatientProfessionalArticle";
var entryId = "test";
var slug = "/newtest1";
var previousSlug = "/newtest2";

var r = new StreamReader("../../../mockdata/RedirectEntryModel.json");
var json = r.ReadToEnd();

SetupResponseJson(HttpStatusCode.OK, json);

// act
await _sut.HandleRedirectAsync(slug, previousSlug, contentTypeId, entryId);

//act
AssertRequest(HttpMethod.Put, $"/entries/{entryId}/published");
}
BlazeBin - wvyxvurvrzuh
A tool for sharing your source code with the world!
0 Replies
No replies yetBe the first to reply to this messageJoin