Esempio n. 1
0
        public void equals_returns_true_if_record_values_are_equal_even_if_read_only_flag_differs()
        {
            var record1 = new ConcreteRecordBase("first", "second", "third");
            var record2 = new ConcreteRecordBase(true, "first", "second", "third");

            Assert.True(record1.Equals(record2));
        }
Esempio n. 2
0
        public void constructor_can_be_instructed_to_make_values_read_only()
        {
            var record = new ConcreteRecordBase(true, "value1", "value2", "value3", "value4");

            Assert.True(record.IsReadOnly);
            Assert.Throws <NotSupportedException>(() => record[0] = "new");
        }
Esempio n. 3
0
        public void get_hash_code_returns_same_hash_for_equal_records()
        {
            var record1 = new ConcreteRecordBase("first", "second", "third");
            var record2 = new ConcreteRecordBase("first", "second", "third");

            Assert.Equal(record1.GetHashCode(), record2.GetHashCode());
        }
Esempio n. 4
0
        public void contains_returns_true_if_value_is_in_record()
        {
            var record = new ConcreteRecordBase("one", "two");

            Assert.True(record.Contains("one"));
            Assert.True(record.Contains("two"));
        }
Esempio n. 5
0
        public void remove_returns_false_if_value_not_removed()
        {
            var record = new ConcreteRecordBase("one", "two", "three");

            Assert.False(record.Remove("four"));
            Assert.False(record.Remove("One"));
        }
Esempio n. 6
0
        public void insert_throws_if_index_is_invalid()
        {
            var record = new ConcreteRecordBase();

            Assert.Throws <ArgumentOutOfRangeException>(() => record.Insert(-1, "one"));
            Assert.Throws <ArgumentOutOfRangeException>(() => record.Insert(10, "one"));
        }
Esempio n. 7
0
        public void indexer_get_throws_if_index_is_negative()
        {
            string ignore;
            var    record = new ConcreteRecordBase();

            Assert.Throws <ArgumentOutOfRangeException>(() => ignore = record[-1]);
        }
Esempio n. 8
0
        public void remove_at_throws_if_index_is_invalid()
        {
            var record = new ConcreteRecordBase();

            Assert.Throws <ArgumentOutOfRangeException>(() => record.RemoveAt(-1));
            Assert.Throws <ArgumentOutOfRangeException>(() => record.RemoveAt(0));
        }
Esempio n. 9
0
        public void equals_returns_true_if_record_values_are_equal()
        {
            var record1 = new ConcreteRecordBase("first", "second", "third");
            var record2 = new ConcreteRecordBase("first", "second", "third");

            Assert.True(record1.Equals(record2));
        }
Esempio n. 10
0
        public void equals_returns_false_if_record_values_differ()
        {
            var record1 = new ConcreteRecordBase("first", "second");
            var record2 = new ConcreteRecordBase("first", "2nd");

            Assert.False(record1.Equals(record2));
        }
Esempio n. 11
0
        public void get_value_or_null_returns_null_if_index_is_invalid()
        {
            var record = new ConcreteRecordBase();

            Assert.Null(record.GetValueOrNull(-1));
            Assert.Null(record.GetValueOrNull(1));
            Assert.Null(record.GetValueOrNull(10));
        }
Esempio n. 12
0
        public void clear_removes_all_values()
        {
            var record = new ConcreteRecordBase(new string[] { "one", "two" }.ToList());

            Assert.Equal(2, record.Count);
            record.Clear();
            Assert.Equal(0, record.Count);
        }
Esempio n. 13
0
        public void contains_returns_false_if_value_is_not_in_record()
        {
            var record = new ConcreteRecordBase("one", "two");

            Assert.False(record.Contains("three"));
            Assert.False(record.Contains("ONE"));
            Assert.False(record.Contains("Two"));
        }
Esempio n. 14
0
 public void indexer_get_retrieves_value_for_given_index()
 {
     var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");
     Assert.Equal("value1", record[0]);
     Assert.Equal("value2", record[1]);
     Assert.Equal("value3", record[2]);
     Assert.Equal("value4", record[3]);
 }
Esempio n. 15
0
        public void index_of_returns_index_if_value_is_in_record()
        {
            var record = new ConcreteRecordBase("one", "two", "three");

            Assert.Equal(0, record.IndexOf("one"));
            Assert.Equal(1, record.IndexOf("two"));
            Assert.Equal(2, record.IndexOf("three"));
        }
