@@ -779,6 +779,86 @@ public void ResolveEvent_WithZeroKeywords_ShouldReturnEmptyKeywordList()
779779 Assert . Empty ( displayEvent . Keywords ) ;
780780 }
781781
782+ [ Fact ]
783+ public void ResolveEvent_WithPercentZeroTerminator_ShouldSkipTerminatorAndResolveDescription ( )
784+ {
785+ // Arrange - %0 is a Windows Event Log message terminator that should be stripped
786+ var providerDetails = new ProviderDetails
787+ {
788+ ProviderName = Constants . TestProviderName ,
789+ Events = [ ] ,
790+ Messages =
791+ [
792+ new MessageModel
793+ {
794+ ProviderName = Constants . TestProviderName ,
795+ ShortId = 1000 ,
796+ Text = "Windows Search Service has created default configuration for new user '%1' .%n%0"
797+ }
798+ ] ,
799+ Parameters = [ ] ,
800+ Keywords = new Dictionary < long , string > ( ) ,
801+ Tasks = new Dictionary < int , string > ( )
802+ } ;
803+
804+ var resolver = new TestEventResolver ( [ providerDetails ] ) ;
805+
806+ var eventRecord = new EventRecord
807+ {
808+ ProviderName = Constants . TestProviderName ,
809+ Id = 1000 ,
810+ Properties = [ "TestUser" , "ExtraProperty" ]
811+ } ;
812+
813+ // Act - should not throw and should produce valid description
814+ var displayEvent = resolver . ResolveEvent ( eventRecord ) ;
815+
816+ // Assert
817+ Assert . NotNull ( displayEvent ) ;
818+ Assert . Contains ( "TestUser" , displayEvent . Description ) ;
819+ Assert . DoesNotContain ( "%0" , displayEvent . Description ) ;
820+ Assert . DoesNotContain ( "Failed to resolve" , displayEvent . Description ) ;
821+ }
822+
823+ [ Fact ]
824+ public void ResolveEvent_WithPropertyIndexOutOfRange_ShouldReturnFailedDescription ( )
825+ {
826+ // Arrange - template references %3 but only 2 properties exist
827+ var providerDetails = new ProviderDetails
828+ {
829+ ProviderName = Constants . TestProviderName ,
830+ Events = [ ] ,
831+ Messages =
832+ [
833+ new MessageModel
834+ {
835+ ProviderName = Constants . TestProviderName ,
836+ ShortId = 1000 ,
837+ Text = "Property1: %1, Property2: %2, Property3: %3"
838+ }
839+ ] ,
840+ Parameters = [ ] ,
841+ Keywords = new Dictionary < long , string > ( ) ,
842+ Tasks = new Dictionary < int , string > ( )
843+ } ;
844+
845+ var resolver = new TestEventResolver ( [ providerDetails ] ) ;
846+
847+ var eventRecord = new EventRecord
848+ {
849+ ProviderName = Constants . TestProviderName ,
850+ Id = 1000 ,
851+ Properties = [ "Value1" , "Value2" ] // Only 2 properties, but template expects 3
852+ } ;
853+
854+ // Act
855+ var displayEvent = resolver . ResolveEvent ( eventRecord ) ;
856+
857+ // Assert
858+ Assert . NotNull ( displayEvent ) ;
859+ Assert . Contains ( "Failed to resolve" , displayEvent . Description ) ;
860+ }
861+
782862 private class TestEventResolver : EventResolverBase , IEventResolver
783863 {
784864 public TestEventResolver ( IEventResolverCache ? cache = null , ITraceLogger ? logger = null )
0 commit comments