File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -564,6 +564,7 @@ public void TestCreateConversionEventNoAttributesWithInvalidValue()
564564                                                    { "timestamp" ,  timeStamp  } , 
565565                                                    { "uuid" ,  guid  } , 
566566                                                    { "key" ,  "purchase"  } , 
567+                                                     { "revenue" ,  42  } , 
567568                                                    { "tags" , 
568569                                                        new  Dictionary < string ,  object > 
569570                                                        { 
Original file line number Diff line number Diff line change @@ -35,12 +35,16 @@ public void TestGetRevenueValue()
3535        { 
3636            var  expectedValue  =  42 ; 
3737            var  expectedValue2  =  100 ; 
38+             var  expectedValueString  =  123 ; 
3839            var  validTag  =  new  Dictionary < string ,  object > ( )  { 
3940                {  "revenue" ,  42  } 
4041            } ; 
4142            var  validTag2  =  new  Dictionary < string ,  object > ( )  { 
4243                {  "revenue" ,  100  } 
4344            } ; 
45+             var  validTagStringValue  =  new  Dictionary < string ,  object > ( )  { 
46+                 {  "revenue" ,  "123"  } 
47+             } ; 
4448
4549            var  invalidTag  =  new  Dictionary < string ,  object > ( )  { 
4650                {  "abc" ,  42  } 
@@ -51,16 +55,22 @@ public void TestGetRevenueValue()
5155            var  invalidValue  =  new  Dictionary < string ,  object > ( )  { 
5256                {  "revenue" ,  42.5  } 
5357            } ; 
58+             var  invalidTagNonRevenue  =  new  Dictionary < string ,  object > ( ) 
59+             { 
60+                 { "non-revenue" ,  123  } 
61+             } ; 
5462
5563            // Invalid data. 
5664            Assert . Null ( EventTagUtils . GetRevenueValue ( null ) ) ; 
5765            Assert . Null ( EventTagUtils . GetRevenueValue ( invalidTag ) ) ; 
5866            Assert . Null ( EventTagUtils . GetRevenueValue ( nullValue ) ) ; 
5967            Assert . Null ( EventTagUtils . GetRevenueValue ( invalidValue ) ) ; 
68+             Assert . Null ( EventTagUtils . GetRevenueValue ( invalidTagNonRevenue ) ) ; 
6069
6170            // Valid data. 
6271            Assert . AreEqual ( EventTagUtils . GetRevenueValue ( validTag ) ,  expectedValue ) ; 
6372            Assert . AreEqual ( EventTagUtils . GetRevenueValue ( validTag2 ) ,  expectedValue2 ) ; 
73+             Assert . AreEqual ( EventTagUtils . GetRevenueValue ( validTagStringValue ) ,  expectedValueString ) ; 
6474        } 
6575
6676        [ Test ] 
Original file line number Diff line number Diff line change @@ -10,13 +10,14 @@ public class EventTagUtils
1010
1111        public  static   object  GetRevenueValue ( Dictionary < string ,  object >  eventTags ) 
1212        { 
13+             int  result  =  0 ; 
1314            if  ( eventTags  ==  null  
1415                ||  ! eventTags . ContainsKey ( REVENUE_EVENT_METRIC_NAME )  
1516                ||  eventTags [ REVENUE_EVENT_METRIC_NAME ]  ==  null  
16-                 ||  ! ( eventTags [ REVENUE_EVENT_METRIC_NAME ]   is   int ) ) 
17+                 ||  ! int . TryParse ( eventTags [ REVENUE_EVENT_METRIC_NAME ] . ToString ( ) ,   out   result ) ) 
1718                return  null ; 
1819
19-            return  eventTags [ REVENUE_EVENT_METRIC_NAME ] ; 
20+            return    result ; 
2021        } 
2122
2223        public  static   object  GetNumericValue ( Dictionary < string ,  object >  eventTags ,  ILogger  logger   =  null ) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments