public async void MediaServicesOperationsCreateJobTest() { // Arrange // TODO var amsV3TransformService = Mock.Of <IMediaServicesV3TransformService>(); // Arrange Mocks Mock.Get(AmsV3SdkWrapper) .Setup(x => x.JobCreateAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Job>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new Job()); // Act var amsV3Services = new MediaServicesV3EncodeService(amsV3TransformService, AmsV3SdkWrapper, Log); // Assert var exception = await Record.ExceptionAsync(async() => await amsV3Services.CreateJobAsync("mytransform", "myinputassetname", "myoutputassetname", "myjobname", null, It.IsAny <Dictionary <string, string> >(), DefaultOperationContext).ConfigureAwait(false)).ConfigureAwait(false); Assert.Null(exception); // no exception if string are not null // exception is string are null await Assert.ThrowsAsync <ArgumentNullException>(async() => await amsV3Services.CreateJobAsync(null, null, null, null, null, It.IsAny <Dictionary <string, string> >(), DefaultOperationContext).ConfigureAwait(false)).ConfigureAwait(false); // exception is string are empty await Assert.ThrowsAsync <ArgumentException>(async() => await amsV3Services.CreateJobAsync(string.Empty, string.Empty, string.Empty, string.Empty, null, It.IsAny <Dictionary <string, string> >(), DefaultOperationContext).ConfigureAwait(false)).ConfigureAwait(false); }
public async void MediaServicesV3ServiceCreateTransformThrowsExceptionWhenTransformNotInDictionaryTest() { // Arrange var storage = new MediaService(storageAccounts: new List <StorageAccount>() { new StorageAccount() { Id = DefaultStorageId } }); var tOutputs = new List <TransformOutput>(); string tNameNotExisting = "transformwhichdoesnotexist"; var amsV3TransformService = Mock.Of <IMediaServicesV3TransformService>(); Transform nullTransform = null; MediaServicesV3TransformBase nullAmsV3Transform = null; // Arrange Mocks Mock.Get(AmsV3SdkWrapper) .Setup(x => x.TransformGetAsync(tNameNotExisting, It.IsAny <CancellationToken>())) .ReturnsAsync(nullTransform); Mock.Get(amsV3TransformService) .Setup(x => x.GetTransform(tNameNotExisting)) .Returns(nullAmsV3Transform); // Act var amsV3Services = new MediaServicesV3EncodeService(amsV3TransformService, AmsV3SdkWrapper, Log); // Assert var exception = await Record.ExceptionAsync(async() => await amsV3Services.CreateTransformIfNotExistByNameAsync(tNameNotExisting, DefaultOperationContext).ConfigureAwait(false)).ConfigureAwait(false); Xunit.Assert.NotNull(exception); Mock.Get(AmsV3SdkWrapper).Verify(x => x.TransformCreateOrUpdateAsync(tNameNotExisting, It.IsAny <TransformOutput[]>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never); }
public async void MediaServicesV3ServiceCreateAssetTest(string jData, bool expectedValue) { // Arrange RequestEncodeCreateDTO encodeRequestData = JsonConvert.DeserializeObject <RequestEncodeCreateDTO>(jData); string assetName = "myassetname"; var amsAccount = new MediaService(storageAccounts: new List <StorageAccount>() { new StorageAccount() { Id = DefaultStorageId } }); // TODO var amsV3TransformService = Mock.Of <IMediaServicesV3TransformService>(); // Arrange Mocks Mock.Get(AmsV3SdkWrapper) .Setup(x => x.AssetCreateOrUpdateAsync(It.IsAny <string>(), It.IsAny <Asset>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new Asset(name: assetName)); Mock.Get(AmsV3SdkWrapper) .Setup(x => x.MediaservicesGetAsync(It.IsAny <CancellationToken>())) .ReturnsAsync(amsAccount); // Act var inputUrls = encodeRequestData.Inputs.ToList().Select(i => new Uri(i.BlobUri)).ToList(); var amsV3Services = new MediaServicesV3EncodeService(amsV3TransformService, AmsV3SdkWrapper, Log); // Assert if (expectedValue == false) { _ = await Xunit.Assert.ThrowsAsync <Exception>(async() => await amsV3Services.CreateOrUpdateAssetForContainerAsync(inputUrls).ConfigureAwait(false)).ConfigureAwait(false); } else { var result = await amsV3Services.CreateOrUpdateAssetForContainerAsync(inputUrls).ConfigureAwait(false); result.ShouldBeOfType <string>(); result.ShouldBe(assetName); } }