Skip to content

Commit ea8d893

Browse files
committed
change the FakeCampaignDto private object to an GetFakeCampaignDto funtion
1 parent b5f90cf commit ea8d893

2 files changed

Lines changed: 24 additions & 20 deletions

File tree

src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using System.Linq;
1212

1313
[Route("api/v1/[controller]")]
14-
//[Authorize]
14+
[Authorize]
1515
public class CampaignsController : Controller
1616
{
1717
private readonly MarketingContext _context;
@@ -178,6 +178,5 @@ private Campaign MapCampaignDtoToModel(CampaignDTO campaignDto)
178178

179179
return campaingModel;
180180
}
181-
182181
}
183182
}

test/Services/IntegrationTests/Services/Marketing/MarketingScenarios.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public async Task Post_add_new_campaign_and_response_ok_status_code()
5555
{
5656
using (var server = CreateServer())
5757
{
58-
var content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json");
58+
var fakeCampaignDto = GetFakeCampaignDto();
59+
var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
5960
var response = await server.CreateClient()
6061
.PostAsync(Post.AddNewCampaign, content);
6162

@@ -68,7 +69,8 @@ public async Task Delete_delete_campaign_and_response_not_content_status_code()
6869
{
6970
using (var server = CreateServer())
7071
{
71-
var content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json");
72+
var fakeCampaignDto = GetFakeCampaignDto();
73+
var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
7274

7375
//add campaign
7476
var campaignResponse = await server.CreateClient()
@@ -91,16 +93,17 @@ public async Task Put_update_campaign_and_response_not_content_status_code()
9193
{
9294
using (var server = CreateServer())
9395
{
94-
var content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json");
96+
var fakeCampaignDto = GetFakeCampaignDto();
97+
var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
9598

9699
//add campaign
97100
var campaignResponse = await server.CreateClient()
98101
.PostAsync(Post.AddNewCampaign, content);
99102

100103
if (int.TryParse(campaignResponse.Headers.Location.Segments[4], out int id))
101104
{
102-
FakeCampaignDto.Description = "FakeCampaignUpdatedDescription";
103-
content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json");
105+
fakeCampaignDto.Description = "FakeCampaignUpdatedDescription";
106+
content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
104107
var response = await server.CreateClient()
105108
.PutAsync(Put.CampaignBy(id), content);
106109

@@ -111,22 +114,24 @@ public async Task Put_update_campaign_and_response_not_content_status_code()
111114
}
112115
}
113116

114-
115-
private static CampaignDTO FakeCampaignDto = new CampaignDTO
117+
private static CampaignDTO GetFakeCampaignDto()
116118
{
117-
Description = "FakeCampaignDescription",
118-
From = DateTime.Now,
119-
To = DateTime.Now.AddDays(7),
120-
Url = "http://CampaignUrl.test/fdaf91ad0cef5419719f50198",
121-
Rules = new List<RuleDTO>
119+
return new CampaignDTO()
122120
{
123-
new RuleDTO
121+
Description = "FakeCampaignDescription",
122+
From = DateTime.Now,
123+
To = DateTime.Now.AddDays(7),
124+
Url = "http://CampaignUrl.test/fdaf91ad0cef5419719f50198",
125+
Rules = new List<RuleDTO>
124126
{
125-
LocationId = 1,
126-
Description = "testDescription",
127-
RuleTypeId = 3,
127+
new RuleDTO
128+
{
129+
LocationId = 1,
130+
Description = "testDescription",
131+
RuleTypeId = 3,
132+
}
128133
}
129-
}
130-
};
134+
};
135+
}
131136
}
132137
}

0 commit comments

Comments
 (0)