aboutsummaryrefslogtreecommitdiff
path: root/cs-dotnet/src/tests/lists.cs
blob: 09ad931f5af29bd3722bef7ebe0f3451163ec1d0 (plain)
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
using System;
using System.IO;
using Com.Xagasoft.Gats;

public class Test
{
    public static void Write( GatsObject o, Stream s )
    {
        o.Write( s );
        Console.WriteLine("Wrote: " + o );
    }

    public static void Read( Stream s )
    {
        GatsObject o = GatsObject.Read( s );
        Console.WriteLine("Read type: " + o.GetType() );
        Console.WriteLine("Read vlaue: " + o );
    }

    public static void Main()
    {
        MemoryStream ms = new MemoryStream();
        GatsList l = new GatsList();
        l.Add( new GatsFloat( Math.PI ) );
        l.Add( new GatsInteger( 1337 ) );
        l.Add( new GatsString("Hello") );
        Write( l, ms );
        ms.Seek( 0, SeekOrigin.Begin );
        Read( ms );

        try
        {
            FileStream fs = new FileStream("list.gats", FileMode.Open,
                    FileAccess.Read );
            Read( fs );
        }
        catch( Exception e )
        {
            Console.WriteLine("Can't test files: " + e.Message );
        }
    }
}