private void ReceiveMarkerInfo(MarkerMessage message) { if (message.IsSuccess && message.MarkerInfo != null) { using (var markerOption = new MarkerOptions()) { bool inArray = _markers.Any(x => x.Latitude == message.MarkerInfo.Latitude && x.Longtitude == message.MarkerInfo.Longtitude); if (!inArray) { MarkerInfo markerInfo = message.MarkerInfo; markerOption.SetPosition(new LatLng(markerInfo.Latitude, markerInfo.Longtitude)); markerOption.SetTitle(markerInfo.Title); markerOption.SetSnippet(markerInfo.Address); // save the "marker" variable returned if you need move, delete, update it, etc... Marker marker = _googleMap.AddMarker(markerOption); _markers.Add(markerInfo); } else { MarkerInfo markerToRemove = _markers.First( x => x.Latitude == message.MarkerInfo.Latitude && x.Longtitude == message.MarkerInfo.Longtitude); _markers.Remove(markerToRemove); _markers.Add(message.MarkerInfo); } string json = JsonConvert.SerializeObject(_markers, Formatting.Indented); FileHelper.WriteFile(_filenameGenerator, _defaultFilename, json); } } }
public void MarkerMessage_writes_correctly_to_file() { var message = new MarkerMessage("marker"); message.Write(writer); var expectedOutput = new byte[] { 0xff, 0x06, 0x06, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x72 }; stream.ToArray().Should().Equal(expectedOutput); }
public async Task RespondsToEnqueuedItem() { var marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; string json = JsonConvert.SerializeObject(marker); CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient(); CloudQueue queue = queueClient.GetQueueReference("testqueue"); await queue.AddMessageAsync(new CloudQueueMessage(json)); await marker.Assert(); }
public async Task OutputToTableBinding() { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; string json = JsonConvert.SerializeObject(marker); byte[] body = Encoding.UTF8.GetBytes(json); IQueueClient queueClient = new QueueClient(Settings.ServiceBusConnectionString, "tableoutput"); await queueClient.SendAsync(new Message(body)); await marker.Assert(); }
public async Task RespondToEnqueuedItemWithSessionId() { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; string json = JsonConvert.SerializeObject(marker); byte[] body = Encoding.UTF8.GetBytes(json); IQueueClient queueClient = new QueueClient(Settings.ServiceBusConnectionString, "sessionidtestqueue"); await queueClient.SendAsync(new Message(body) { SessionId = Guid.NewGuid().ToString() }); await marker.Assert(); }
public async Task WriteToStorageQueueWhenResponseIsCollection() { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; HttpResponseMessage response = await Settings.Host .AppendPathSegment("outputBindings") .AppendPathSegment("collectionToStorageQueue") .SetQueryParam("markerId", marker.MarkerId) .GetAsync(); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); await marker.Assert(); }
public async Task RespondToEnqueuedItem() { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; string json = JsonConvert.SerializeObject(marker); byte[] body = Encoding.UTF8.GetBytes(json); ITopicClient topicClient = new TopicClient(Settings.ServiceBusConnectionString, "testtopic"); await topicClient.SendAsync(new Message(body)); await marker.Assert(); }
public async Task WriteToServiceBusTopicWhenResponseIsSingular() { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; HttpResponseMessage response = await Settings.Host .AppendPathSegment("outputBindings") .AppendPathSegment("toServiceBusTopic") .SetQueryParam("markerId", marker.MarkerId) .GetAsync(); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); await marker.Assert(); }
public async Task RespondToUploadedBlob() { var marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; string json = JsonConvert.SerializeObject(marker); CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("streamblobcommands"); CloudBlockBlob blob = container.GetBlockBlobReference($"{marker.MarkerId}.json"); await blob.UploadTextAsync(json); await marker.Assert(); }
public async Task OutputToTableBinding() { var marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; string json = JsonConvert.SerializeObject(marker); CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("outputbindingcontainer"); CloudBlockBlob blob = container.GetBlockBlobReference($"{marker.MarkerId}.json"); await blob.UploadTextAsync(json); await marker.Assert(); }
public async Task WriteToServiceBusQueueWhenResponseIsSingularAndOutputConverterRuns() { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; HttpResponseMessage response = await Settings.Host .AppendPathSegment("outputBindings") .AppendPathSegment("toServiceBusQueueWithConverter") .SetQueryParam("markerId", marker.MarkerId) .SetQueryParam("value", 42) .GetAsync(); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); marker.Value++; // the converter adds 1 to the value await marker.Assert(); }
public async Task RespondToEnqueuedItem() { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; string json = JsonConvert.SerializeObject(marker); EventHubsConnectionStringBuilder connectionStringBuilder = new EventHubsConnectionStringBuilder(Settings.EventHubConnectionString) { EntityPath = "maintesthub" }; EventHubClient client = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString()); await client.SendAsync(new EventData(Encoding.UTF8.GetBytes(json))); await marker.Assert(); }
public async Task OutputToTableBinding() { string cosmosConnectionString = Settings.CosmosConnectionString; string[] cosmosConnectionStringParts = cosmosConnectionString.Split(';'); string cosmosEndpoint = cosmosConnectionStringParts[0].Substring("AccountEndpoint=".Length); string cosmosAuthKey = cosmosConnectionStringParts[1].Substring("AccountKey=".Length).TrimEnd(';'); using (DocumentClient documentClient = new DocumentClient(new Uri(cosmosEndpoint), cosmosAuthKey)) { MarkerMessage marker = new MarkerMessage { MarkerId = Guid.NewGuid() }; await documentClient.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("testdatabase", "outputtablecollection"), marker); await marker.Assert(); } }
private void ApplyButton_Click(object sender, EventArgs e) { var markerInfo = new MarkerInfo { Address = _addressText.Text, Latitude = double.Parse(_latitudeText.Text), Longtitude = double.Parse(_longtitudeText.Text), Title = _titleEditText.Text, Snippet = _snippetEditText.Text, LastModData = DateTime.Now }; var markerMessage = new MarkerMessage { IsSuccess = true, MarkerInfo = markerInfo }; Messenger.Default.Send(markerMessage); _navigationService.GoBack(); }
public Task Handle(MarkerMessage message, IMessageHandlerContext context) { scenarioContext.MarkerMessageReceived = true; return(Task.CompletedTask); }