/* Copyright (C) 2004 - 2005  db4objects Inc.  http://www.db4o.com

This file is part of the db4o open source object database.

db4o is free software; you can redistribute it and/or modify it under
the terms of version 2 of the GNU General Public License as published
by the Free Software Foundation and as clarified by db4objects' GPL 
interpretation policy, available at
http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
Suite 350, San Mateo, CA 94403, USA.

db4o is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */
using System;
using j4o.lang;
using j4o.util;
using com.db4o;
using com.db4o.query;
using com.db4o.test.soda;
namespace com.db4o.test.soda.collections {

    public class STHashtableD : STClass {
      
        public STHashtableD() : base() {
        }
        [Transient] public static SodaTest st;
      
        protected System.Collections.Hashtable vec(Object[] objects) {
            System.Collections.Hashtable h1 = new System.Collections.Hashtable();
            for (int i1 = 0; i1 < objects.Length; i1++) {
                h1.Add(objects[i1], i1);
            }
            return h1;
        }
      
        public Object[] store() {
            return new Object[]{
                                   vec(new Object[]{
                                                       5778,
                                                       5779            }),
                                   vec(new Object[]{
                                                       5778,
                                                       5789            }),
                                   vec(new Object[]{
                                                       "foo577",
                                                       new STElement("bar577", "barbar577")            }),
                                   vec(new Object[]{
                                                       "foo5772",
                                                       new STElement("bar577", "barbar2577")            })         };
        }
      
        public void testDefaultContainsInteger() {
            Query q1 = st.query();
            Object[] r1 = store();
            q1.constrain(vec(new Object[]{5778}));
            st.expect(q1, new Object[]{
                                          r1[0],
                                          r1[1]         });
        }
      
        public void testDefaultContainsString() {
            Query q1 = st.query();
            Object[] r1 = store();
            q1.constrain(vec(new Object[]{
                                             "foo577"         }));
            st.expect(q1, new Object[]{
                                          r1[2]         });
        }
      
        public void testDefaultContainsTwo() {
            Query q1 = st.query();
            Object[] r1 = store();
            q1.constrain(vec(new Object[]{
                                             System.Convert.ToInt32(5778),
                                             System.Convert.ToInt32(5789)         }));
            st.expect(q1, new Object[]{
                                          r1[1]         });
        }
      
        public void testDefaultContainsObject() {
            Query q1 = st.query();
            Object[] r1 = store();
            q1.constrain(vec(new Object[]{
                                             new STElement("bar577", null)         }));
            st.expect(q1, new Object[]{
                                          r1[2],
                                          r1[3]         });
        }
    }
}