public async Task CreateExpectedAssets() { var cost = await CreateCostEntity(User); var latestStage = await GetCostLatestStage(cost.Id, User); var latestRevision = await GetCostLatestRevision(cost.Id, latestStage.Id, User); var mediaTypeId = await GetMediaTypeId(); CreateMediaTypeMappingIfNotCreated(mediaTypeId); var model = new CreateExpectedAssetModel { Title = "Title1", AdId = "DAGWJHOER123", AiringRegions = new[] { "EMEA" }, Duration = TimeSpan.FromHours(1).ToString(), Definition = "HD", MediaTypeId = mediaTypeId, OvalTypeId = await GetOvalTypeId(), FirstAirDate = DateTime.UtcNow.AddDays(5), AssetId = "ADGADG", Scrapped = false }; var url = ExpectedAssetsUrl(cost.Id, latestStage.Id, latestRevision.Id); var createExpectedAssetResponse = await Browser.Post(url, with => { with.User(User); with.JsonBody(model); }); var expectedAsset = Deserialize <ExpectedAsset>(createExpectedAssetResponse, HttpStatusCode.Created); expectedAsset.Title.Should().Be(model.Title); expectedAsset.ProjectAdIdId.Should().NotBeEmpty(); expectedAsset.AiringRegions.Should().BeEquivalentTo(model.AiringRegions); expectedAsset.Duration.ToString().Should().Be(model.Duration); expectedAsset.Definition.Should().Be(model.Definition); expectedAsset.MediaTypeId.Should().Be(model.MediaTypeId); expectedAsset.OvalTypeId.Should().Be(model.OvalTypeId); expectedAsset.FirstAirDate.Should().BeSameDateAs(model.FirstAirDate); expectedAsset.AssetId.Should().Be(model.AssetId); expectedAsset.Scrapped.Should().Be(model.Scrapped); }
public async Task DeleteExpectedAsset() { var cost = await CreateCostEntity(User); var latestStage = await GetCostLatestStage(cost.Id, User); var latestRevision = await GetCostLatestRevision(cost.Id, latestStage.Id, User); var mediaTypeId = await GetMediaTypeId(); CreateMediaTypeMappingIfNotCreated(mediaTypeId); var model = new CreateExpectedAssetModel { Title = "Title1", AdId = "DAGWJHOER1O", AiringRegions = new[] { "EMEA" }, Duration = TimeSpan.FromHours(1).ToString(), Definition = "HD", MediaTypeId = mediaTypeId, OvalTypeId = await GetOvalTypeId(), FirstAirDate = DateTime.UtcNow.AddDays(5), AssetId = "ADGADG", Scrapped = false }; var url = ExpectedAssetsUrl(cost.Id, latestStage.Id, latestRevision.Id); var expectedAsset = Deserialize <ExpectedAsset>(await Browser.Post(url, with => { with.User(User); with.JsonBody(model); }), HttpStatusCode.Created); url += "/" + expectedAsset.Id; var deleteRequest = await Browser.Delete(url, w => w.User(User)); deleteRequest.StatusCode.Should().Be(HttpStatusCode.OK); }
public async Task UpdateExpectedAsset() { var cost = await CreateCostEntity(User); var latestStage = await GetCostLatestStage(cost.Id, User); var latestRevision = await GetCostLatestRevision(cost.Id, latestStage.Id, User); var mediaTypeId = await GetMediaTypeId(); CreateMediaTypeMappingIfNotCreated(mediaTypeId); var model = new CreateExpectedAssetModel { Title = "Title1", AdId = "DAGWJHOERO534", AiringRegions = new[] { "EMEA" }, Duration = TimeSpan.FromHours(1).ToString(), Definition = "HD", MediaTypeId = mediaTypeId, OvalTypeId = await GetOvalTypeId(), FirstAirDate = DateTime.UtcNow.AddDays(5), AssetId = "ADGADG", Scrapped = false }; var url = ExpectedAssetsUrl(cost.Id, latestStage.Id, latestRevision.Id); var expectedAsset = Deserialize <ExpectedAsset>(await Browser.Post(url, with => { with.User(User); with.JsonBody(model); }), HttpStatusCode.Created); var updateModel = new UpdateExpectedAssetModel { Title = "Title2", AdId = "DAGWJHOERO534", AiringRegions = new[] { "AFRICA" }, Duration = TimeSpan.FromHours(2).ToString(), Definition = "SD", MediaTypeId = await GetMediaTypeId(), OvalTypeId = await GetOvalTypeId(), FirstAirDate = DateTime.UtcNow.AddDays(10), AssetId = "blah", Scrapped = true }; url += "/" + expectedAsset.Id; var updateResponse = Deserialize <ServiceResult>(await Browser.Put(url, with => { with.User(User); with.JsonBody(updateModel); }), HttpStatusCode.OK); updateResponse.Success.Should().BeTrue(); expectedAsset = Deserialize <ExpectedAsset>(await Browser.Get(url, with => with.User(User)), HttpStatusCode.OK); expectedAsset.Title.Should().Be(updateModel.Title); expectedAsset.ProjectAdIdId.Should().NotBeEmpty(); expectedAsset.AiringRegions.Should().BeEquivalentTo(updateModel.AiringRegions); expectedAsset.Duration.ToString().Should().Be(updateModel.Duration); expectedAsset.Definition.Should().Be(updateModel.Definition); expectedAsset.MediaTypeId.Should().Be(updateModel.MediaTypeId); expectedAsset.OvalTypeId.Should().Be(updateModel.OvalTypeId); //expectedAsset.FirstAirDate.Should().Be(updateModel.FirstAirDate); expectedAsset.AssetId.Should().Be(updateModel.AssetId); expectedAsset.Scrapped.Should().Be(updateModel.Scrapped); expectedAsset.Modified.Should().BeAfter(expectedAsset.Created); }
protected async Task CreateExpectedAsset(Guid costId, Guid stageId, Guid revisionId, CreateExpectedAssetModel model) { var url = ExpectedAssetsUrl(costId, stageId, revisionId); await Browser.Post(url, with => { with.User(User); with.JsonBody(model); }); }