Ejemplo n.º 1
0
    public void testMessageGroups()
    {
        Message message = new Message();

        QuickFix42.NewOrderSingle.NoAllocs numAllocs = new QuickFix42.NewOrderSingle.NoAllocs();
        numAllocs.set(new AllocAccount("AllocACC1"));
        numAllocs.set(new AllocShares(1010.10));
        message.addGroup(numAllocs);
        numAllocs.set(new AllocAccount("AllocACC2"));
        numAllocs.set(new AllocShares(2020.20));
        message.addGroup(numAllocs);

        StringField field = null;
        IEnumerator i     = numAllocs.GetEnumerator();

        Assert.IsTrue(i.MoveNext());
        field = (StringField)i.Current;
        Assert.AreEqual("AllocACC2", field.getValue());
        Assert.IsTrue(i.MoveNext());
        field = (StringField)i.Current;
        Assert.AreEqual("2020.2", field.getValue());
        Assert.IsTrue(!i.MoveNext());

        try
        {
            message.getGroup(1, numAllocs);
            Assert.AreEqual("AllocACC1",
                            numAllocs.getField(new AllocAccount()).getValue());
            Assert.IsTrue(1010.10 ==
                          numAllocs.getField(new AllocShares()).getValue());
            message.getGroup(2, numAllocs);
            Assert.AreEqual("AllocACC2",
                            numAllocs.getField(new AllocAccount()).getValue());
            Assert.IsTrue(2020.20 ==
                          numAllocs.getField(new AllocShares()).getValue());
        }
        catch (FieldNotFound e)
        {
            Assert.Fail("no exception should be thrown");
        }

        try
        {
            message.getGroup(3, numAllocs);
            Assert.Fail("exception should be thrown");
        }
        catch (FieldNotFound e) {}
    }
Ejemplo n.º 2
0
    public void testMessageGroups()
    {
        Message message = new Message();
        QuickFix42.NewOrderSingle.NoAllocs numAllocs = new QuickFix42.NewOrderSingle.NoAllocs();
        numAllocs.set( new AllocAccount("AllocACC1") );
        numAllocs.set( new AllocShares(1010.10) );
        message.addGroup(numAllocs);
        numAllocs.set( new AllocAccount("AllocACC2") );
        numAllocs.set( new AllocShares(2020.20) );
        message.addGroup(numAllocs);

        StringField field = null;
        IEnumerator i = numAllocs.GetEnumerator();
        Assert.IsTrue( i.MoveNext() );
        field = (StringField)i.Current;
        Assert.AreEqual( "AllocACC2", field.getValue() );
        Assert.IsTrue( i.MoveNext() );
        field = (StringField)i.Current;
        Assert.AreEqual( "2020.2", field.getValue() );
        Assert.IsTrue( !i.MoveNext() );

        try
        {
          message.getGroup( 1, numAllocs );
          Assert.AreEqual( "AllocACC1",
                       numAllocs.getField( new AllocAccount() ).getValue() );
          Assert.IsTrue( 1010.10 ==
                     numAllocs.getField( new AllocShares() ).getValue() );
          message.getGroup( 2, numAllocs );
          Assert.AreEqual( "AllocACC2",
                       numAllocs.getField( new AllocAccount() ).getValue() );
          Assert.IsTrue( 2020.20 ==
                     numAllocs.getField( new AllocShares() ).getValue() );
        }
        catch( FieldNotFound )
        {
          Assert.Fail( "no exception should be thrown" );
        }

        try
        {
          message.getGroup( 3, numAllocs );
          Assert.Fail( "exception should be thrown" );
        }
        catch( FieldNotFound ) {}
    }