chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Quintiq file version 2.0
#parent: #root
StaticMethod CompareNamedValue (LibUTF_IterationRun run, Boolean checkequals, NamedValue sourcenv, 
  NamedValue targetnv, String text)
{
  Description: "Checks two NamedValue values if they match or not, based on the expected 'checkequals' value passed in."
  TextBody:
  [*
    value := true;
    
    sourcevalue := '';
    targetvalue := '';
    
    if( targetnv.GetValue().istype( Real ) )
    {
      value := sourcenv.GetValueAsReal() = targetnv.GetValueAsReal();
      sourcevalue := [String]sourcenv.GetValueAsReal();
      targetvalue := [String]targetnv.GetValueAsReal();
    }
    else if( targetnv.GetValue().istype( Number ) )
    {
      value := sourcenv.GetValueAsNumber() = targetnv.GetValueAsNumber();
      sourcevalue := [String]sourcenv.GetValueAsNumber();
      targetvalue := [String]targetnv.GetValueAsNumber();
    }
    else if( targetnv.GetValue().istype( String ) )
    {
      value := sourcenv.GetValueAsString() = targetnv.GetValueAsString();
      sourcevalue := sourcenv.GetValueAsString();
      targetvalue := targetnv.GetValueAsString();
    }
    else if( targetnv.GetValue().istype( Boolean ) )
    {
      value := sourcenv.GetValueAsBoolean() = targetnv.GetValueAsBoolean();
      sourcevalue := [String]sourcenv.GetValueAsBoolean();
      targetvalue := [String]targetnv.GetValueAsBoolean();
    }
    else if( targetnv.GetValue().istype( Date ) )
    {
      value := sourcenv.GetValueAsDate() = targetnv.GetValueAsDate();
      sourcevalue := [String]sourcenv.GetValueAsDate();
      targetvalue := [String]targetnv.GetValueAsDate();
    }
    else if( targetnv.GetValue().istype( DateTime ) )
    {
      value := sourcenv.GetValueAsDateTime() = targetnv.GetValueAsDateTime();
      sourcevalue := [String]sourcenv.GetValueAsDateTime();
      targetvalue := [String]targetnv.GetValueAsDateTime();
    }
    else if( targetnv.GetValue().istype( Duration ) )
    {
      value := sourcenv.GetValueAsDuration() = targetnv.GetValueAsDuration();
      sourcevalue := [String]sourcenv.GetValueAsDuration();
      targetvalue := [String]targetnv.GetValueAsDuration();
    }
    else if( targetnv.GetValue().istype( Key ) )
    {
      value := sourcenv.GetValueAsKey() = targetnv.GetValueAsKey();
      sourcevalue := [String]sourcenv.GetValueAsKey();
      targetvalue := [String]targetnv.GetValueAsKey();
    }
    else if( targetnv.GetValue().istype( BinaryValue ) )
    {
      value := sourcenv.GetValueAsBinaryValue() = targetnv.GetValueAsBinaryValue();
      sourcevalue := [String]sourcenv.GetValueAsBinaryValue();
      targetvalue := [String]targetnv.GetValueAsBinaryValue();
    }
    
    name := sourcenv.Name().SubString( 2, sourcenv.Name().Length() - 2 );
    
    text := 'Checking matching value for (@NAME@). Expecting (@EXPECTED@) but is (@ACTUAL@).'
                           .ReplaceAll( '@NAME@', name )
                           .ReplaceAll( '@EXPECTED@', targetvalue )
                           .ReplaceAll( '@ACTUAL@', sourcevalue );
    
    run.AssertEqual( value, checkequals, text );
  *]
}