Esempio n. 16
0
        public void remove_returns_true_if_value_is_removed()
        {
            var record = new ConcreteRecordBase("one", "two", "three");

            Assert.True(record.Remove("one"));
            Assert.True(record.Remove("two"));
            Assert.True(record.Remove("three"));
        }
Esempio n. 17
0
        public void index_of_returns_negative_one_if_value_is_not_in_record()
        {
            var record = new ConcreteRecordBase("one", "two");

            Assert.Equal(-1, record.IndexOf("three"));
            Assert.Equal(-1, record.IndexOf("ONE"));
            Assert.Equal(-1, record.IndexOf("Two"));
        }
Esempio n. 18
0
        public void contains_returns_false_if_value_is_not_in_record()
        {
            var record = new ConcreteRecordBase("one", "two");

            Assert.DoesNotContain("three", record);
            Assert.DoesNotContain("ONE", record);
            Assert.DoesNotContain("Two", record);
        }
Esempio n. 19
0
 public void constructor_assigns_given_values()
 {
     var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");
     Assert.Equal(4, record.Count);
     Assert.Equal("value1", record[0]);
     Assert.Equal("value2", record[1]);
     Assert.Equal("value3", record[2]);
     Assert.Equal("value4", record[3]);
 }
Esempio n. 20
0
        public void remove_removes_value()
        {
            var record = new ConcreteRecordBase("one", "two", "three");

            Assert.True(record.Contains("one"));
            record.Remove("one");
            Assert.False(record.Contains("one"));
            Assert.Equal(2, record.Count);
        }
Esempio n. 21
0
        public void indexer_get_retrieves_value_for_given_index()
        {
            var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");

            Assert.Equal("value1", record[0]);
            Assert.Equal("value2", record[1]);
            Assert.Equal("value3", record[2]);
            Assert.Equal("value4", record[3]);
        }
Esempio n. 22
0
        public void get_value_or_null_returns_value_if_index_is_valid()
        {
            var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");

            Assert.Equal("value1", record.GetValueOrNull(0));
            Assert.Equal("value2", record.GetValueOrNull(1));
            Assert.Equal("value3", record.GetValueOrNull(2));
            Assert.Equal("value4", record.GetValueOrNull(3));
        }
Esempio n. 23
0
        public void copy_to_copies_values_to_array()
        {
            var record = new ConcreteRecordBase("one", "two", "three");
            var array  = new string[record.Count];

            record.CopyTo(array, 0);
            Assert.Equal("one", array[0]);
            Assert.Equal("two", array[1]);
            Assert.Equal("three", array[2]);
        }
Esempio n. 24
0
        public void constructor_assigns_given_values()
        {
            var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");

            Assert.Equal(4, record.Count);
            Assert.Equal("value1", record[0]);
            Assert.Equal("value2", record[1]);
            Assert.Equal("value3", record[2]);
            Assert.Equal("value4", record[3]);
        }
Esempio n. 25
0
        public void count_returns_number_of_values()
        {
            var record1 = new ConcreteRecordBase("one", "two");

            Assert.Equal(2, record1.Count);

            var record2 = new ConcreteRecordBase(new string[] { "one", "two" }.ToList());

            record2.Add("three");
            Assert.Equal(3, record2.Count);
        }
Esempio n. 26
0
        public void to_string_returns_a_useful_debug_representation_of_the_record()
        {
            var separator = (char)0x2022;
            var record    = new ConcreteRecordBase("value1", "value2", "value3", "value4");

            Assert.Equal(string.Format("value1{0}value2{0}value3{0}value4{0}", separator), record.ToString());
            record[1] += " ";
            Assert.Equal(string.Format("value1{0}value2 {0}value3{0}value4{0}", separator), record.ToString());
            record.Add("a new value");
            Assert.Equal(string.Format("value1{0}value2 {0}value3{0}value4{0}a new value{0}", separator), record.ToString());
        }
Esempio n. 27
0
 public void indexer_set_assigns_value_for_given_index()
 {
     var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");
     record[0] += "Altered";
     record[1] += "Altered";
     record[2] += "Altered";
     record[3] += "Altered";
     Assert.Equal("value1Altered", record[0]);
     Assert.Equal("value2Altered", record[1]);
     Assert.Equal("value3Altered", record[2]);
     Assert.Equal("value4Altered", record[3]);
 }
Esempio n. 28
0
        public void add_adds_specified_value()
        {
            var record = new ConcreteRecordBase();

            record.Add("one");
            Assert.Equal(1, record.Count);
            Assert.True(record.Contains("one"));

            record.Add("two");
            Assert.Equal(2, record.Count);
            Assert.True(record.Contains("two"));
        }
