{"id":28328471,"url":"https://github.com/nosratifarhad/integrationtest_xunit","last_synced_at":"2026-04-27T11:31:11.184Z","repository":{"id":163403467,"uuid":"627477133","full_name":"nosratifarhad/IntegrationTest_XUnit","owner":"nosratifarhad","description":"Integration test Use XUnit Use Bogus And HttpClient","archived":false,"fork":false,"pushed_at":"2023-11-30T12:13:40.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T08:43:21.108Z","etag":null,"topics":["bogus","dotnet","dotnet-core","dotnetcore","faker","httpclient","integration","integration-testing","integrationtest"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nosratifarhad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-13T14:45:57.000Z","updated_at":"2023-05-10T10:42:21.000Z","dependencies_parsed_at":"2023-11-30T13:41:40.036Z","dependency_job_id":null,"html_url":"https://github.com/nosratifarhad/IntegrationTest_XUnit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nosratifarhad/IntegrationTest_XUnit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FIntegrationTest_XUnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FIntegrationTest_XUnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FIntegrationTest_XUnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FIntegrationTest_XUnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nosratifarhad","download_url":"https://codeload.github.com/nosratifarhad/IntegrationTest_XUnit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FIntegrationTest_XUnit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32335295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bogus","dotnet","dotnet-core","dotnetcore","faker","httpclient","integration","integration-testing","integrationtest"],"created_at":"2025-05-26T06:17:06.849Z","updated_at":"2026-04-27T11:31:11.180Z","avatar_url":"https://github.com/nosratifarhad.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IntegrationTest In Xunit\n\n * Test From ApiControllers Services To Repositories .\n * Test Exceptions .\n * Test All Logics in Services .\n * Test All Validation .\n----\n### * Install pakeges :\n* dotnet add package FluentAssertions\n* dotnet add package Bogus\n\n## I Use \"FluentAssertions\" For Handle Assert Tests \n* You can See All Sample \"FluentAssertions\" In [This Repository](https://github.com/nosratifarhad/FluentAssertions.git/).\n\n----\n### Test For Created Successed Product\n\n```csharp\n[Fact]\npublic async Task When_ValidCreateProductInputModelInCreateProduct_Then_CreatedProductInDataBase()\n{\n    var mockInputModel = ProductMockData.ValidCreateProductInputModel().ToRequestModel();\n\n    var response = await _client.PostAsync(\"/api/product\", mockInputModel).ConfigureAwait(false);\n\n    response.StatusCode.Should().Be(System.Net.HttpStatusCode.Created);\n    response.IsSuccessStatusCode.Should().BeTrue();\n\n    var productId = await response.ToRequestItem(\"ProductId\");\n\n    var newProductViewModel = await GetProductByResponseHeadersLocation(response.Headers.Location.AbsoluteUri).ConfigureAwait(false);\n\n    newProductViewModel.Should().NotBeNull();\n    newProductViewModel.ProductId.Should().Be(productId);\n}\n```\n\n### Test For Update Successed Product\n```csharp\n[Fact]\npublic async Task When_ValidUpdateProductInputModelInUpdateProduct_Then_UpdateProductInDataBase()\n{\n    var validUpdateProductInputModel = ProductMockData.ValidUpdateProductInputModel();\n\n    int productId = validUpdateProductInputModel.ProductId;\n\n    var mockInputModel = validUpdateProductInputModel.ToRequestModel();\n\n    var response = await _client.PutAsync($\"/api/product/{productId}\", mockInputModel).ConfigureAwait(false);\n\n    response.StatusCode.Should().Be(System.Net.HttpStatusCode.NoContent);\n    response.IsSuccessStatusCode.Should().BeTrue();\n\n    var newProductViewModel = await GetProductByProductId(productId).ConfigureAwait(false);\n\n    newProductViewModel.Should().NotBeNull();\n    newProductViewModel.ProductId.Should().Be(productId);\n}\n```\n\n### Test For Get All Products\n\n```csharp\n[Fact]\npublic async Task When_CallGetProducts_Then_ReturnListPoductViewModel()\n{\n    var response = await _client.GetAsync(\"/api/products\").ConfigureAwait(false);\n\n    var responseModel = await response.ToResponseModel\u003cIEnumerable\u003cProductViewModel\u003e\u003e();\n\n    response.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);\n    response.IsSuccessStatusCode.Should().BeTrue();\n\n    responseModel.Should().NotBeNull();\n    responseModel.Should().HaveCount(5);\n}\n```\n\n### Test For Get By ProductId\n\n```csharp\n[Fact]\npublic async Task When_ValidProductIdInGetProduct_Then_ReturnedProductViewModel()\n{\n    int productId = await GetValidProductId();\n\n    var response = await _client.GetAsync($\"/api/product/{productId}\").ConfigureAwait(false);\n\n    response.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);\n    response.IsSuccessStatusCode.Should().BeTrue();\n\n    var responseModel = await response.ToResponseModel\u003cProductViewModel\u003e();\n\n    responseModel.Should().NotBeNull();\n    responseModel.ProductId.Should().Be(productId);\n}\n```\n### User Bogus For Generate Fake Data In MockDatas Like This\n\n```csharp\npublic static UpdateProductInputModel ValidUpdateProductInputModel()\n    =\u003e new Faker\u003cUpdateProductInputModel\u003e()\n        .RuleFor(bp =\u003e bp.ProductId, f =\u003e f.Random.Number(1, 5))\n        .RuleFor(bp =\u003e bp.ProductName, f =\u003e f.Name.FirstName())\n        .RuleFor(bp =\u003e bp.ProductTitle, f =\u003e f.Name.JobTitle())\n        .RuleFor(bp =\u003e bp.ProductDescription, f =\u003e f.Name.JobDescriptor())\n        .RuleFor(bp =\u003e bp.ProductCategory, f =\u003e f.Random.Enum\u003cProductCategory\u003e())\n        .RuleFor(bp =\u003e bp.MainImageName, f =\u003e f.Name.FullName())\n        .RuleFor(bp =\u003e bp.MainImageTitle, f =\u003e f.Name.FullName())\n        .RuleFor(bp =\u003e bp.MainImageUri, f =\u003e f.Name.FullName())\n        .RuleFor(bp =\u003e bp.Color, f =\u003e f.Random.Enum\u003cProductColor\u003e())\n        .RuleFor(bp =\u003e bp.IsFreeDelivery, f =\u003e f.Random.Bool())\n        .RuleFor(bp =\u003e bp.IsExisting, f =\u003e f.Random.Bool())\n        .RuleFor(bp =\u003e bp.Weight, f =\u003e f.Random.Number());\n```\n### Passed All Tests\n\n![My Remote Image](https://github.com/nosratifarhad/Xunit_IntegrationTest/blob/main/docs/res.png)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosratifarhad%2Fintegrationtest_xunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnosratifarhad%2Fintegrationtest_xunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosratifarhad%2Fintegrationtest_xunit/lists"}