Exemplo 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));
        }
Exemplo 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");
        }
Exemplo 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());
        }
Exemplo 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"));
        }
Exemplo 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"));
        }
Exemplo 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"));
        }
Exemplo n.º 7
0
        public void indexer_get_throws_if_index_is_negative()
        {
            string ignore;
            var    record = new ConcreteRecordBase();

            Assert.Throws <ArgumentOutOfRangeException>(() => ignore = record[-1]);
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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"));
        }
Exemplo 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]);
 }
Exemplo 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"));
        }
Exemplo 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"));
        }
Exemplo 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"));
        }
Exemplo 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);
        }
Exemplo 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]);
 }
Exemplo 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);
        }
Exemplo 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]);
        }
Exemplo 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));
        }
Exemplo 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]);
        }
Exemplo 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]);
        }
Exemplo 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);
        }
Exemplo 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());
        }
Exemplo 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]);
 }
Exemplo 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"));
        }
Exemplo 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]);
        }
Exemplo 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]);
        }
Exemplo 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"));
        }
Exemplo n.º 32
0
 public void indexer_set_throws_if_read_only()
 {
     var record = new ConcreteRecordBase(true, "one", "two");
     Assert.Throws<NotSupportedException>(() => record[0] = "test");
 }
Exemplo 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));
 }
Exemplo 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());
        }
Exemplo 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());
 }
Exemplo 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");
 }
Exemplo 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"));
        }
Exemplo n.º 38
0
 public void insert_throws_if_read_only()
 {
     var record = new ConcreteRecordBase(true);
     Assert.Throws<NotSupportedException>(() => record.Insert(0, "one"));
 }
Exemplo n.º 39
0
        public void indexer_set_throws_if_value_is_null()
        {
            var record = new ConcreteRecordBase("one", "two");

            Assert.Throws <ArgumentNullException>(() => record[0] = null);
        }
Exemplo n.º 40
0
 public void remove_at_throws_if_read_only()
 {
     var record = new ConcreteRecordBase(true, "one");
     Assert.Throws<NotSupportedException>(() => record.RemoveAt(0));
 }
Exemplo n.º 41
0
 public void indexer_set_throws_if_value_is_null()
 {
     var record = new ConcreteRecordBase("one", "two");
     Assert.Throws<ArgumentNullException>(() => record[0] = null);
 }
Exemplo n.º 42
0
 public void is_read_only_returns_false_if_not_read_only()
 {
     var record = new ConcreteRecordBase();
     Assert.False(record.IsReadOnly);
 }
Exemplo 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]);
 }
Exemplo n.º 44
0
 public void equals_returns_false_if_compared_to_null()
 {
     var record = new ConcreteRecordBase();
     Assert.False(record.Equals(null));
 }
Exemplo n.º 45
0
 public void equals_returns_true_if_compared_to_self()
 {
     var record = new ConcreteRecordBase();
     Assert.True(record.Equals(record));
 }
Exemplo n.º 46
0
 public void insert_throws_if_value_is_null()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentNullException>(() => record.Insert(0, null));
 }
Exemplo n.º 47
0
 public void indexer_set_throws_if_index_is_invalid()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentOutOfRangeException>(() => record[12] = "test");
 }
Exemplo 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));
 }
Exemplo 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"));
 }
Exemplo 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);
        }
Exemplo 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));
 }
Exemplo 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"));
 }
Exemplo 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"));
        }
Exemplo 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"));
 }
Exemplo n.º 55
0
 public void remove_throws_if_value_is_null()
 {
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentNullException>(() => record.Remove(null));
 }
Exemplo 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]);
 }
Exemplo n.º 57
0
        public void indexer_set_throws_if_read_only()
        {
            var record = new ConcreteRecordBase(true, "one", "two");

            Assert.Throws <NotSupportedException>(() => record[0] = "test");
        }
Exemplo 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"));
 }
Exemplo 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));
 }
Exemplo n.º 60
0
 public void indexer_get_throws_if_index_is_invalid()
 {
     string ignore;
     var record = new ConcreteRecordBase();
     Assert.Throws<ArgumentOutOfRangeException>(() => ignore = record[12]);
 }