© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y 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


  [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");
        }
  [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!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ How to write unit test for this?
C#CC# / help
16mo ago
Unit test help
C#CC# / help
17mo ago
Need help on how to write unit tests in xunit for the code
C#CC# / help
3y ago
❔ Unit Test | Mocking class with unsafe methods
C#CC# / help
3y ago