Esempio n. 29
0
        public void insert_inserts_value_at_specified_index()
        {
            var record = new ConcreteRecordBase("two", "four");

            record.Insert(1, "three");
            record.Insert(0, "one");
            Assert.Equal(4, record.Count);
            Assert.Equal("one", record[0]);
            Assert.Equal("two", record[1]);
            Assert.Equal("three", record[2]);
            Assert.Equal("four", record[3]);
        }
Esempio n. 30
0
        public void indexer_set_assigns_value_for_given_index()
        {
            var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");

            record[0] += "Altered";
            record[1] += "Altered";
            record[2] += "Altered";
            record[3] += "Altered";
            Assert.Equal("value1Altered", record[0]);
            Assert.Equal("value2Altered", record[1]);
            Assert.Equal("value3Altered", record[2]);
            Assert.Equal("value4Altered", record[3]);
        }
Esempio n. 31
0
        public void record_is_enumerable()
        {
            var record = new ConcreteRecordBase("first", "second", "third");
            var values = new List <string>();

            foreach (var value in record)
            {
                values.Add(value);
            }

            Assert.Equal(3, values.Count);
            Assert.True(values.Contains("first"));
            Assert.True(values.Contains("second"));
            Assert.True(values.Contains("third"));
        }
Esempio n. 32
0
 public void indexer_set_throws_if_read_only()
 {
     var record = new ConcreteRecordBase(true, "one", "two");
     Assert.Throws<NotSupportedException>(() => record[0] = "test");
 }
Esempio n. 33
0
 public void equals_returns_false_if_record_values_differ()
 {
     var record1 = new ConcreteRecordBase("first", "second");
     var record2 = new ConcreteRecordBase("first", "2nd");
     Assert.False(record1.Equals(record2));
 }
Esempio n. 34
0
        public void get_hash_code_returns_same_hash_for_equal_records()
        {
            var record1 = new ConcreteRecordBase("first", "second", "third");
            var record2 = new ConcreteRecordBase("first", "second", "third");

            Assert.Equal(record1.GetHashCode(), record2.GetHashCode());
        }
Esempio n. 35
0
 public void to_string_returns_a_useful_debug_representation_of_the_record()
 {
     var separator = (char)0x2022;
     var record = new ConcreteRecordBase("value1", "value2", "value3", "value4");
     Assert.Equal(string.Format("value1{0}value2{0}value3{0}value4{0}", separator), record.ToString());
     record[1] += " ";
     Assert.Equal(string.Format("value1{0}value2 {0}value3{0}value4{0}", separator), record.ToString());
     record.Add("a new value");
     Assert.Equal(string.Format("value1{0}value2 {0}value3{0}value4{0}a new value{0}", separator), record.ToString());
 }
Esempio n. 36
0
 public void constructor_can_be_instructed_to_make_values_read_only()
 {
     var record = new ConcreteRecordBase(true, "value1", "value2", "value3", "value4");
     Assert.True(record.IsReadOnly);
     Assert.Throws<NotSupportedException>(() => record[0] = "new");
 }
Esempio n. 37
0
        public void add_adds_specified_value()
        {
            var record = new ConcreteRecordBase();

            record.Add("one");
            Assert.Equal(1, record.Count);
            Assert.True(record.Contains("one"));

            record.Add("two");
            Assert.Equal(2, record.Count);
            Assert.True(record.Contains("two"));
        }
Esempio n. 38
0
 public void insert_throws_if_read_only()
 {
     var record = new ConcreteRecordBase(true);
     Assert.Throws<NotSupportedException>(() => record.Insert(0, "one"));
 }
Esempio n. 39
0
        public void indexer_set_throws_if_value_is_null()
        {
            var record = new ConcreteRecordBase("one", "two");

            Assert.Throws <ArgumentNullException>(() => record[0] = null);
        }
Esempio n. 40
0
 public void remove_at_throws_if_read_only()
 {
     var record = new ConcreteRecordBase(true, "one");
     Assert.Throws<NotSupportedException>(() => record.RemoveAt(0));
 }
Esempio n. 41
0
 public void indexer_set_throws_if_value_is_null()
 {
     var record = new ConcreteRecordBase("one", "two");
     Assert.Throws<ArgumentNullException>(() => record[0] = null);
 }
Esempio n. 42
0
 public void is_read_only_returns_false_if_not_read_only()
 {
     var record = new ConcreteRecordBase();
     Assert.False(record.IsReadOnly);
 }
