public async void PullAvroBinaryMessagesAsync() { string randomName = _pubsubFixture.RandomName(); string topicId = $"testTopicForAvroBinaryMessageAck{randomName}"; string subscriptionId = $"testSubscriptionForAvroBinaryMessageAck{randomName}"; string schemaId = $"testSchemaForAvroMessageBinaryAck{randomName}"; var schema = _pubsubFixture.CreateAvroSchema(schemaId); _pubsubFixture.CreateTopicWithSchema(topicId, schema.Name.ToString(), Encoding.Binary); _pubsubFixture.CreateSubscription(topicId, subscriptionId); await _publishAvroMessagesAsyncSample.PublishAvroMessagesAsync(_pubsubFixture.ProjectId, topicId, new AvroUtilities.State[] { new AvroUtilities.State { name = "New York", post_abbr = "NY" } }); // Pull and acknowledge the messages var result = await _pullAvroMessagesAsyncSample.PullAvroMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, true); Assert.Equal(1, result); //Pull the Message to confirm it's gone after it's acknowledged result = await _pullAvroMessagesAsyncSample.PullAvroMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, true); Assert.True(result == 0); }
public async void PublishBinaryMessages() { string randomName = _pubsubFixture.RandomName(); string topicId = $"testTopicAvroBinaryMessageCreation{randomName}"; string subscriptionId = $"testSubscriptionAvroBinaryMessageCreation{randomName}"; string schemaId = $"testSchemaAvroBinaryMessageCreation{randomName}"; var schema = _pubsubFixture.CreateAvroSchema(schemaId); _pubsubFixture.CreateTopicWithSchema(topicId, schema.Name.ToString(), Encoding.Binary); _pubsubFixture.CreateSubscription(topicId, subscriptionId); List <AvroUtilities.State> messageTexts = new List <AvroUtilities.State> { new AvroUtilities.State { name = "New York", post_abbr = "NY" }, new AvroUtilities.State { name = "Pennsylvania", post_abbr = "PA" } }; var output = await _publishAvroMessagesAsyncSample.PublishAvroMessagesAsync(_pubsubFixture.ProjectId, topicId, messageTexts); Assert.Equal(messageTexts.Count, output); // Pull the Message to confirm it is valid await _pubsubFixture.Pull.Eventually(async() => { var result = await _pullMessagesAsyncSample.PullMessagesAsync(_pubsubFixture.ProjectId, subscriptionId, false); Assert.True(result > 0); }); }
public void DeleteSchema() { string schemaId = "testSchemaForDeleteSchema" + _pubsubFixture.RandomName(); _pubsubFixture.CreateAvroSchema(schemaId); _deleteSchemaSample.DeleteSchema(_pubsubFixture.ProjectId, schemaId); Exception ex = Assert.Throws <Grpc.Core.RpcException>(() => _pubsubFixture.GetSchema(schemaId)); _pubsubFixture.TempSchemaIds.Remove(schemaId); // We already deleted it. }
public void GetSchema() { string schemaId = "testSchemaForGetSchema" + _pubsubFixture.RandomName(); _pubsubFixture.CreateAvroSchema(schemaId); _pubsubFixture.GetSchema(schemaId); var receivedSchema = _getSchemaSample.GetSchema(_pubsubFixture.ProjectId, schemaId); var schema = _pubsubFixture.GetSchema(schemaId); Assert.Equal(receivedSchema, schema); }
public void CreateTopicWithSchema() { string schemaId = "testSchemaForTopicCreationWithSchema" + _pubsubFixture.RandomName(); var schema = _pubsubFixture.CreateAvroSchema(schemaId); string topicId = "testTopicForTopicCreationWithSchema" + _pubsubFixture.RandomName(); var newlyCreatedTopic = _createTopicWithSchemaSample.CreateTopicWithSchema(_pubsubFixture.ProjectId, topicId, schema.Name, Encoding.Json); _pubsubFixture.TempTopicIds.Add(topicId); var topic = _pubsubFixture.GetTopic(topicId); Assert.Equal(newlyCreatedTopic, topic); }