private async Task ServiceBusMessagePump_PublishServiceBusMessage_MessageSuccessfullyProcessed(Encoding messageEncoding, string connectionStringKey) { // Arrange var operationId = Guid.NewGuid().ToString(); var transactionId = Guid.NewGuid().ToString(); var connectionString = Configuration.GetValue <string>(connectionStringKey); ServiceBusConnectionStringProperties serviceBusConnectionString = ServiceBusConnectionStringProperties.Parse(connectionString); await using (var client = new ServiceBusClient(connectionString)) await using (ServiceBusSender messageSender = client.CreateSender(serviceBusConnectionString.EntityPath)) { var order = OrderGenerator.Generate(); var orderMessage = order.AsServiceBusMessage(operationId, transactionId, encoding: messageEncoding); // Act await messageSender.SendMessageAsync(orderMessage); // Assert var receivedEvent = _serviceBusEventConsumerHost.GetReceivedEvent(operationId); Assert.NotEmpty(receivedEvent); var deserializedEventGridMessage = EventParser.Parse(receivedEvent); Assert.NotNull(deserializedEventGridMessage); var orderCreatedEvent = Assert.Single(deserializedEventGridMessage.Events); Assert.NotNull(orderCreatedEvent); var orderCreatedEventData = orderCreatedEvent.GetPayload <OrderCreatedEventData>(); Assert.NotNull(orderCreatedEventData); Assert.NotNull(orderCreatedEventData.CorrelationInfo); Assert.Equal(order.Id, orderCreatedEventData.Id); Assert.Equal(order.Amount, orderCreatedEventData.Amount); Assert.Equal(order.ArticleNumber, orderCreatedEventData.ArticleNumber); Assert.Equal(transactionId, orderCreatedEventData.CorrelationInfo.TransactionId); Assert.Equal(operationId, orderCreatedEventData.CorrelationInfo.OperationId); Assert.NotEmpty(orderCreatedEventData.CorrelationInfo.CycleId); } }
private void TestParseAllEvents() { //Arrange Script tester = new Script(); foreach (string file in Directory.EnumerateFiles("events", "*.txt")) { string contents = File.ReadAllText(file); //Act EventTabModel model = EventParser.CreateEventFromScript(file, contents); EventContainer container = new EventContainer(model); List <EventContainer> list = new List <EventContainer> { container }; Dictionary <string, string> files = EventParser.ParseAllEvents(list); string filecontent = files.FirstOrDefault().Value; string fileName = files.FirstOrDefault().Key; //Assert Assert.IsNotNull(model); Assert.IsTrue(model.EventList.Any()); Assert.IsNotNull(fileName); Assert.IsNotNull(filecontent); tester.Analyse(filecontent); Assert.IsFalse(tester.Logger.hasErrors()); } }
private void ParseTypes() { var pi = 0; for (int i = 0; i < _solution.Projects.Count; i++) { pi = i; var types = _solution.Projects[i].Compilation.MainAssembly.TopLevelTypeDefinitions.ToList(); for (int j = 0; j < types.Count; j++) { if (types[j].Kind != TypeKind.Delegate) { PostProgress(_sdBuildStrings.ParsingClass + ": " + string.Format("{0}.{1}", types[j].Namespace, types[j].Name), j, types.Count, pi, _solution.Projects.Count); var sdType = CreateSDType(types[j]); EventParser.ParseMinimalFields(sdType, types[j]); PropertyParser.ParseMinimalProperties(sdType, types[j]); FieldParser.ParseMinimalFields(sdType, types[j]); MethodParser.ParseMinimalConstructors(sdType, types[j]); MethodParser.ParseMinimalMethods(sdType, types[j]); _repository.AddNamespaceTypeRelation(types[j].Namespace, sdType.Identifier); } } } }
public async void CheckForChanges() { DataContract.FileInfo info = FileInfo; //check the fileinfo data if (info == null) { return; } //If the file exists if (!File.Exists(info.Filename)) { return; } //If the file was modified after the last modification date if (File.GetLastWriteTime(info.Filename) <= info.LastModifiedDate) { return; } //Then we can show a message MessageDialogResult Result = await(new ViewModelLocator()) .Main.ShowFileChangedDialog(); if (Result == MessageDialogResult.Affirmative) { string oldText = EventParser.ParseEventForCompare(this); string newText = EventParser.ParseEventScriptForCompare(info.Filename); SideBySideDiffModel model = new SideBySideDiffBuilder( new Differ()).BuildDiffModel(oldText, newText); new ViewModelLocator().CodeComparator.DiffModel = model; new CompareCode().ShowDialog(); } }
public void SetConnection(MenuItem item, bool raiseConnectionChangeEvent) { if (item.Tag == null || item.Tag.ToString() == Connections.Instance.DefaultConnectionName) { Connections.Instance.DatabaseModel = Connections.Instance.DefaultDatabaseModel; EventParser.ParseMessage(Connections.Instance.DatabaseModel, "DatabaseConnection", Connections.Instance.DefaultConnectionName); this.IsDefaultConnection = true; if (raiseConnectionChangeEvent) { Connections.Instance.ConnectionChanged?.Invoke(Connections.Instance, Connections.Instance.DatabaseModel); } return; } Connections.Instance.DatabaseModel = Connections.Instance.AlternativeModels[item.Tag.ToString()]; EventParser.ParseMessage(Connections.Instance.DatabaseModel, "DatabaseConnection", item.Tag.ToString()); this.IsDefaultConnection = false; if (raiseConnectionChangeEvent) { Connections.Instance.ConnectionChanged?.Invoke(Connections.Instance, Connections.Instance.DatabaseModel); } }
private EventParser GetEventParser(string message, string objectName, KindModelEnum kind, params FileElement[] fileElements) { if (string.IsNullOrEmpty(message)) { throw new ArgumentException("message is empty", nameof(message)); } if (string.IsNullOrEmpty(objectName)) { objectName = string.Empty; } //throw new ArgumentException("objectName is empty", nameof(objectName)); var eventParser = new EventParser() { Message = message, Type = kind.ToString(), OjectName = objectName, ValidatorName = this.GetType().FullName, }; eventParser.Files.AddRange(fileElements); this.Events.Add(eventParser); return(eventParser); }
public async Task DeleveredEventTest() { var json = @" [ { 'email': '*****@*****.**', 'timestamp': 1513299569, 'smtp-id': '<14c5d75ce93.dfd.64b469@ismtpd-555>', 'event': 'delivered', 'category': 'cat facts', 'sg_event_id': 'sg_event_id', 'sg_message_id': 'sg_message_id', 'response': '200 OK' } ] "; IEnumerable <Event> events = await EventParser.ParseAsync(json); events.Count().ShouldBe(1); var defferedEvent = (DeliveredEvent)events.Single(); defferedEvent.Email.ShouldBe("*****@*****.**"); defferedEvent.Timestamp.ShouldBe(DateTime.UnixEpoch.AddSeconds(1513299569)); defferedEvent.SmtpId.ShouldBe("<14c5d75ce93.dfd.64b469@ismtpd-555>"); defferedEvent.EventType.ShouldBe(EventType.Delivered); defferedEvent.Category.Value[0].ShouldBe("cat facts"); defferedEvent.SendGridEventId.ShouldBe("sg_event_id"); defferedEvent.SendGridMessageId.ShouldBe("sg_message_id"); defferedEvent.Response.ShouldBe("200 OK"); }
private void ViewCSharpScript_Cliked(object sender, RoutedEventArgs e) { try { ErdCanvasModel canvas = EventParser.ParseQuery(this, new ParseQueryEventArguments { Title = "TableObjectCanvasQuery", Arguments = new object[] { this.Table.TableName } }).To <ErdCanvasModel>(); SampleScript scriptor = new SampleScript(); foreach (OptionSetupModel option in BuildScript.Setup.BuildOptions.Where(o => o.RepeatOption == RepeatOptionEnum.ForeachTableProject)) { scriptor.LanguageOption = option.LanguageOption; string fileName = option.OutputFileName.Replace("[[TableName]]", this.Table.TableName); string filePath = Path.Combine(Path.GetTempPath(), $"{fileName}.txt"); List <ErdCanvasModel> allErdCancases = EventParser.ParseQuery(this, "GetAllErdCanvasesAsList").To <List <ErdCanvasModel> >(); string result = scriptor.BuildSampleForeachTableScript(canvas, allErdCancases, this.Table, option); File.WriteAllText(filePath, result); Process.Start(filePath); } } catch (Exception err) { MessageBox.Show(err.Message); } }
private void Initialize() { var resulItems = (EventParser.ParseQuery(this, new ParseQueryEventArguments { Title = "QueryTablesStack" })); bool haveTables = false; foreach (TableMenuItem item in ((List <TableMenuItem>)resulItems).OrderBy(n => n.TableName)) { TableModel table = item.TableModelObject; if (this.excludeCanvasTables.Contains(table.TableName)) { continue; } TreeViewItemTool tool = new TreeViewItemTool { Header = table.TableName, Tag = table, IsCheckBox = true, IsChecked = included.Any(tn => tn.TableName == item.TableName) }; this.uxTables.Items.Add(tool); haveTables = true; } if (!haveTables) { MessageBox.Show("No tables found to select from."); } }
public IEnumerator Profiler_AsyncEventsCapturePerformance() { string testFileName = "testfile.json"; TraceProfiler.BeginCapture(testFileName); var e = new TraceEventProfiler.AsyncEvent("MyAsyncEvent"); e.Begin(); yield return(new WaitForSeconds(0.1f)); e.End(); TraceProfiler.EndCapture(); string filename = Path.Combine(Application.persistentDataPath, testFileName); EventParser parser = new EventParser(filename); List <ProfileEvent> asyncEvents = parser.FindWithName("MyAsyncEvent"); // TODO: Add more tests, but for now make sure that async events work Assert.AreEqual("b", asyncEvents[0].ph); Assert.AreEqual("e", asyncEvents[1].ph); string filePath = Path.Combine(Application.persistentDataPath, testFileName); File.Delete(filePath); }
private void StructureParseTypes(CSharpProject project, SDRepository sdRepository) { var types = project.Compilation.MainAssembly.TopLevelTypeDefinitions.ToList(); for (int j = 0; j < types.Count; j++) { var type = types[j]; if (types[j].Kind != TypeKind.Delegate) { PostParseMessage(_parserStrings.ParsingClass + ": " + string.Format("{0}.{1}", types[j].Namespace, types[j].Name)); var nameSpace = sdRepository.GetNamespaceByIdentifier(type.Namespace); var namespaceRef = nameSpace ?? new SDNamespace(type.Namespace) { IsProjectStranger = true }; var sdType = new SDType(type.GetIdentifier(), type.Name, namespaceRef) { Accessibility = type.GetDefinition().Accessibility.ToString().ToLower() }; sdRepository.AddType(sdType); EventParser.ParseMinimalFields(sdType, types[j]); PropertyParser.ParseMinimalProperties(sdType, types[j]); FieldParser.ParseMinimalFields(sdType, types[j]); MethodParser.ParseMinimalConstructors(sdType, types[j]); MethodParser.ParseMinimalMethods(sdType, types[j]); sdRepository.AddNamespaceTypeRelation(types[j].Namespace, sdType.Identifier); } } }
//TODO: We need a better separation of methods for event pushing. public void Push(string eventString) { eventString = eventString + ";" + Context.ConnectionId; var e = EventParser.Parse(eventString, serviceProvider); Engine.Instance.Push(e); }
private void BuildModelFiles(ErdCanvasModel[] canvases, Dispatcher dispatcher) { string basePath = Path.Combine(EntityModelScript.Setup.ClientModelOutputDirectory, "Base"); string userPath = Path.Combine(EntityModelScript.Setup.ClientModelOutputDirectory, "User"); Paths.CreateDirectory(basePath); Paths.CreateDirectory(userPath); foreach (ErdCanvasModel canvas in canvases) { foreach (TableModel table in canvas.SegmentTables) { dispatcher.Invoke(() => { EventParser.ParseMessage(this, new ParseMessageEventArguments { Message = string.Format("Building Model {0}", table.TableName) }); }); string modelBase = EntityModelScript.ScriptServerModelBase(table); string className = EntityModelScript.GetClassName(table); File.WriteAllText(Path.Combine(basePath, $"{className}_Base.cs"), modelBase); string userFileName = Path.Combine(userPath, $"{className}.cs"); if (!File.Exists(userFileName)) { string model = EntityModelScript.ScriptServerModel(table); File.WriteAllText(userFileName, model); } } } }
/// <summary> /// Loads the tables from the database /// </summary> /// <param name="databaseModel">the DatabaseModel object to exeute the query against</param> /// <returns>returns a List<TableModel> (Columns not loaded)</returns> public List <TableModel> GetTables(Dispatcher dispatcher) { List <TableModel> result = new List <TableModel>(); DataAccess dataAccess = new DataAccess(Connections.DatabaseModel); XDocument tablesXml = dataAccess.ExecuteQuery(SQLQueries.DatabaseQueries.DatabaseTablesQuery(Connections.DatabaseModel.DatabaseName)); foreach (XElement rowItem in tablesXml.Root.Elements()) { string tableName = rowItem.Element("TABLE_NAME").Value; EventParser.ParseMessage(this, dispatcher, "Reading", tableName); if (tableName.ToLower() == "sysdiagrams") { continue; } List <dynamic> clusterList = dataAccess.ExecuteQueryDynamic(SQLQueries.DatabaseQueries.DatabasePrimaryClusterName(tableName)); TableModel model = new TableModel { TableName = tableName }; model.PrimaryKeyClusterConstraintName = clusterList.Count > 0 ? ((IDictionary <string, object>)clusterList[0]).Values.FirstOrDefault().ToString() : tableName; result.Add(model); } return(result); }
public async Task ClickEventTest() { var json = @" [ { 'email': '*****@*****.**', 'timestamp': 1513299569, 'smtp-id': '<14c5d75ce93.dfd.64b469@ismtpd-555>', 'event': 'click', 'category': 'cat facts', 'sg_event_id': 'sg_event_id', 'sg_message_id': 'sg_message_id', 'useragent': 'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)', 'ip': '255.255.255.255', 'url': 'http://www.sendgrid.com/' } ] "; IEnumerable <Event> events = await EventParser.ParseAsync(json); events.Count().ShouldBe(1); var clickEvent = (ClickEvent)events.Single(); clickEvent.Email.ShouldBe("*****@*****.**"); clickEvent.Timestamp.ShouldBe(DateTime.UnixEpoch.AddSeconds(1513299569)); clickEvent.SmtpId.ShouldBe("<14c5d75ce93.dfd.64b469@ismtpd-555>"); clickEvent.EventType.ShouldBe(EventType.Click); clickEvent.Category.Value[0].ShouldBe("cat facts"); clickEvent.SendGridEventId.ShouldBe("sg_event_id"); clickEvent.SendGridMessageId.ShouldBe("sg_message_id"); clickEvent.UserAgent.ShouldBe("Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"); clickEvent.IP.ShouldBe("255.255.255.255"); clickEvent.Url.ToString().ShouldBe("http://www.sendgrid.com/"); }
public IEnumerator ThreadNameEvents_PresentInTheCapture() { var filename = Path.Combine(Application.persistentDataPath, "testfile.json"); TraceProfiler.BeginCapture(filename); yield return(new WaitForSeconds(0.1f)); TraceProfiler.EndCapture(); var parser = new EventParser(filename); var threadEvents = parser.FindWithName("thread_name"); var mainThreadDetected = false; foreach (var e in threadEvents) { Assert.IsNull(e.cat); Assert.AreEqual("thread_name", e.name); Assert.AreEqual("M", e.ph); Assert.IsNotNull(e.args); Assert.IsNotNull(e.args.name); if (e.args.name.Contains("Main Thread")) { mainThreadDetected = true; } } Assert.IsTrue(mainThreadDetected); File.Delete(filename); }
public void GetFieldFromLine_Given_an_invalid_server_sent_event_then_return_default_key_value_pair(string value) { var result = EventParser.GetFieldFromLine(value); Assert.Null(result.Key); Assert.Null(result.Value); }
/// <summary> /// Processing the external event pay load received /// </summary> /// <param name="curExternalEventPayload">event pay load received</param> /// <param name="parser">delegate method</param> public async Task Process(string curExternalEventPayload, EventParser parser) { var client = ObjectFactory.GetInstance <IRestfulServiceClient>(); var fr8EventUrl = CloudConfigurationManager.GetSetting("CoreWebServerUrl") + "api/v1/events"; var eventReportCrateDTO = _crateManager.ToDto(await parser.Invoke(curExternalEventPayload)); if (eventReportCrateDTO != null) { Uri url = new Uri(fr8EventUrl, UriKind.Absolute); try { //TODO are we expecting a timeout?? await client.PostAsync(url, eventReportCrateDTO); } catch (TaskCanceledException) { //Timeout throw new TimeoutException( String.Format("Timeout while making HTTP request. \r\nURL: {0}, \r\nMethod: {1}", url.ToString(), HttpMethod.Post.Method)); } } }
public void Unsubscribe(string eventString) { eventString = eventString + "/" + Context.ConnectionId; var e = EventParser.Parse(eventString, services); Engine.Instance.Push(e); }
public async Task UnsubscribeEventTest() { var json = @" [ { 'email': '*****@*****.**', 'timestamp': 1513299569, 'smtp-id': '<14c5d75ce93.dfd.64b469@ismtpd-555>', 'event': 'unsubscribe', 'category': 'cat facts', 'sg_event_id': 'sg_event_id', 'sg_message_id': 'sg_message_id' } ] "; IEnumerable <Event> events = await EventParser.ParseAsync(json); events.Count().ShouldBe(1); var spamReportEvent = (UnsubscribeEvent)events.Single(); spamReportEvent.Email.ShouldBe("*****@*****.**"); spamReportEvent.Timestamp.ShouldBe(DateTime.UnixEpoch.AddSeconds(1513299569)); spamReportEvent.SmtpId.ShouldBe("<14c5d75ce93.dfd.64b469@ismtpd-555>"); spamReportEvent.EventType.ShouldBe(EventType.Unsubscribe); spamReportEvent.Category.Value[0].ShouldBe("cat facts"); spamReportEvent.SendGridEventId.ShouldBe("sg_event_id"); spamReportEvent.SendGridMessageId.ShouldBe("sg_message_id"); }
public async Task DroppedEventTest() { var json = @" [ { 'email': '*****@*****.**', 'timestamp': 1513299569, 'smtp-id': '<14c5d75ce93.dfd.64b469@ismtpd-555>', 'event': 'dropped', 'category': 'cat facts', 'sg_event_id': 'sg_event_id', 'sg_message_id': 'sg_message_id', 'reason': 'Bounced Address', 'status': '5.0.0' } ] "; IEnumerable <Event> events = await EventParser.ParseAsync(json); events.Count().ShouldBe(1); var droppedEvent = (DroppedEvent)events.Single(); droppedEvent.Email.ShouldBe("*****@*****.**"); droppedEvent.Timestamp.ShouldBe(DateTime.UnixEpoch.AddSeconds(1513299569)); droppedEvent.SmtpId.ShouldBe("<14c5d75ce93.dfd.64b469@ismtpd-555>"); droppedEvent.EventType.ShouldBe(EventType.Dropped); droppedEvent.Category.Value[0].ShouldBe("cat facts"); droppedEvent.SendGridEventId.ShouldBe("sg_event_id"); droppedEvent.SendGridMessageId.ShouldBe("sg_message_id"); droppedEvent.Reason.ShouldBe("Bounced Address"); droppedEvent.Status.ShouldBe("5.0.0"); }
private void RunMappingScriptor(ErdCanvasModel[] canvases, Dispatcher dispatcher) { try { string dispatchNote = "Build Mappings Script for: {0}"; Paths.CreateDirectory(Path.Combine(EntityModelScript.Setup.ServerOutputBaseDirectory, "Mappings")); foreach (ErdCanvasModel canvas in canvases) { foreach (TableModel table in canvas.SegmentTables) { dispatcher.Invoke(() => { EventParser.ParseMessage(this, new ParseMessageEventArguments { Message = string.Format(dispatchNote, table.TableName) }); }); string mapptingPath = Path.Combine(EntityModelScript.Setup.ServerOutputBaseDirectory, "Mappings", $"{EntityModelScript.GetClassName(table)}Mapping.cs"); string mappingResult = EntityModelScript.ScriptServerModelMapping(table); File.WriteAllText(mapptingPath, mappingResult); } } } catch (Exception err) { throw; } }
public async Task AllEvents() { var jsonStream = new MemoryStream(File.ReadAllBytes("TestData/events.json")); IEnumerable <Event> events = await EventParser.ParseAsync(jsonStream); events.Count().ShouldBe(11); }
private void Import_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { InitialDirectory = Directory.GetCurrentDirectory(), Filter = "CSV File (*.csv)|*.csv", ReadOnlyChecked = true }; if (openFileDialog.ShowDialog() != true) { return; } var file = openFileDialog.FileName; List <IShellItem> csvShelltems = CsvIO.ImportCSVFile(file); if (csvShelltems.Count == 0) { LogAggregator.Instance.ShowIfNotEmpty(); return; } if (App.ShellItems != null) { App.ShellItems.Clear(); } if (App.nodeCollection.nodeList != null) { App.nodeCollection.nodeList.Clear(); } App.ShellItems = csvShelltems; List <IEvent> events = EventParser.GetEvents(App.ShellItems); App.nodeCollection.ClearAllFilters(); App.nodeCollection.nodeList.AddRange(NodeParser.GetNodes(events)); if (Home.timelinePage == null) { Home.timelinePage = new TimelinePage(); App.NavigationService.Navigate(Home.timelinePage); } else { Home.timelinePage.RebuildTimeline(); string timelinePageKey = "timelinepage"; if (App.pages.ContainsKey(timelinePageKey)) { App.NavigationService.Navigate(App.pages[timelinePageKey]); } else { App.NavigationService.Navigate(Home.timelinePage); } } LogAggregator.Instance.ShowIfNotEmpty(); }
public void GetFieldFromLine_Given_a_server_sent_event_then_return_field_name_and_value(string key, string value) { string sse = string.Format("{0}: {1}", key, value); var result = EventParser.GetFieldFromLine(sse); Assert.Equal(result.Key, key); Assert.Equal(result.Value, value); }
public void ParseExplicitAsCloudEvent_ValidBlobCreatedEvent_ShouldSucceed() { // Arrange const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg", eventType = "Microsoft.Storage.BlobCreated", id = "5647b67c-b01e-002d-6a47-bc01ac063360", api = "PutBlockList", clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037", requestId = "5647b67c-b01e-002d-6a47-bc01ac000000", eTag = "0x8D58A5F0C6722F9", contentType = "image/jpeg", blobType = "BlockBlob", url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg", sequencer = "00000000000000000000000000000094000000000017d503", batchId = "69cd1576-e430-4aff-8153-570934a1f6e1"; const int contentLength = 29342; var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274"); var source = new Uri("/some/source/not/available/in/event-grid/events", UriKind.Relative); string rawEvent = EventSamples.BlobCreateEvent; var eventGridEventBatch = EventParser.Parse(rawEvent); Assert.NotNull(eventGridEventBatch); Event @event = Assert.Single(eventGridEventBatch.Events); Assert.NotNull(@event); // Act CloudEvent cloudEvent = @event.AsCloudEvent(source); // Assert Assert.NotNull(cloudEvent); Assert.Equal(topic, @event.Topic); Assert.Equal(subject, cloudEvent.Subject); Assert.Equal(eventType, cloudEvent.Type); Assert.Equal(eventTime, cloudEvent.Time.GetValueOrDefault()); Assert.Equal(id, cloudEvent.Id); var eventPayload = cloudEvent.GetPayload <StorageBlobCreatedEventData>(); Assert.NotNull(eventPayload); Assert.Equal(api, eventPayload.Api); Assert.Equal(clientRequestId, eventPayload.ClientRequestId); Assert.Equal(requestId, eventPayload.RequestId); Assert.Equal(eTag, eventPayload.ETag); Assert.Equal(contentType, eventPayload.ContentType); Assert.Equal(contentLength, eventPayload.ContentLength); Assert.Equal(blobType, eventPayload.BlobType); Assert.Equal(url, eventPayload.Url); Assert.Equal(sequencer, eventPayload.Sequencer); Assert.NotNull(eventPayload.StorageDiagnostics); var storageDiagnostics = Assert.IsType <JObject>(eventPayload.StorageDiagnostics); Assert.Equal(batchId, storageDiagnostics["batchId"]); }
public void ParseImplicit_ValidBlobCreatedEvent_ShouldSucceed() { // Arrange const string topic = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; const string subject = "/blobServices/default/containers/event-container/blobs/finnishjpeg"; const string eventType = "Microsoft.Storage.BlobCreated"; const string id = "5647b67c-b01e-002d-6a47-bc01ac063360"; const string dataVersion = "1"; const string metadataVersion = "1"; const string api = "PutBlockList"; const string clientRequestId = "5c24a322-35c9-4b46-8ef5-245a81af7037"; const string requestId = "5647b67c-b01e-002d-6a47-bc01ac000000"; const string eTag = "0x8D58A5F0C6722F9"; const string contentType = "image/jpeg"; const int contentLength = 29342; const string blobType = "BlockBlob"; const string url = "https://sample.blob.core.windows.net/event-container/finnish.jpeg"; const string sequencer = "00000000000000000000000000000094000000000017d503"; const string batchId = "69cd1576-e430-4aff-8153-570934a1f6e1"; string rawEvent = EventSamples.BlobCreateEvent; var eventTime = DateTimeOffset.Parse("2018-03-15T10:25:17.7535274Z"); // Act EventBatch <Event> eventGridMessage = EventParser.Parse(rawEvent); // Assert Assert.NotNull(eventGridMessage); Assert.NotNull(eventGridMessage.Events); Event eventGridEvent = Assert.Single(eventGridMessage.Events); Assert.NotNull(eventGridEvent); Assert.Equal(topic, eventGridEvent.Topic); Assert.Equal(subject, eventGridEvent.Subject); Assert.Equal(eventType, eventGridEvent.EventType); Assert.Equal(eventTime, eventGridEvent.EventTime); Assert.Equal(id, eventGridEvent.Id); Assert.Equal(dataVersion, eventGridEvent.DataVersion); Assert.Equal(metadataVersion, eventGridEvent.MetadataVersion); var eventPayload = eventGridEvent.GetPayload <StorageBlobCreatedEventData>(); Assert.NotNull(eventPayload); Assert.Equal(api, eventPayload.Api); Assert.Equal(clientRequestId, eventPayload.ClientRequestId); Assert.Equal(requestId, eventPayload.RequestId); Assert.Equal(eTag, eventPayload.ETag); Assert.Equal(contentType, eventPayload.ContentType); Assert.Equal(contentLength, eventPayload.ContentLength); Assert.Equal(blobType, eventPayload.BlobType); Assert.Equal(url, eventPayload.Url); Assert.Equal(sequencer, eventPayload.Sequencer); Assert.NotNull(eventPayload.StorageDiagnostics); var storageDiagnostics = Assert.IsType <JObject>(eventPayload.StorageDiagnostics); Assert.Equal(batchId, storageDiagnostics["batchId"]); }
public void ParseEventTime() { var stringToParse = "12.07. 20:00"; var correctDateTime = new DateTime(2020, 07, 12, 20, 00, 00); var parsedTime = EventParser.ParseDateTime(stringToParse, 2020); Assert.AreEqual(correctDateTime, parsedTime); }
private EventBusinessModel EventModelBllToEventModelContract(BusinessLogic.BusinessModels.EventModel from) { return(new EventBusinessModel { Areas = from.Areas?.Select(x => EventAreaParser.ToEventAreaContract(x)).ToList(), Event = from.Event is null ? null : EventParser.ToEventContract(from.Event), IsPublished = from.IsPublished, LayoutName = from.LayoutName ?? null, Venue = from.Venue is null ? null : VenueParser.ToVenueContract(from.Venue) });
public void ParseEventExplicit_ValidStorageBlobCreatedCloudEvent_ShouldSucceed() { // Arrange const CloudEventsSpecVersion cloudEventsVersion = CloudEventsSpecVersion.V0_1; const string eventType = "Microsoft.Storage.BlobCreated", source = "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Storage/storageAccounts/{storage-account}#blobServices/default/containers/{storage-container}/blobs/{new-file}", eventId = "173d9985-401e-0075-2497-de268c06ff25", eventTime = "2018-04-28T02:18:47.1281675Z"; const string api = "PutBlockList", clientRequestId = "6d79dbfb-0e37-4fc4-981f-442c9ca65760", requestId = "831e1650-001e-001b-66ab-eeb76e000000", etag = "0x8D4BCC2E4835CD0", contentType = "application/octet-stream", blobType = "BlockBlob", url = "https://oc2d2817345i60006.blob.core.windows.net/oc2d2817345i200097container/oc2d2817345i20002296blob", sequencer = "00000000000004420000000000028963", batchId = "b68529f3-68cd-4744-baa4-3c0498ec19f0"; const long contentLength = 524_288; string rawEvent = EventSamples.AzureBlobStorageCreatedCloudEvent; // Act EventBatch <Event> eventBatch = EventParser.Parse(rawEvent); // Assert Assert.NotNull(eventBatch); Assert.NotNull(eventBatch.Events); CloudEvent cloudEvent = Assert.Single(eventBatch.Events); Assert.NotNull(cloudEvent); Assert.Equal(cloudEventsVersion, cloudEvent.SpecVersion); Assert.Equal(eventType, cloudEvent.Type); Assert.Equal(source, cloudEvent.Source.OriginalString); Assert.Equal(eventId, cloudEvent.Id); Assert.Equal(eventTime, cloudEvent.Time.GetValueOrDefault().ToString("O")); var eventPayload = cloudEvent.GetPayload <StorageBlobCreatedEventData>(); Assert.NotNull(eventPayload); Assert.Equal(api, eventPayload.Api); Assert.Equal(clientRequestId, eventPayload.ClientRequestId); Assert.Equal(requestId, eventPayload.RequestId); Assert.Equal(etag, eventPayload.ETag); Assert.Equal(contentType, eventPayload.ContentType); Assert.Equal(contentLength, eventPayload.ContentLength); Assert.Equal(blobType, eventPayload.BlobType); Assert.Equal(url, eventPayload.Url); Assert.Equal(sequencer, eventPayload.Sequencer); Assert.NotNull(eventPayload.StorageDiagnostics); var storageDiagnostics = Assert.IsType <JObject>(eventPayload.StorageDiagnostics); Assert.Equal(batchId, storageDiagnostics["batchId"]); }
public static ReturnValue ParseOBJFile(string path, EventParser vectorParser, EventParser texCoordParser, EventParser normalParser, EventParser commentParser = null) { if (!File.Exists(path)) return ReturnValue.FileNotFound; string[] data = File.ReadAllLines(path, Encoding.ASCII); foreach (string line in data) { } return ReturnValue.OK; }