PageRenderTime 39ms CodeModel.GetById 6ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 2ms

/Src/Compilers/CSharp/Test/Emit/CodeGen/WinRTCollectionTests.cs

https://github.com/EkardNT/Roslyn
C# | 7443 lines | 7248 code | 42 blank | 153 comment | 2 complexity | 6c30fac654fbeaf461328d7ac2aac221 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1// Copyright (c) Microsoft Open Technologies, Inc.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
   2
   3using System.Collections.Generic;
   4using Microsoft.CodeAnalysis.CSharp;
   5using Microsoft.CodeAnalysis.CSharp.Symbols;
   6using Microsoft.CodeAnalysis.CSharp.Syntax;
   7using ProprietaryTestResources = Microsoft.CodeAnalysis.Test.Resources.Proprietary;
   8using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
   9using Microsoft.CodeAnalysis.Test.Utilities;
  10using Roslyn.Test.Utilities;
  11using Xunit;
  12
  13namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen
  14{
  15    public class WinRTCollectionTests : CSharpTestBase
  16    {
  17        private MetadataReference[] _legacyRefs = null;
  18
  19        public MetadataReference[] LegacyRefs
  20        {
  21            get
  22            {
  23                if (_legacyRefs == null)
  24                {
  25                    var list = new List<MetadataReference>(WinRtRefs.Length + 2);
  26                    list.AddRange(WinRtRefs);
  27                    list.Add(
  28                        new MetadataImageReference(
  29                            TestResources.WinRt.Windows_Languages_WinRTTest.AsImmutableOrNull(),
  30                            display: "WinRTTest"));
  31                    list.Add(
  32                        new MetadataImageReference(
  33                            ProprietaryTestResources.NetFX.v4_0_30319_17929.System_Core.AsImmutableOrNull(),
  34                            display: "SystemCore"));
  35                    _legacyRefs = list.ToArray();
  36                }
  37                return _legacyRefs;
  38            }
  39        }
  40
  41        [Fact, WorkItem(762316, "DevDiv")]
  42        public void InheritFromTypeWithProjections()
  43        {
  44            var source = @"
  45using Windows.UI.Xaml;
  46 
  47public sealed class BehaviorCollection : DependencyObjectCollection
  48{
  49  private int count;
  50 
  51  public BehaviorCollection()
  52    {
  53        count = this.Count;
  54    }
  55  
  56  public object GetItem(int i)
  57    {
  58     return this[i];
  59    }
  60}";
  61            var comp = CreateCompilationWithMscorlib45(source, references: WinRtRefs);
  62            comp.VerifyDiagnostics();
  63        }
  64
  65        [Fact]
  66        public void IVectorProjectionTests()
  67        {
  68            var source =
  69@"using System;
  70using Windows.Data.Json;
  71
  72public class Class1
  73{
  74    public static void Main(string[] args)
  75    {
  76        var jsonArray = new JsonArray();
  77        var a = JsonValue.CreateStringValue(""a"");
  78        jsonArray.Add(a);
  79        var b = JsonValue.CreateStringValue(""b"");
  80        jsonArray.Insert(0, b);
  81        jsonArray.Remove(b);
  82        Console.WriteLine(jsonArray.Contains(b));
  83        Console.WriteLine(jsonArray.IndexOf(a));
  84        jsonArray.RemoveAt(0);
  85        Console.WriteLine(jsonArray.Count);
  86        jsonArray.Add(b);
  87        foreach (var json in jsonArray)
  88        {
  89            Console.WriteLine(json.GetString());
  90        }
  91        Console.WriteLine(jsonArray.Count);
  92        jsonArray.Clear();
  93        Console.WriteLine(jsonArray.Count);
  94    }
  95}";
  96            string expectedOutput =
  97@"False
  980
  990
 100b
 1011
 1020";
 103
 104            var verifier = CompileAndVerifyOnWin8Only(source,
 105                expectedOutput: expectedOutput,
 106                additionalRefs: WinRtRefs,
 107                emitOptions: EmitOptions.RefEmitBug);
 108
 109            verifier.VerifyIL("Class1.Main",
 110@"{
 111// Code size      174 (0xae)
 112  .maxstack  3
 113  .locals init (Windows.Data.Json.JsonArray V_0, //jsonArray
 114  Windows.Data.Json.JsonValue V_1, //a
 115  Windows.Data.Json.JsonValue V_2, //b
 116  System.Collections.Generic.IEnumerator<Windows.Data.Json.IJsonValue> V_3)
 117  IL_0000:  newobj     ""Windows.Data.Json.JsonArray..ctor()""
 118  IL_0005:  stloc.0
 119  IL_0006:  ldstr      ""a""
 120  IL_000b:  call       ""Windows.Data.Json.JsonValue Windows.Data.Json.JsonValue.CreateStringValue(string)""
 121  IL_0010:  stloc.1
 122  IL_0011:  ldloc.0
 123  IL_0012:  ldloc.1
 124  IL_0013:  callvirt   ""void System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Add(Windows.Data.Json.IJsonValue)""
 125  IL_0018:  ldstr      ""b""
 126  IL_001d:  call       ""Windows.Data.Json.JsonValue Windows.Data.Json.JsonValue.CreateStringValue(string)""
 127  IL_0022:  stloc.2
 128  IL_0023:  ldloc.0
 129  IL_0024:  ldc.i4.0
 130  IL_0025:  ldloc.2
 131  IL_0026:  callvirt   ""void System.Collections.Generic.IList<Windows.Data.Json.IJsonValue>.Insert(int, Windows.Data.Json.IJsonValue)""
 132  IL_002b:  ldloc.0
 133  IL_002c:  ldloc.2
 134  IL_002d:  callvirt   ""bool System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Remove(Windows.Data.Json.IJsonValue)""
 135  IL_0032:  pop
 136  IL_0033:  ldloc.0
 137  IL_0034:  ldloc.2
 138  IL_0035:  callvirt   ""bool System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Contains(Windows.Data.Json.IJsonValue)""
 139  IL_003a:  call       ""void System.Console.WriteLine(bool)""
 140  IL_003f:  ldloc.0
 141  IL_0040:  ldloc.1
 142  IL_0041:  callvirt   ""int System.Collections.Generic.IList<Windows.Data.Json.IJsonValue>.IndexOf(Windows.Data.Json.IJsonValue)""
 143  IL_0046:  call       ""void System.Console.WriteLine(int)""
 144  IL_004b:  ldloc.0
 145  IL_004c:  ldc.i4.0
 146  IL_004d:  callvirt   ""void System.Collections.Generic.IList<Windows.Data.Json.IJsonValue>.RemoveAt(int)""
 147  IL_0052:  ldloc.0
 148  IL_0053:  callvirt   ""int System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Count.get""
 149  IL_0058:  call       ""void System.Console.WriteLine(int)""
 150  IL_005d:  ldloc.0
 151  IL_005e:  ldloc.2
 152  IL_005f:  callvirt   ""void System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Add(Windows.Data.Json.IJsonValue)""
 153  IL_0064:  ldloc.0
 154  IL_0065:  callvirt   ""System.Collections.Generic.IEnumerator<Windows.Data.Json.IJsonValue> System.Collections.Generic.IEnumerable<Windows.Data.Json.IJsonValue>.GetEnumerator()""
 155  IL_006a:  stloc.3
 156  .try
 157{
 158  IL_006b:  br.s       IL_007d
 159  IL_006d:  ldloc.3
 160  IL_006e:  callvirt   ""Windows.Data.Json.IJsonValue System.Collections.Generic.IEnumerator<Windows.Data.Json.IJsonValue>.Current.get""
 161  IL_0073:  callvirt   ""string Windows.Data.Json.IJsonValue.GetString()""
 162  IL_0078:  call       ""void System.Console.WriteLine(string)""
 163  IL_007d:  ldloc.3
 164  IL_007e:  callvirt   ""bool System.Collections.IEnumerator.MoveNext()""
 165  IL_0083:  brtrue.s   IL_006d
 166  IL_0085:  leave.s    IL_0091
 167}
 168  finally
 169{
 170  IL_0087:  ldloc.3
 171  IL_0088:  brfalse.s  IL_0090
 172  IL_008a:  ldloc.3
 173  IL_008b:  callvirt   ""void System.IDisposable.Dispose()""
 174  IL_0090:  endfinally
 175}
 176  IL_0091:  ldloc.0
 177  IL_0092:  callvirt   ""int System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Count.get""
 178  IL_0097:  call       ""void System.Console.WriteLine(int)""
 179  IL_009c:  ldloc.0
 180  IL_009d:  callvirt   ""void System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Clear()""
 181  IL_00a2:  ldloc.0
 182  IL_00a3:  callvirt   ""int System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Count.get""
 183  IL_00a8:  call       ""void System.Console.WriteLine(int)""
 184  IL_00ad:  ret
 185}
 186");
 187        }
 188
 189        [Fact]
 190        public void IVectorViewProjectionTests()
 191        {
 192            var source =
 193@"using System;
 194using Windows.Foundation;
 195
 196public class Class1
 197{
 198    public static void Main(string[] args)
 199    {
 200        var results = new WwwFormUrlDecoder(""?param1=test"");
 201        Console.Out.WriteLine(results[0].Name + results[0].Value);
 202    }
 203}";
 204            var expectedOut = "param1test";
 205            var verifier = CompileAndVerifyOnWin8Only(
 206                source,
 207                expectedOutput: expectedOut,
 208                additionalRefs: WinRtRefs,
 209                emitOptions: EmitOptions.RefEmitBug);
 210
 211            verifier.VerifyIL("Class1.Main",
 212@"{
 213  // Code size       51 (0x33)
 214  .maxstack  4
 215  .locals init (Windows.Foundation.WwwFormUrlDecoder V_0) //results
 216  IL_0000:  ldstr      ""?param1=test""
 217  IL_0005:  newobj     ""Windows.Foundation.WwwFormUrlDecoder..ctor(string)""
 218  IL_000a:  stloc.0
 219  IL_000b:  call       ""System.IO.TextWriter System.Console.Out.get""
 220  IL_0010:  ldloc.0
 221  IL_0011:  ldc.i4.0
 222  IL_0012:  callvirt   ""Windows.Foundation.IWwwFormUrlDecoderEntry System.Collections.Generic.IReadOnlyList<Windows.Foundation.IWwwFormUrlDecoderEntry>.this[int].get""
 223  IL_0017:  callvirt   ""string Windows.Foundation.IWwwFormUrlDecoderEntry.Name.get""
 224  IL_001c:  ldloc.0
 225  IL_001d:  ldc.i4.0
 226  IL_001e:  callvirt   ""Windows.Foundation.IWwwFormUrlDecoderEntry System.Collections.Generic.IReadOnlyList<Windows.Foundation.IWwwFormUrlDecoderEntry>.this[int].get""
 227  IL_0023:  callvirt   ""string Windows.Foundation.IWwwFormUrlDecoderEntry.Value.get""
 228  IL_0028:  call       ""string string.Concat(string, string)""
 229  IL_002d:  callvirt   ""void System.IO.TextWriter.WriteLine(string)""
 230  IL_0032:  ret
 231}");
 232        }
 233
 234        [Fact]
 235        public void IMapProjectionTests()
 236        {
 237            var source =
 238@"using System;
 239using System.Collections.Generic;
 240using Windows.ApplicationModel.DataTransfer;
 241
 242public class Class1
 243{
 244    public static void Main(string[] args)
 245    {
 246        var dataPackage = new DataPackage();
 247        var dpps = dataPackage.Properties;
 248        dpps.Add(new KeyValuePair<string, object>(""testKey1"", ""testValue1""));
 249        Console.Out.WriteLine(dpps.ContainsKey(""testKey1""));
 250        Console.Out.WriteLine(dpps[""testKey1""]);
 251        dpps.Add(""testKey2"", ""testValue2"");
 252        object tv2;
 253        dpps.TryGetValue(""testKey2"", out tv2);
 254        Console.Out.WriteLine(tv2);
 255        dpps[""testKey2""] = ""testValue3"";
 256        dpps.Remove(""testKey1"");
 257        var valsEnumerator = dpps.Values.GetEnumerator();
 258        var keysEnumerator = dpps.Keys.GetEnumerator();
 259        while (keysEnumerator.MoveNext() && valsEnumerator.MoveNext())
 260        {
 261            Console.Out.WriteLine(keysEnumerator.Current + valsEnumerator.Current);
 262        }
 263    }
 264}";
 265
 266            var expectedOut =
 267@"True
 268testValue1
 269testValue2
 270testKey2testValue3
 271";
 272            var verifier = CompileAndVerifyOnWin8Only(
 273                source,
 274                expectedOutput: expectedOut,
 275                additionalRefs: WinRtRefs,
 276                emitOptions: EmitOptions.RefEmitBug);
 277
 278            verifier.VerifyIL("Class1.Main",
 279@"{
 280// Code size      213 (0xd5)
 281  .maxstack  3
 282  .locals init (Windows.ApplicationModel.DataTransfer.DataPackagePropertySet V_0, //dpps
 283  object V_1, //tv2
 284  System.Collections.Generic.IEnumerator<object> V_2, //valsEnumerator
 285  System.Collections.Generic.IEnumerator<string> V_3) //keysEnumerator
 286  IL_0000:  newobj     ""Windows.ApplicationModel.DataTransfer.DataPackage..ctor()""
 287  IL_0005:  callvirt   ""Windows.ApplicationModel.DataTransfer.DataPackagePropertySet Windows.ApplicationModel.DataTransfer.DataPackage.Properties.get""
 288  IL_000a:  stloc.0
 289  IL_000b:  ldloc.0
 290  IL_000c:  ldstr      ""testKey1""
 291  IL_0011:  ldstr      ""testValue1""
 292  IL_0016:  newobj     ""System.Collections.Generic.KeyValuePair<string, object>..ctor(string, object)""
 293  IL_001b:  callvirt   ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>.Add(System.Collections.Generic.KeyValuePair<string, object>)""
 294  IL_0020:  call       ""System.IO.TextWriter System.Console.Out.get""
 295  IL_0025:  ldloc.0
 296  IL_0026:  ldstr      ""testKey1""
 297  IL_002b:  callvirt   ""bool System.Collections.Generic.IDictionary<string, object>.ContainsKey(string)""
 298  IL_0030:  callvirt   ""void System.IO.TextWriter.WriteLine(bool)""
 299  IL_0035:  call       ""System.IO.TextWriter System.Console.Out.get""
 300  IL_003a:  ldloc.0
 301  IL_003b:  ldstr      ""testKey1""
 302  IL_0040:  callvirt   ""object System.Collections.Generic.IDictionary<string, object>.this[string].get""
 303  IL_0045:  callvirt   ""void System.IO.TextWriter.WriteLine(object)""
 304  IL_004a:  ldloc.0
 305  IL_004b:  ldstr      ""testKey2""
 306  IL_0050:  ldstr      ""testValue2""
 307  IL_0055:  callvirt   ""void System.Collections.Generic.IDictionary<string, object>.Add(string, object)""
 308  IL_005a:  ldloc.0
 309  IL_005b:  ldstr      ""testKey2""
 310  IL_0060:  ldloca.s   V_1
 311  IL_0062:  callvirt   ""bool System.Collections.Generic.IDictionary<string, object>.TryGetValue(string, out object)""
 312  IL_0067:  pop
 313  IL_0068:  call       ""System.IO.TextWriter System.Console.Out.get""
 314  IL_006d:  ldloc.1
 315  IL_006e:  callvirt   ""void System.IO.TextWriter.WriteLine(object)""
 316  IL_0073:  ldloc.0
 317  IL_0074:  ldstr      ""testKey2""
 318  IL_0079:  ldstr      ""testValue3""
 319  IL_007e:  callvirt   ""void System.Collections.Generic.IDictionary<string, object>.this[string].set""
 320  IL_0083:  ldloc.0
 321  IL_0084:  ldstr      ""testKey1""
 322  IL_0089:  callvirt   ""bool System.Collections.Generic.IDictionary<string, object>.Remove(string)""
 323  IL_008e:  pop
 324  IL_008f:  ldloc.0
 325  IL_0090:  callvirt   ""System.Collections.Generic.ICollection<object> System.Collections.Generic.IDictionary<string, object>.Values.get""
 326  IL_0095:  callvirt   ""System.Collections.Generic.IEnumerator<object> System.Collections.Generic.IEnumerable<object>.GetEnumerator()""
 327  IL_009a:  stloc.2
 328  IL_009b:  ldloc.0
 329  IL_009c:  callvirt   ""System.Collections.Generic.ICollection<string> System.Collections.Generic.IDictionary<string, object>.Keys.get""
 330  IL_00a1:  callvirt   ""System.Collections.Generic.IEnumerator<string> System.Collections.Generic.IEnumerable<string>.GetEnumerator()""
 331  IL_00a6:  stloc.3
 332  IL_00a7:  br.s       IL_00c4
 333  IL_00a9:  call       ""System.IO.TextWriter System.Console.Out.get""
 334  IL_00ae:  ldloc.3
 335  IL_00af:  callvirt   ""string System.Collections.Generic.IEnumerator<string>.Current.get""
 336  IL_00b4:  ldloc.2
 337  IL_00b5:  callvirt   ""object System.Collections.Generic.IEnumerator<object>.Current.get""
 338  IL_00ba:  call       ""string string.Concat(object, object)""
 339  IL_00bf:  callvirt   ""void System.IO.TextWriter.WriteLine(string)""
 340  IL_00c4:  ldloc.3
 341  IL_00c5:  callvirt   ""bool System.Collections.IEnumerator.MoveNext()""
 342  IL_00ca:  brfalse.s  IL_00d4
 343  IL_00cc:  ldloc.2
 344  IL_00cd:  callvirt   ""bool System.Collections.IEnumerator.MoveNext()""
 345  IL_00d2:  brtrue.s   IL_00a9
 346  IL_00d4:  ret
 347}");
 348        }
 349
 350        // TODO: There are no suitable winmd members to test the IMapView projections,
 351        // a custom winmd will have to be used after winmd references are implemented
 352
 353        [Fact]
 354        public void MultipleInterfaceMethodConflictTests()
 355        {
 356            var source =
 357@"using Windows.Data.Json;
 358using Windows.Foundation;
 359
 360public class Class1
 361{
 362    public static void Main(string[] args)
 363    {
 364        var en = new JsonArray().GetEnumerator();
 365        en = new WwwFormUrlDecoder(""?param1=test"").GetEnumerator();
 366    }
 367}";
 368            var comp = CreateCompilation(source, references: WinRtRefs);
 369            // JsonArray implements both IEnumerable and IList, which both have a GetEnumerator
 370            // method. We can't know which interface method to call, so we shouldn't emit a
 371            // GetEnumerator method at all.
 372            comp.VerifyDiagnostics(
 373                Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetEnumerator")
 374                .WithArguments("Windows.Data.Json.JsonArray", "GetEnumerator"),
 375                Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetEnumerator")
 376                .WithArguments("Windows.Foundation.WwwFormUrlDecoder", "GetEnumerator"));
 377
 378        }
 379
 380        [Fact]
 381        public void LegacyCollectionTest01()
 382        {
 383            var source =
 384@"using Windows.Languages.WinRTTest;
 385using System.Collections.Generic;
 386using System.Reflection;
 387using System.Linq.Expressions;
 388using System;
 389using System.Linq;
 390
 391class AllMembers
 392{
 393    private static int FailedCount = 0;
 394    private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
 395    {
 396        var temp = Console.ForegroundColor;
 397        if (actual != expected)
 398        {
 399            FailedCount++;
 400            Console.ForegroundColor = ConsoleColor.Red;
 401            Console.Write(""FAIL:  "");
 402        }
 403        else
 404        {
 405            Console.ForegroundColor = ConsoleColor.Green;
 406            Console.Write(""PASS:  "");
 407        }
 408
 409        Console.ForegroundColor = temp;
 410        Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
 411        return actual == expected;
 412    }
 413
 414    private static bool ValidateValue(object actual, object expected)
 415    {
 416        var temp = Console.ForegroundColor;
 417        if (actual.ToString() != expected.ToString())
 418        {
 419            FailedCount++;
 420            Console.ForegroundColor = ConsoleColor.Red;
 421            Console.Write(""FAIL:  "");
 422        }
 423        else
 424        {
 425            Console.ForegroundColor = ConsoleColor.Green;
 426            Console.Write(""PASS:  "");
 427        }
 428
 429        Console.ForegroundColor = temp;
 430        Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
 431        return actual.ToString() == expected.ToString();
 432    }
 433
 434    static void TestIIterableMembers()
 435    {
 436        Console.WriteLine(""===  IIterableFloat  ==="");
 437        var i = new IIterableFloat();
 438        i.ClearFlag();
 439
 440        IEnumerator<float> enumerator = ((IEnumerable<float>)i).GetEnumerator();
 441        ValidateMethod(i.GetFlagState(), TestMethodCalled.IIterable_First);
 442    }
 443
 444    static int Main()
 445    {
 446        TestIIterableMembers();
 447        
 448        Console.WriteLine(FailedCount);
 449        return FailedCount;
 450    }
 451}";
 452            var verifier = CompileAndVerify(source,
 453                additionalRefs: LegacyRefs,
 454                emitOptions: EmitOptions.RefEmitBug,
 455                verify: false);
 456            verifier.VerifyDiagnostics(
 457                // (3,1): info CS8019: Unnecessary using directive.
 458                // using System.Reflection;
 459                Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
 460                // (4,1): info CS8019: Unnecessary using directive.
 461                // using System.Linq.Expressions;
 462                Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
 463                // (6,1): info CS8019: Unnecessary using directive.
 464                // using System.Linq;
 465                Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
 466            verifier.VerifyIL("AllMembers.TestIIterableMembers",
 467@"{
 468  // Code size       41 (0x29)
 469  .maxstack  2
 470  IL_0000:  ldstr      ""===  IIterableFloat  ===""
 471  IL_0005:  call       ""void System.Console.WriteLine(string)""
 472  IL_000a:  newobj     ""Windows.Languages.WinRTTest.IIterableFloat..ctor()""
 473  IL_000f:  dup
 474  IL_0010:  callvirt   ""void Windows.Languages.WinRTTest.IIterableFloat.ClearFlag()""
 475  IL_0015:  dup
 476  IL_0016:  callvirt   ""System.Collections.Generic.IEnumerator<float> System.Collections.Generic.IEnumerable<float>.GetEnumerator()""
 477  IL_001b:  pop
 478  IL_001c:  callvirt   ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IIterableFloat.GetFlagState()""
 479  IL_0021:  ldc.i4.1
 480  IL_0022:  call       ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
 481  IL_0027:  pop
 482  IL_0028:  ret
 483}");
 484        }
 485
 486        [Fact]
 487        public void LegacyCollectionTest02()
 488        {
 489            var source =
 490@"using Windows.Languages.WinRTTest;
 491using System.Collections.Generic;
 492using System.Reflection;
 493using System.Linq.Expressions;
 494using System;
 495using System.Linq;
 496
 497class AllMembers
 498{
 499    private static int FailedCount = 0;
 500    private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
 501    {
 502        var temp = Console.ForegroundColor;
 503        if (actual != expected)
 504        {
 505            FailedCount++;
 506            Console.ForegroundColor = ConsoleColor.Red;
 507            Console.Write(""FAIL:  "");
 508        }
 509        else
 510        {
 511            Console.ForegroundColor = ConsoleColor.Green;
 512            Console.Write(""PASS:  "");
 513        }
 514
 515        Console.ForegroundColor = temp;
 516        Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
 517        return actual == expected;
 518    }
 519
 520    private static bool ValidateValue(object actual, object expected)
 521    {
 522        var temp = Console.ForegroundColor;
 523        if (actual.ToString() != expected.ToString())
 524        {
 525            FailedCount++;
 526            Console.ForegroundColor = ConsoleColor.Red;
 527            Console.Write(""FAIL:  "");
 528        }
 529        else
 530        {
 531            Console.ForegroundColor = ConsoleColor.Green;
 532            Console.Write(""PASS:  "");
 533        }
 534
 535        Console.ForegroundColor = temp;
 536        Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
 537        return actual.ToString() == expected.ToString();
 538    }
 539
 540    static void TestIVectorIntMembers()
 541    {
 542        Console.WriteLine(""===  IVectorInt  ==="");
 543        var v = new IVectorInt();
 544        //Add
 545        v.ClearFlag();
 546        v.Add(1);
 547        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
 548        ValidateValue(v[0], 1);
 549        //Contains
 550        v.ClearFlag();
 551        bool b = v.Contains(1);
 552        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 553        ValidateValue(b, true);
 554        //CopyTo
 555        v.ClearFlag();
 556        int[] arr = new int[10];
 557        v.CopyTo(arr, 0);
 558        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 559        ValidateValue(arr[0], 1);
 560        ValidateValue(arr[1], 0); //there should be nothing there! :)
 561        //GetEnumerator
 562        v.ClearFlag();
 563        int count = v.Count;
 564        IEnumerator<int> enumerator = ((IEnumerable<int>)v).GetEnumerator();
 565        ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
 566        int index = 0;
 567        foreach (var e in v)
 568        {
 569            index = index + 1;
 570            ValidateValue(e, index);
 571        }
 572
 573        ValidateValue(index, 1); //there should only be 1 element there
 574        //IndexOf
 575        v.ClearFlag();
 576        var rez = v.IndexOf(1);
 577        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 578        ValidateValue(rez, 0); // 1 is on the first line :)
 579        //Insert
 580        v.ClearFlag();
 581        v.Insert(1, 2);
 582        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
 583        ValidateValue(v[1], 2);
 584        //IsReadOnly
 585        v.ClearFlag();
 586        bool isReadOnly = v.IsReadOnly;
 587        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
 588        ValidateValue(isReadOnly, false);
 589        //Indexing
 590        v.ClearFlag();
 591        int val = v[0];
 592        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 593        ValidateValue(val, 1);
 594        v.ClearFlag();
 595        val = v[1];
 596        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 597        ValidateValue(val, 2);
 598        //Remove
 599        v.ClearFlag();
 600        v.Remove(1);
 601        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 602        ValidateValue(v.Count, 1);
 603        //RemoveAt
 604        v.ClearFlag();
 605        v.RemoveAt(0);
 606        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 607        ValidateValue(v.Count, 0);
 608        //Clear
 609        v.Add(1);
 610        v.Add(2);
 611        v.ClearFlag();
 612        v.Clear();
 613        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
 614        ValidateValue(v.Count, 0);
 615    }
 616
 617    static void TestIVectorStructMembers()
 618    {
 619        Console.WriteLine(""===  IVectorStruct  ==="");
 620        var v = new IVectorStruct();
 621        var ud = new UserDefinedStruct()
 622        {
 623            Id = 1
 624        }
 625
 626        ;
 627        //Add
 628        v.ClearFlag();
 629        v.Add(ud);
 630        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
 631        ValidateValue(v[0].Id, 1);
 632        //Contains
 633        v.ClearFlag();
 634        bool b = v.Contains(ud);
 635        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 636        ValidateValue(b, true);
 637        //CopyTo
 638        v.ClearFlag();
 639        UserDefinedStruct[] arr = new UserDefinedStruct[10];
 640        v.CopyTo(arr, 0);
 641        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 642        ValidateValue(arr[0].Id, ud.Id);
 643        //GetEnumerator
 644        v.ClearFlag();
 645        int count = v.Count;
 646        IEnumerator<UserDefinedStruct> enumerator = ((IEnumerable<UserDefinedStruct>)v).GetEnumerator();
 647        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_get_Size);
 648        enumerator.MoveNext();
 649        ValidateValue((enumerator.Current).Id, 1);
 650        int index = 0;
 651        foreach (var e in v)
 652        {
 653            index = index + 1;
 654            ValidateValue(e.Id, index);
 655        }
 656
 657        ValidateValue(index, 1); //there should only be 1 element there
 658        //IndexOf
 659        v.ClearFlag();
 660        var rez = v.IndexOf(ud);
 661        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 662        ValidateValue(rez, 0); // 1 is on the first line :)
 663        //Insert
 664        v.ClearFlag();
 665        v.Insert(1, new UserDefinedStruct()
 666        {
 667            Id = 4
 668        }
 669
 670        );
 671        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
 672        ValidateValue(v[1].Id, 4);
 673        //IsReadOnly
 674        v.ClearFlag();
 675        bool isReadOnly = v.IsReadOnly;
 676        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
 677        ValidateValue(isReadOnly, false);
 678        //Indexing
 679        v.ClearFlag();
 680        var val = v[0];
 681        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 682        ValidateValue(val.Id, ud.Id);
 683        v.ClearFlag();
 684        val = v[1];
 685        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 686        ValidateValue(val.Id, 4);
 687        //Remove
 688        v.ClearFlag();
 689        v.Remove(ud);
 690        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 691        ValidateValue(v.Count, 1);
 692        //RemoveAt
 693        v.ClearFlag();
 694        v.RemoveAt(0);
 695        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 696        ValidateValue(v.Count, 0);
 697        //Clear
 698        v.Add(ud);
 699        v.Add(new UserDefinedStruct()
 700        {
 701            Id = 4
 702        }
 703
 704        );
 705        v.ClearFlag();
 706        v.Clear();
 707        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
 708        ValidateValue(v.Count, 0);
 709    }
 710
 711    static void TestIVectorUintStructMembers()
 712    {
 713        Console.WriteLine(""===  IVectorUintStruct  ==="");
 714        var v = new IVectorUintStruct();
 715        //Add
 716        v.ClearFlag();
 717        v.Add(7);
 718        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
 719        ValidateValue((v as IList<uint>)[0], 7);
 720        //Contains
 721        v.ClearFlag();
 722        bool b = v.Contains(7);
 723        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 724        ValidateValue(b, true);
 725        //IndexOf
 726        v.ClearFlag();
 727        var rez = ((IList<uint>)v).IndexOf(7);
 728        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 729        ValidateValue(rez, 0);
 730        //Insert
 731        v.ClearFlag();
 732        v.Insert(1, 5);
 733        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
 734        ValidateValue((v as IList<uint>)[1], 5);
 735        //IsReadOnly
 736        v.ClearFlag();
 737        bool isReadOnly = ((IList<uint>)v).IsReadOnly;
 738        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
 739        ValidateValue(isReadOnly, false);
 740        //Indexing
 741        v.ClearFlag();
 742        uint val = ((uint)(v as IList<uint>)[0]);
 743        ValidateValue(val, 7);
 744        v.ClearFlag();
 745        val = ((IList<uint>)v)[1];
 746        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 747        ValidateValue(val, 5);
 748        //Remove 
 749        v.ClearFlag();
 750        v.Remove(5);
 751        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 752        ValidateValue(((IList<uint>)v).Count, 1);
 753        //RemoveAt
 754        try
 755        {
 756            v.ClearFlag();
 757            ((IList<uint>)v).RemoveAt(0);
 758            ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 759            ValidateValue(((IList<uint>)v).Count, 0);
 760        }
 761        catch (Exception exce)
 762        {
 763            Console.WriteLine(""RemoveAt"");
 764            Console.WriteLine(exce.Message);
 765        }
 766
 767        //Clear
 768        v.Add(1);
 769        v.Add(2);
 770        v.ClearFlag();
 771        ((IList<uint>)v).Clear();
 772        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
 773        ValidateValue(((IList<uint>)v).Count, 0);
 774        var ud = new UserDefinedStruct()
 775        {
 776            Id = 1
 777        }
 778
 779        ;
 780        //Add
 781        v.ClearFlag();
 782        v.Add(ud);
 783        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
 784        ValidateValue(((IList<UserDefinedStruct>)v)[0].Id, 1);
 785        //Contains
 786        v.ClearFlag();
 787        b = v.Contains(ud);
 788        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 789        ValidateValue(b, true);
 790        //'CopyTo
 791        //v.ClearFlag()
 792        //Dim arr As UserDefinedStruct()
 793        //ReDim arr(10)
 794        //v.CopyTo(arr, 0)
 795        //ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt)
 796        //ValidateValue(arr[0].Id, ud.Id)
 797        //GetEnumerator
 798        v.ClearFlag();
 799        int count = ((IList<UserDefinedStruct>)v).Count;
 800        IEnumerator<UserDefinedStruct> enumerator = ((IList<UserDefinedStruct>)v).GetEnumerator();
 801        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetMany);
 802        enumerator.MoveNext();
 803        ValidateValue((enumerator.Current).Id, 1);
 804        //IndexOf
 805        v.ClearFlag();
 806        rez = v.IndexOf(ud);
 807        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 808        ValidateValue(rez, 0); // 1 is on the first line :)
 809        //Insert
 810        v.ClearFlag();
 811        v.Insert(1, new UserDefinedStruct()
 812        {
 813            Id = 4
 814        }
 815
 816        );
 817        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
 818        ValidateValue(((IList<UserDefinedStruct>)v)[1].Id, 4);
 819        //IsReadOnly
 820        v.ClearFlag();
 821        isReadOnly = ((IList<UserDefinedStruct>)v).IsReadOnly;
 822        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
 823        ValidateValue(isReadOnly, false);
 824        //Indexing
 825        v.ClearFlag();
 826        var val2 = ((IList<UserDefinedStruct>)v)[0];
 827        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 828        ValidateValue(val2.Id, ud.Id);
 829        v.ClearFlag();
 830        val2 = ((IList<UserDefinedStruct>)v)[1];
 831        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 832        ValidateValue(val2.Id, 4);
 833        //Remove
 834        v.ClearFlag();
 835        v.Remove(ud);
 836        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 837        ValidateValue(((IList<UserDefinedStruct>)v).Count, 1);
 838        //RemoveAt
 839        v.ClearFlag();
 840        ((IList<UserDefinedStruct>)v).RemoveAt(0);
 841        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 842        ValidateValue(((IList<UserDefinedStruct>)v).Count, 0);
 843        //Clear
 844        v.Add(ud);
 845        v.Add(new UserDefinedStruct()
 846        {
 847            Id = 4
 848        }
 849
 850        );
 851        v.ClearFlag();
 852        ((IList<UserDefinedStruct>)v).Clear();
 853        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
 854        ValidateValue(((IList<UserDefinedStruct>)v).Count, 0);
 855    }
 856
 857    static void TestIVectorUintFloatMembers()
 858    {
 859        Console.WriteLine(""===  IVectorUintIVectorFloat  ==="");
 860        var v = new IVectorUintIVectorFloat();
 861        //Add
 862        v.ClearFlag();
 863        v.Add(7);
 864        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
 865        ValidateValue(((IList<uint>)v).Count, 1);
 866        try
 867        {
 868            ValidateValue(((IList<uint>)v)[0], 7);
 869        }
 870        catch (ArgumentException exc)
 871        {
 872            Console.WriteLine(exc.Message);
 873        }
 874
 875        //Contains
 876        v.ClearFlag();
 877        bool b = v.Contains(7);
 878        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 879        ValidateValue(b, true);
 880        //IndexOf
 881        v.ClearFlag();
 882        var rez = ((IList<uint>)v).IndexOf(7);
 883        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 884        ValidateValue(rez, 0);
 885        //Insertv.ClearFlag()
 886        v.Insert(1, 5);
 887        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
 888        try
 889        {
 890            ValidateValue(((IList<uint>)v)[1], 5);
 891        }
 892        catch (ArgumentException exc)
 893        {
 894            Console.WriteLine(exc.Message);
 895        }
 896
 897        //IsReadOnly
 898        v.ClearFlag();
 899        bool isReadOnly = ((IList<uint>)v).IsReadOnly;
 900        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
 901        ValidateValue(isReadOnly, false);
 902        //Indexing
 903        try
 904        {
 905            v.ClearFlag();
 906            var val = (v as IList<uint>)[0];
 907            ValidateValue(val, 7);
 908            v.ClearFlag();
 909            val = ((IList<uint>)v)[1];
 910            ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 911            ValidateValue(val, 5);
 912        }
 913        catch (Exception exce)
 914        {
 915            Console.WriteLine(""Indexing"");
 916            Console.WriteLine(exce.Message);
 917        }
 918
 919        //Remove 
 920        v.ClearFlag();
 921        v.Remove(5);
 922        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 923        ValidateValue(((IList<uint>)v).Count, 1);
 924        //RemoveAt
 925        try
 926        {
 927            v.ClearFlag();
 928            ((IList<uint>)v).RemoveAt(0);
 929            ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 930            ValidateValue(((IList<uint>)v).Count, 0);
 931        }
 932        catch (Exception exce)
 933        {
 934            Console.WriteLine(""RemoveAt"");
 935            Console.WriteLine(exce.Message);
 936        }
 937
 938        //Clear
 939        v.Add(1);
 940        v.Add(2);
 941        v.ClearFlag();
 942        ((IList<uint>)v).Clear();
 943        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
 944        ValidateValue(((IList<uint>)v).Count, 0);
 945        //single
 946        //Add
 947        v.ClearFlag();
 948        float one = 1;
 949        v.Add(one);
 950        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
 951        ValidateValue(((IList<float>)v)[0], one);
 952        //Contains
 953        v.ClearFlag();
 954        b = v.Contains(one);
 955        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 956        ValidateValue(b, true);
 957        //'CopyTo
 958        //v.ClearFlag()
 959        //Dim arr As single()
 960        //ReDim arr(10)
 961        //v.CopyTo(arr, 0)
 962        //ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt)
 963        //ValidateValue(arr[0].Id, ud.Id)
 964        //IndexOf
 965        v.ClearFlag();
 966        rez = v.IndexOf(one);
 967        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
 968        ValidateValue(rez, 0); // 1 is on the first line :)
 969        //Insert
 970        v.ClearFlag();
 971        v.Insert(1, (float)4);
 972        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
 973        ValidateValue(((IList<float>)v)[1], 4);
 974        //IsReadOnly
 975        v.ClearFlag();
 976        isReadOnly = ((IList<float>)v).IsReadOnly;
 977        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
 978        ValidateValue(isReadOnly, false);
 979        //Indexing
 980        v.ClearFlag();
 981        var val2 = ((IList<float>)v)[0];
 982        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 983        ValidateValue(val2, one);
 984        v.ClearFlag();
 985        val2 = ((IList<float>)v)[1];
 986        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
 987        ValidateValue(val2, 4);
 988        //Remove
 989        v.ClearFlag();
 990        v.Remove(one);
 991        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 992        ValidateValue(((IList<float>)v).Count, 1);
 993        //RemoveAt
 994        v.ClearFlag();
 995        ((IList<float>)v).RemoveAt(0);
 996        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
 997        ValidateValue(((IList<float>)v).Count, 0);
 998        //Clear
 999        v.Add(one);
1000        v.ClearFlag();
1001        ((IList<float>)v).Clear();
1002        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
1003        ValidateValue(((IList<float>)v).Count, 0);
1004    }
1005
1006    static void TestIVectorIntIMapIntIntMembers()
1007    {
1008        Console.WriteLine(""===  IVectorIntIMapIntInt  ==="");
1009        var v = new IVectorIntIMapIntInt();
1010        //Add
1011        v.ClearFlag();
1012        v.Add(1);
1013        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
1014        ValidateValue((v as IList<int>)[0], 1);
1015        //Contains
1016        v.ClearFlag();
1017        bool b = v.Contains(1);
1018        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
1019        ValidateValue(b, true);
1020        //CopyTo
1021        v.ClearFlag();
1022        int[] arr = new int[10];
1023        v.CopyTo(arr, 0);
1024        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1025        ValidateValue(arr[0], 1);
1026        ValidateValue(arr[1], 0); //there should be nothing there! :)
1027        //'GetEnumerator
1028        //v.ClearFlag()
1029        //Dim count As Integer = v.Count
1030        //Dim enumerator As IEnumerator(Of Integer) = v.GetEnumerator()
1031        //ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First)
1032        //Dim index As Integer = 0
1033        //For Each e In v
1034        //    index = index + 1
1035        //    ValidateValue(e, index)
1036        //Next
1037        //ValidateValue(index, 1) 'there should only be 1 element there
1038        //IndexOf
1039        v.ClearFlag();
1040        var rez = v.IndexOf(1);
1041        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
1042        ValidateValue(rez, 0); // 1 is on the first line :)
1043        //Insert
1044        v.ClearFlag();
1045        v.Insert(1, 2);
1046        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
1047        ValidateValue((v as IList<int>)[1], 2);
1048        //IsReadOnly
1049        v.ClearFlag();
1050        bool isReadOnly = ((IList<int>)v).IsReadOnly;
1051        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
1052        ValidateValue(isReadOnly, false);
1053        //Indexing
1054        v.ClearFlag();
1055        int val = ((int)(v as IList<int>)[0]);
1056        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1057        ValidateValue(val, 1);
1058        v.ClearFlag();
1059        val = ((IList<int>)v)[1];
1060        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1061        ValidateValue(val, 2);
1062        //Remove
1063        v.ClearFlag();
1064        ((IList<int>)v).Remove(1);
1065        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
1066        ValidateValue(((IList<int>)v).Count, 1);
1067        //RemoveAt
1068        v.ClearFlag();
1069        v.RemoveAt(0);
1070        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
1071        ValidateValue(((IList<int>)v).Count, 0);
1072        //Clear
1073        v.Add(1);
1074        v.Add(2);
1075        v.ClearFlag();
1076        ((IList<int>)v).Clear();
1077        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
1078        ValidateValue(((IList<int>)v).Count, 0);
1079        var m = v;
1080        //Add
1081        m.ClearFlag();
1082        m.Add(1, 2);
1083        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
1084        ValidateValue(((IDictionary<int, int>)m).Count, 1);
1085        //ContainsKey
1086        m.ClearFlag();
1087        bool key = m.ContainsKey(1);
1088        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
1089        //Lookup
1090        m.ClearFlag();
1091        int val2 = ((int)(v as IDictionary<int, int>)[1]);
1092        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
1093        ValidateValue(val2, 2);
1094        //Keys
1095        m.ClearFlag();
1096        var keys = m.Keys;
1097        ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
1098        //Values
1099        m.ClearFlag();
1100        var values = m.Values;
1101        ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
1102        //Lookup
1103        m.ClearFlag();
1104        int outVal;
1105        bool success = ((IDictionary<int, int>)m).TryGetValue(1, out outVal);
1106        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
1107        ValidateValue(success, true);
1108        ValidateValue(outVal, 2);
1109        //Add
1110        m.ClearFlag();
1111        m.Add(new KeyValuePair<int, int>(3, 4));
1112        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
1113        ValidateValue(((IDictionary<int, int>)m).Count, 2);
1114        //Contains
1115        m.ClearFlag();
1116        bool contains = m.Contains(new KeyValuePair<int, int>(3, 4));
1117        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
1118        ValidateValue(contains, true);
1119        //non-existant pair
1120        m.ClearFlag();
1121        contains = m.Contains(new KeyValuePair<int, int>(8, 9));
1122        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
1123        ValidateValue(contains, false);
1124        //Remove
1125        m.ClearFlag();
1126        bool remove = ((IDictionary<int, int>)m).Remove(1);
1127        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
1128        ValidateValue(((IDictionary<int, int>)m).Count, 1);
1129        ValidateValue(remove, true);
1130        //CopyTo
1131        //m.ClearFlag()
1132        //Dim arr As KeyValuePair(Of Integer, Integer)()
1133        //ReDim arr(10)
1134        //m.CopyTo(arr, 1)
1135        //ValidateMethod(m.GetFlagState(), TestMethodCalled.IVector_GetAt)
1136        //ValidateValue(arr[0].Value, 2)
1137        //Count
1138        m.ClearFlag();
1139        int count = ((IDictionary<int, int>)m).Count;
1140        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
1141        ValidateValue(count, 1);
1142        //isReadOnly
1143        m.ClearFlag();
1144        isReadOnly = ((IDictionary<int, int>)m).IsReadOnly;
1145        ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
1146        ValidateValue(isReadOnly, false);
1147        //Remove
1148        m.ClearFlag();
1149        var rez2 = m.Remove(new KeyValuePair<int, int>(3, 4));
1150        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
1151        ValidateValue(rez2, true);
1152        m.ClearFlag();
1153        rez2 = m.Remove(new KeyValuePair<int, int>(2, 3));
1154        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
1155        ValidateValue(rez2, false);
1156        m.Add(1, 2);
1157        m.Add(2, 3);
1158        m.ClearFlag();
1159        ((IDictionary<int, int>)m).Clear();
1160        ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Clear);
1161        ValidateValue(((IDictionary<int, int>)m).Count, 0);
1162    }
1163
1164    static void TestIVectorExplicitAddMembers()
1165    {
1166        IVectorExplicitAdd v = new IVectorExplicitAdd();
1167        //Calling the user defined Add method
1168        v.ClearFlag();
1169        ((IMemberAdd)v).Add(1);
1170        ValidateMethod(v.GetFlagState(), TestMethodCalled.UserDef_Add);
1171        v.ClearFlag();
1172        ((IMemberAdd)v).Add(1);
1173        ValidateMethod(v.GetFlagState(), TestMethodCalled.UserDef_Add);
1174        //Calling the Interface Add's method
1175        v.ClearFlag();
1176        ((IList<int>)v).Add(1);
1177        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
1178        ValidateValue(v[0], 1);
1179    }
1180
1181    static void TestIVectorViewMembers()
1182    {
1183        var v = new IVectorViewInt();
1184        v.ClearFlag();
1185        int count = v.Count;
1186        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVectorView_get_Size);
1187    }
1188
1189    static void TestIVectorUIntIVectorViewIntMembers()
1190    {
1191        Console.WriteLine(""===  IVectorUintIVectorViewInt  ==="");
1192        var v = new IVectorUintIVectorViewInt();
1193        //Add
1194        v.ClearFlag();
1195        v.Add(1);
1196        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
1197        ValidateValue((v as IList<uint>)[0], 1);
1198        //Contains
1199        v.ClearFlag();
1200        bool b = v.Contains(1);
1201        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
1202        ValidateValue(b, true);
1203        //CopyTo
1204        v.ClearFlag();
1205        uint[] arr = new uint[10];
1206        v.CopyTo(arr, 0);
1207        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1208        ValidateValue(arr[0], 1);
1209        ValidateValue(arr[1], 0); //there should be nothing there! :)
1210        //GetEnumerator
1211        v.ClearFlag();
1212        uint count = ((uint)(v as IList<uint>).Count);
1213        IEnumerator<uint> enumerator = ((IEnumerable<uint>)v).GetEnumerator();
1214        ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
1215        uint index = 0;
1216        foreach (var e in v)
1217        {
1218            index = ((uint)index + 1);
1219            ValidateValue(e, index);
1220        }
1221
1222        ValidateValue(index, 1); //there should only be 1 element there
1223        //IndexOf
1224        v.ClearFlag();
1225        var rez = v.IndexOf(1);
1226        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
1227        ValidateValue(rez, 0); // 1 is on the first line :)
1228        //Insert
1229        v.ClearFlag();
1230        v.Insert(1, 2);
1231        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
1232        ValidateValue((v as IList<uint>)[1], 2);
1233        //IsReadOnly
1234        v.ClearFlag();
1235        bool isReadOnly = v.IsReadOnly;
1236        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
1237        ValidateValue(isReadOnly, false);
1238        //Indexing
1239        v.ClearFlag();
1240        uint val = (v as IList<uint>)[0];
1241        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1242        ValidateValue(val, 1);
1243        v.ClearFlag();
1244        val = (((IList<uint>)v))[1];
1245        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1246        ValidateValue(val, 2);
1247        //Remove
1248        v.ClearFlag();
1249        v.Remove(1);
1250        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
1251        ValidateValue((v as IList<uint>).Count, 1);
1252        //RemoveAt
1253        v.ClearFlag();
1254        v.RemoveAt(0);
1255        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
1256        ValidateValue((v as IList<uint>).Count, 0);
1257        //Clear
1258        v.Add(1);
1259        v.Add(2);
1260        v.ClearFlag();
1261        v.Clear();
1262        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
1263        ValidateValue((v as IList<uint>).Count, 0);
1264        // IVectorView members
1265        v.Add(1);
1266        v.Add(2);
1267        v.ClearFlag();
1268        ValidateValue(((IReadOnlyList<uint>)v).Count, 2);
1269        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_get_Size);
1270        v.ClearFlag();
1271        ValidateValue(((IReadOnlyList<uint>)v)[0], 1);
1272        ValidateValue(((IReadOnlyList<uint>)v)[1], 2);
1273        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVectorView_GetAt);
1274    }
1275
1276    static void TestIVectorIntIVectorViewUintMembers()
1277    {
1278        Console.WriteLine(""===  IVectorIntIVectorViewUint  ==="");
1279        var v = new IVectorIntIVectorViewUint();
1280        //Add
1281        v.ClearFlag();
1282        v.Add(1);
1283        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
1284        ValidateValue((v as IList<int>)[0], 1);
1285        //Contains
1286        v.ClearFlag();
1287        bool b = v.Contains(1);
1288        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
1289        ValidateValue(b, true);
1290        //CopyTo
1291        v.ClearFlag();
1292        int[] arr = new int[10];
1293        v.CopyTo(arr, 0);
1294        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1295        ValidateValue(arr[0], 1);
1296        ValidateValue(arr[1], 0); //there should be nothing there! :)
1297        //GetEnumerator
1298        v.ClearFlag();
1299        uint count = ((uint)(((IList<int>)v)).Count);
1300        IEnumerator<int> enumerator = (((IList<int>)v)).GetEnumerator();
1301        ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
1302        uint index = 0;
1303        foreach (var e in (((IList<int>)v)))
1304        {
1305            index = ((uint)index + 1);
1306            ValidateValue(e, index);
1307        }
1308
1309        ValidateValue(index, 1); //there should only be 1 element there
1310        //IndexOf
1311        v.ClearFlag();
1312        var rez = v.IndexOf(1);
1313        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
1314        ValidateValue(rez, 0); // 1 is on the first line :)
1315        //Insert
1316        v.ClearFlag();
1317        v.Insert(1, 2);
1318        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
1319        ValidateValue((v as IList<int>)[1], 2);
1320        //IsReadOnly
1321        v.ClearFlag();
1322        bool isReadOnly = v.IsReadOnly;
1323        ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
1324        ValidateValue(isReadOnly, false);
1325        //Indexing
1326        v.ClearFlag();
1327        uint val = ((uint)(v as IList<int>)[0]);
1328        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1329        ValidateValue(val, 1);
1330        v.ClearFlag();
1331        val = ((uint)(((IList<int>)v))[1]);
1332        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1333        ValidateValue(val, 2);
1334        //Remove
1335        v.ClearFlag();
1336        v.Remove(1);
1337        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
1338        ValidateValue((((IList<int>)v)).Count, 1);
1339        //RemoveAt
1340        v.ClearFlag();
1341        v.RemoveAt(0);
1342        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
1343        ValidateValue((((IList<int>)v)).Count, 0);
1344        //Clear
1345        v.Add(1);
1346        v.Add(2);
1347        v.ClearFlag();
1348        v.Clear();
1349        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
1350        ValidateValue((((IList<int>)v)).Count, 0);
1351        // IVectorView members
1352        v.Add(1);
1353        v.Add(2);
1354        v.ClearFlag();
1355        ValidateValue(((IReadOnlyList<uint>)v)[0], 0);
1356        ValidateValue(((IReadOnlyList<uint>)v)[1], 0);
1357        ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
1358    }
1359
1360    static void TestIVectorStructIVectorViewStructMembers()
1361    {
1362        Console.WriteLine(""===  IVectorStructIVectorView…

Large files files are truncated, but you can click here to view the full file