public void TestContentKeyAuthorizationPolicyOptionCreateFailedRetryMessageLengthLimitExceeded() { var expected = new ContentKeyAuthorizationPolicyOptionData { Name = "testData" }; var fakeException = new WebException("test", WebExceptionStatus.MessageLengthLimitExceeded); var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 10, expected); dataContextMock.Setup((ctxt) => ctxt.AddObject("ContentKeyAuthorizationPolicyOptions", It.IsAny <object>())); _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object); try { IContentKeyAuthorizationPolicyOption actual = _mediaContext.ContentKeyAuthorizationPolicyOptions.Create("Empty", ContentKeyDeliveryType.None, null, null); } catch (WebException x) { dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(It.IsAny <object>()), Times.Exactly(1)); Assert.AreEqual(fakeException, x); throw; } Assert.Fail("Expected exception"); }
public void TestContentKeyAuthorizationPolicyOptionCreateRetry() { var expected = new ContentKeyAuthorizationPolicyOptionData { Name = "testData" }; var fakeException = new WebException("test", WebExceptionStatus.ConnectionClosed); var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 2, expected); dataContextMock.Setup((ctxt) => ctxt.AddObject("ContentKeyAuthorizationPolicyOptions", It.IsAny <object>())); _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object); IContentKeyAuthorizationPolicyOption actual = _mediaContext.ContentKeyAuthorizationPolicyOptions.Create("Empty", ContentKeyDeliveryType.None, null, null); Assert.AreEqual(expected.Name, actual.Name); dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(It.IsAny <object>()), Times.Exactly(2)); }
public void TestContentKeyAuthorizationPolicyOptionUpdateRetry() { var data = new ContentKeyAuthorizationPolicyOptionData { Name = "testData" }; var fakeException = new WebException("test", WebExceptionStatus.ConnectionClosed); var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 2, data); dataContextMock.Setup((ctxt) => ctxt.AttachTo("ContentKeyAuthorizationPolicyOptions", data)); dataContextMock.Setup((ctxt) => ctxt.UpdateObject(data)); _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object); data.SetMediaContext(_mediaContext); data.Update(); dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(data), Times.Exactly(2)); }
public void TestContentKeyAuthorizationPolicyOptionCreateRetry() { var expected = new ContentKeyAuthorizationPolicyOptionData { Name = "testData" }; var fakeException = new WebException("test", WebExceptionStatus.ConnectionClosed); var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 2, expected); dataContextMock.Setup((ctxt) => ctxt.AddObject("ContentKeyAuthorizationPolicyOptions", It.IsAny<object>())); _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object); IContentKeyAuthorizationPolicyOption actual = _mediaContext.ContentKeyAuthorizationPolicyOptions.Create("Empty", ContentKeyDeliveryType.None, null, null); Assert.AreEqual(expected.Name, actual.Name); dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(It.IsAny<object>()), Times.Exactly(2)); }
public void TestContentKeyAuthorizationPolicyOptionCreateFailedRetryMessageLengthLimitExceeded() { var expected = new ContentKeyAuthorizationPolicyOptionData { Name = "testData" }; var fakeException = new WebException("test", WebExceptionStatus.MessageLengthLimitExceeded); var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 10, expected); dataContextMock.Setup((ctxt) => ctxt.AddObject("ContentKeyAuthorizationPolicyOptions", It.IsAny<object>())); _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object); try { IContentKeyAuthorizationPolicyOption actual = _mediaContext.ContentKeyAuthorizationPolicyOptions.Create("Empty", ContentKeyDeliveryType.None, null, null); } catch (WebException x) { dataContextMock.Verify((ctxt) => ctxt.SaveChangesAsync(It.IsAny<object>()), Times.Exactly(1)); Assert.AreEqual(fakeException, x); throw; } Assert.Fail("Expected exception"); }