示例#1
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestSerializeAndDeserializeNull()
        {
            bool gotException = false;

            try
            {
                new EnumSetWritable <TestEnumSetWritable.TestEnumSet>(null);
            }
            catch (RuntimeException)
            {
                gotException = true;
            }
            Assert.True("Instantiation of empty EnumSetWritable with no element type class "
                        + "provided should throw exception", gotException);
            EnumSetWritable <TestEnumSetWritable.TestEnumSet> nullFlagWritable = new EnumSetWritable
                                                                                 <TestEnumSetWritable.TestEnumSet>(null, typeof(TestEnumSetWritable.TestEnumSet));
            DataOutputBuffer @out = new DataOutputBuffer();

            ObjectWritable.WriteObject(@out, nullFlagWritable, nullFlagWritable.GetType(), null
                                       );
            DataInputBuffer @in = new DataInputBuffer();

            @in.Reset(@out.GetData(), @out.GetLength());
            EnumSet <TestEnumSetWritable.TestEnumSet> read = ((EnumSetWritable <TestEnumSetWritable.TestEnumSet
                                                                                >)ObjectWritable.ReadObject(@in, null)).Get();

            Assert.Equal(read, null);
        }
示例#2
0
        /// <summary>
        /// test
        /// <see cref="EnumSetWritable{E}"/>
        /// equals() method
        /// </summary>
        public virtual void TestEnumSetWritableEquals()
        {
            EnumSetWritable <TestEnumSetWritable.TestEnumSet> eset1 = new EnumSetWritable <TestEnumSetWritable.TestEnumSet
                                                                                           >(EnumSet.Of(TestEnumSetWritable.TestEnumSet.Append, TestEnumSetWritable.TestEnumSet
                                                                                                        .Create), typeof(TestEnumSetWritable.TestEnumSet));
            EnumSetWritable <TestEnumSetWritable.TestEnumSet> eset2 = new EnumSetWritable <TestEnumSetWritable.TestEnumSet
                                                                                           >(EnumSet.Of(TestEnumSetWritable.TestEnumSet.Append, TestEnumSetWritable.TestEnumSet
                                                                                                        .Create), typeof(TestEnumSetWritable.TestEnumSet));

            Assert.True("testEnumSetWritableEquals error !!!", eset1.Equals
                            (eset2));
            NUnit.Framework.Assert.IsFalse("testEnumSetWritableEquals error !!!", eset1.Equals
                                               (new EnumSetWritable <TestEnumSetWritable.TestEnumSet>(EnumSet.Of(TestEnumSetWritable.TestEnumSet
                                                                                                                 .Append, TestEnumSetWritable.TestEnumSet.Create, TestEnumSetWritable.TestEnumSet
                                                                                                                 .Overwrite), typeof(TestEnumSetWritable.TestEnumSet))));
            Assert.True("testEnumSetWritableEquals getElementType error !!!"
                        , eset1.GetElementType().Equals(typeof(TestEnumSetWritable.TestEnumSet)));
        }
示例#3
0
        /// <summary>
        /// test
        /// <c>EnumSetWritable.write(DataOutputBuffer out)</c>
        ///
        /// and iteration by TestEnumSet through iterator().
        /// </summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestEnumSetWritableWriteRead()
        {
            EnumSetWritable <TestEnumSetWritable.TestEnumSet> srcSet = new EnumSetWritable <TestEnumSetWritable.TestEnumSet
                                                                                            >(EnumSet.Of(TestEnumSetWritable.TestEnumSet.Append, TestEnumSetWritable.TestEnumSet
                                                                                                         .Create), typeof(TestEnumSetWritable.TestEnumSet));
            DataOutputBuffer @out = new DataOutputBuffer();

            srcSet.Write(@out);
            EnumSetWritable <TestEnumSetWritable.TestEnumSet> dstSet = new EnumSetWritable <TestEnumSetWritable.TestEnumSet
                                                                                            >();
            DataInputBuffer @in = new DataInputBuffer();

            @in.Reset(@out.GetData(), @out.GetLength());
            dstSet.ReadFields(@in);
            EnumSet <TestEnumSetWritable.TestEnumSet>     result  = dstSet.Get();
            IEnumerator <TestEnumSetWritable.TestEnumSet> dstIter = result.GetEnumerator();
            IEnumerator <TestEnumSetWritable.TestEnumSet> srcIter = srcSet.GetEnumerator();

            while (dstIter.HasNext() && srcIter.HasNext())
            {
                Assert.Equal("testEnumSetWritableWriteRead error !!!", dstIter
                             .Next(), srcIter.Next());
            }
        }
示例#4
0
 public TestEnumSetWritable()
 {
     nonEmptyFlagWritable = new EnumSetWritable <TestEnumSetWritable.TestEnumSet>(nonEmptyFlag
                                                                                  );
 }