Esempio n. 43
0
 public void copy_to_copies_values_to_array()
 {
     var record = new ConcreteRecordBase("one", "two", "three");
     var array = new string[record.Count];
     record.CopyTo(array, 0);
     Assert.Equal("one", array[0]);
     Assert.Equal("two", array[1]);
     Assert.Equal("three", array[2]);
 }
Esempio n. 44
0
 public void equals_returns_false_if_compared_to_null()
 {
     var record = new ConcreteRecordBase();
     Assert.False(record.Equals(null));
 }
Esempio n. 45
0
 public void equals_returns_true_if_compared_to_self()
 {
     var record = new ConcreteRecordBase();
     Assert.True(record.Equals(record));
 }
Esempio n. 46
0
 public void insert_throws_if_value_is_null()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentNullException>(() => record.Insert(0, null));
 }
Esempio n. 47
0
 public void indexer_set_throws_if_index_is_invalid()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentOutOfRangeException>(() => record[12] = "test");
 }
Esempio n. 48
0
 public void equals_returns_true_if_record_values_are_equal_even_if_read_only_flag_differs()
 {
     var record1 = new ConcreteRecordBase("first", "second", "third");
     var record2 = new ConcreteRecordBase(true, "first", "second", "third");
     Assert.True(record1.Equals(record2));
 }
Esempio n. 49
0
 public void insert_throws_if_index_is_invalid()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentOutOfRangeException>(() => record.Insert(-1, "one"));
     Assert.Throws<ArgumentOutOfRangeException>(() => record.Insert(10, "one"));
 }
Esempio n. 50
0
        public void remove_removes_value()
        {
            var record = new ConcreteRecordBase("one", "two", "three");

            Assert.True(record.Contains("one"));
            record.Remove("one");
            Assert.False(record.Contains("one"));
            Assert.Equal(2, record.Count);
        }
Esempio n. 51
0
 public void equals_returns_true_if_record_values_are_equal()
 {
     var record1 = new ConcreteRecordBase("first", "second", "third");
     var record2 = new ConcreteRecordBase("first", "second", "third");
     Assert.True(record1.Equals(record2));
 }
Esempio n. 52
0
 public void remove_returns_true_if_value_is_removed()
 {
     var record = new ConcreteRecordBase("one", "two", "three");
     Assert.True(record.Remove("one"));
     Assert.True(record.Remove("two"));
     Assert.True(record.Remove("three"));
 }
Esempio n. 53
0
        public void record_is_enumerable()
        {
            var record = new ConcreteRecordBase("first", "second", "third");
            var values = new List<string>();

            foreach (var value in record)
            {
                values.Add(value);
            }

            Assert.Equal(3, values.Count);
            Assert.True(values.Contains("first"));
            Assert.True(values.Contains("second"));
            Assert.True(values.Contains("third"));
        }
Esempio n. 54
0
 public void remove_returns_false_if_value_not_removed()
 {
     var record = new ConcreteRecordBase("one", "two", "three");
     Assert.False(record.Remove("four"));
     Assert.False(record.Remove("One"));
 }
Esempio n. 55
0
 public void remove_throws_if_value_is_null()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentNullException>(() => record.Remove(null));
 }
Esempio n. 56
0
 public void insert_inserts_value_at_specified_index()
 {
     var record = new ConcreteRecordBase("two", "four");
     record.Insert(1, "three");
     record.Insert(0, "one");
     Assert.Equal(4, record.Count);
     Assert.Equal("one", record[0]);
     Assert.Equal("two", record[1]);
     Assert.Equal("three", record[2]);
     Assert.Equal("four", record[3]);
 }
Esempio n. 57
0
        public void indexer_set_throws_if_read_only()
        {
            var record = new ConcreteRecordBase(true, "one", "two");

            Assert.Throws <NotSupportedException>(() => record[0] = "test");
        }
Esempio n. 58
0
 public void index_of_returns_index_if_value_is_in_record()
 {
     var record = new ConcreteRecordBase("one", "two", "three");
     Assert.Equal(0, record.IndexOf("one"));
     Assert.Equal(1, record.IndexOf("two"));
     Assert.Equal(2, record.IndexOf("three"));
 }
Esempio n. 59
0
 public void remove_at_throws_if_index_is_invalid()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentOutOfRangeException>(() => record.RemoveAt(-1));
     Assert.Throws<ArgumentOutOfRangeException>(() => record.RemoveAt(0));
 }
Esempio n. 60
0
 public void indexer_get_throws_if_index_is_invalid()
 {
     string ignore;
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentOutOfRangeException>(() => ignore = record[12]);
 }