change the FakeCampaignDto private object to an GetFakeCampaignDto funtion

This commit is contained in:
Christian Arenas 2017-06-05 19:36:09 +02:00
parent 7842194637
commit bb167617bf
2 changed files with 24 additions and 20 deletions

View File

@ -11,7 +11,7 @@
using System.Linq; using System.Linq;
[Route("api/v1/[controller]")] [Route("api/v1/[controller]")]
//[Authorize] [Authorize]
public class CampaignsController : Controller public class CampaignsController : Controller
{ {
private readonly MarketingContext _context; private readonly MarketingContext _context;
@ -178,6 +178,5 @@
return campaingModel; return campaingModel;
} }
} }
} }

View File

@ -55,7 +55,8 @@
{ {
using (var server = CreateServer()) using (var server = CreateServer())
{ {
var content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json"); var fakeCampaignDto = GetFakeCampaignDto();
var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
var response = await server.CreateClient() var response = await server.CreateClient()
.PostAsync(Post.AddNewCampaign, content); .PostAsync(Post.AddNewCampaign, content);
@ -68,7 +69,8 @@
{ {
using (var server = CreateServer()) using (var server = CreateServer())
{ {
var content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json"); var fakeCampaignDto = GetFakeCampaignDto();
var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
//add campaign //add campaign
var campaignResponse = await server.CreateClient() var campaignResponse = await server.CreateClient()
@ -91,7 +93,8 @@
{ {
using (var server = CreateServer()) using (var server = CreateServer())
{ {
var content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json"); var fakeCampaignDto = GetFakeCampaignDto();
var content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
//add campaign //add campaign
var campaignResponse = await server.CreateClient() var campaignResponse = await server.CreateClient()
@ -99,8 +102,8 @@
if (int.TryParse(campaignResponse.Headers.Location.Segments[4], out int id)) if (int.TryParse(campaignResponse.Headers.Location.Segments[4], out int id))
{ {
FakeCampaignDto.Description = "FakeCampaignUpdatedDescription"; fakeCampaignDto.Description = "FakeCampaignUpdatedDescription";
content = new StringContent(JsonConvert.SerializeObject(FakeCampaignDto), Encoding.UTF8, "application/json"); content = new StringContent(JsonConvert.SerializeObject(fakeCampaignDto), Encoding.UTF8, "application/json");
var response = await server.CreateClient() var response = await server.CreateClient()
.PutAsync(Put.CampaignBy(id), content); .PutAsync(Put.CampaignBy(id), content);
@ -111,22 +114,24 @@
} }
} }
private static CampaignDTO GetFakeCampaignDto()
private static CampaignDTO FakeCampaignDto = new CampaignDTO
{ {
Description = "FakeCampaignDescription", return new CampaignDTO()
From = DateTime.Now,
To = DateTime.Now.AddDays(7),
Url = "http://CampaignUrl.test/fdaf91ad0cef5419719f50198",
Rules = new List<RuleDTO>
{ {
new RuleDTO Description = "FakeCampaignDescription",
From = DateTime.Now,
To = DateTime.Now.AddDays(7),
Url = "http://CampaignUrl.test/fdaf91ad0cef5419719f50198",
Rules = new List<RuleDTO>
{ {
LocationId = 1, new RuleDTO
Description = "testDescription", {
RuleTypeId = 3, LocationId = 1,
Description = "testDescription",
RuleTypeId = 3,
}
} }
} };
}; }
} }
} }