private async Task EnsureBlobExistsAsync() { if (await m_blob.ExistsAsync()) { return; } try { await m_blob.UploadFromByteArrayAsync( EmptyArray.Get <byte>(), 0, 0, AccessCondition.GenerateIfNoneMatchCondition("*"), null, null); } catch (StorageException exception) { // 412 from trying to modify a blob that's leased var blobLeased = exception.RequestInformation.HttpStatusCode == (int)HttpStatusCode.PreconditionFailed; var blobExists = exception.RequestInformation.HttpStatusCode == (int)HttpStatusCode.Conflict && exception.RequestInformation.ExtendedErrorInformation.ErrorCode == BlobErrorCodeStrings.BlobAlreadyExists; if (!blobExists && !blobLeased) { throw; } } }
public async Task IsExistsAsync_WhenBlobDeletedCreated_ReturnsFalse() { await Blob.UploadAsync(new MemoryStream(EmptyArray.Get <byte>())); await Blob.DeleteAsync(); Assert.False(await Blob.IsExistsAsync()); }
public static ICloudTableEntityQuery PrepareEntityPointQuery( this ICloudTable table, string partitionKey) { Require.NotNull(table, "table"); return(table.PrepareEntityPointQuery(partitionKey, EmptyArray.Get <string>())); }
public List <Dictionary <string, object> > Execute() { var result = new List <Dictionary <string, object> >(); do { result.AddRange(FetchEntities(m_filter, EmptyArray.Get <byte>())); }while (ReadNextSegment); return(result); }
public async Task CreateBlockBlob_WithDirectoryPathTest() { var blob = Container.CreateBlockBlob( Guid.NewGuid().ToString("D") + "/" + Guid.NewGuid().ToString("D")); await blob.UploadAsync(new MemoryStream(EmptyArray.Get <byte>())); Assert.True(await blob.IsExistsAsync()); }
public static ICloudTableEntityRangeQuery PrepareEntityRangeQueryByRows( this ICloudTable table, string partitionKey, string fromRowKey, string toRowKey) { return(table.PrepareEntityRangeQueryByRows( partitionKey, fromRowKey, toRowKey, EmptyArray.Get <string>())); }
public NotificationHubDataAttribute( bool emptyChannel = false, bool hasSubscriber = true, bool startHub = true) { Fixture.Customize <INotification>(composer => composer .FromFactory((EventStreamUpdated notification) => notification)); Fixture.Customize <IReceivedNotification[]>(composer => composer .FromFactory((IReceivedNotification n) => n.YieldArray())); Fixture.Customize <Mock <IReceivedNotificationProcessor> >(composer => composer .Do(mock => mock .Setup(self => self.ProcessingCount) .Returns(0))); Fixture.Customize <Mock <INotificationsChannel> >(composer => composer .Do(mock => mock .Setup(self => self.ReceiveNotificationsAsync()) .Returns(() => emptyChannel ? EmptyArray.Get <IReceivedNotification>().YieldTask() : Fixture.Create <IReceivedNotification[]>().YieldTask())) .Do(mock => mock .Setup(self => self.SendAsync(It.IsAny <INotification>())) .Returns(TaskDone.Done))); Fixture.Customize <IPollingJob>(composer => composer.FromFactory((PollingJobStub stub) => stub)); Fixture.Customize <Mock <INotificationFormatter> >(composer => composer .Do(mock => mock .Setup(self => self.FromBytes(It.IsAny <Stream>())) .Returns(() => Fixture.Create <EventStreamUpdated>())) .Do(mock => mock .Setup(self => self.ToBytes(It.IsAny <EventStreamUpdated>())) .ReturnsUsingFixture(Fixture))); Fixture.Customize <NotificationHub>(composer => composer .Do(hub => { if (hasSubscriber) { hub.Subscribe(Fixture.Create <INotificationListener>()); } if (startHub) { hub.StartNotificationProcessing(Fixture.Create <IEventStoreConnection>()); } })); }
protected byte[] GetContinuationTokenBytes() { if (m_continuationToken == null) { return(EmptyArray.Get <byte>()); } return(Encoding.UTF8.GetBytes( "{0} {1} {2} {3}".FormatString( m_continuationToken.NextPartitionKey ?? string.Empty, m_continuationToken.NextRowKey ?? string.Empty, m_continuationToken.NextTableName ?? string.Empty, m_continuationToken.TargetLocation))); }
private async Task <IReceivedNotification[]> ReceiveNotificationsAsync() { var notifications = EmptyArray.Get <IReceivedNotification>(); if (RequestNotificationsRequired()) { notifications = await m_channel.ReceiveNotificationsAsync(); s_logger.Debug( "Receive {NotificationCount} notifications {NotificationIds}.", notifications.Length, notifications.Select(n => n.Notification.NotificationId)); } return(notifications); }
public Dictionary <string, object> Execute() { var entities = FetchEntities( PrepareFilter(), EmptyArray.Get <byte>()); if (entities.Count == 0) { return(null); } if (entities.Count > 1) { throw new InvalidOperationException("Single entity query returns to much rows."); } return(entities[0]); }
public async Task UpdateMessage_UpdatesVisibility() { // arrange await Queue.AddMessageAsync(EmptyArray.Get <byte>()); var message = await Queue.GetMessageAsync(); // act await Queue.UpdateMessageAsync( message.MessageId, message.PopReceipt, TimeSpan.FromSeconds(5)); var updatedMessage = await Queue.GetMessageAsync(); // assert Assert.Null(updatedMessage); }
public async Task <IReceivedNotification[]> ReceiveNotificationsAsync() { var readedQueue = 0; do { var queue = ChooseIncomingQueue(); var result = await ReadNotificationsFromQueueAsync(queue); if (result.Any()) { return(result.ToArray()); } readedQueue++; }while (readedQueue < m_queueCount); return(EmptyArray.Get <IReceivedNotification>()); }
public Developer( int userId, string firstName, string lastName, string email, ConfirmationStatus confirmationStatus, Uri photoUri, DateTime registrationDate, Uri vkProfileUri, string phoneNumber, int?studentAccessionYear, string studyingDirection, string instituteName, string specialization, string role, DeveloperPageProjectPreview[] projects) { Require.Positive(userId, nameof(userId)); Require.NotEmpty(firstName, nameof(firstName)); Require.NotEmpty(lastName, nameof(lastName)); Require.NotEmpty(email, nameof(email)); UserId = userId; FirstName = firstName; LastName = lastName; Email = email; ConfirmationStatus = confirmationStatus; PhotoUri = photoUri; RegistrationDate = registrationDate; VkProfileUri = vkProfileUri; PhoneNumber = phoneNumber; StudentAccessionYear = studentAccessionYear; StudyingDirection = studyingDirection; InstituteName = instituteName; Specialization = specialization; Role = role; Projects = projects ?? EmptyArray.Get <DeveloperPageProjectPreview>(); }
public ReceivedNotificationProcessor() { m_handlers = EmptyArray.Get <INotificationHandler>(); }
public DistributionPolicy GetUserSpecifiedPolicy(params int[] userIds) { return(new DistributionPolicy(userIds ?? EmptyArray.Get <int>())); }
public static ICloudTableEntityRangeQuery PrepareEntityGetAllQuery(this ICloudTable table) { Require.NotNull(table, "table"); return(table.PrepareEntityGetAllQuery(EmptyArray.Get <string>())); }
public static ICloudTableEntitySegmentedRangeQuery PrepareEntityFilterSegmentedRangeQuery(this ICloudTable table, string filter, int count) { Require.NotNull(table, "table"); return(table.PrepareEntityFilterSegmentedRangeQuery(filter, count, EmptyArray.Get <string>())); }
public Task <List <Dictionary <string, object> > > ExecuteAsync() { return(FetchEntitiesAsync(m_filter, EmptyArray.Get <byte>())); }
public async Task IsLeaseLocked_WhenBlobLeaseWasNotAcquired_ReturnsFalse() { await Blob.UploadAsync(new MemoryStream(EmptyArray.Get <byte>())); Assert.False(await Blob.IsLeaseLocked()); }
public void Get_ReturnsSameInstance() { Assert.Same(EmptyArray.Get <int>(), EmptyArray.Get <int>()); }
public NotDisposableEmptyMemoryStream() : base(EmptyArray.Get <byte>(), false) { }
public List <Dictionary <string, object> > Execute() { return(FetchEntities(m_filter, EmptyArray.Get <byte>())); }
public async Task IsExistsAsync_WhenBlobCreated_ReturnsTrue() { await Blob.UploadAsync(new MemoryStream(EmptyArray.Get <byte>())); Assert.True(await Blob.IsExistsAsync()); }
public static ICloudTableEntityRangeQuery PrepareEntityFilterRangeQuery(this ICloudTable table, string filter) { Require.NotNull(table, "table"); return(table.PrepareEntityFilterRangeQuery(filter, EmptyArray.Get <string>())); }
public static ICloudTableEntityRangeQuery PrepareEntityRangeQueryByPartition( this ICloudTable table, string partitionKey) { return(table.PrepareEntityRangeQueryByPartition(partitionKey, EmptyArray.Get <string>())); }
public void IsEmpty_WhenCollectionIsEmpty_ReturnsTrue() { Assert.True(EmptyArray.Get <int>().IsEmpty()); }