@@ -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