Пример #1
0
        public void opEquality_KeyStringPair_KeyStringPair()
        {
            var obj       = new KeyStringPair();
            var comparand = new KeyStringPair();

            Assert.True(obj == comparand);
        }
Пример #2
0
        public void opInequality_KeyStringPair_KeyStringPair()
        {
            var obj       = new KeyStringPair();
            var comparand = new KeyStringPair();

            Assert.False(obj != comparand);
        }
Пример #3
0
        public void op_ToString()
        {
            var expected = "foo{0}---{0}bar".FormatWith(Environment.NewLine);
            var actual   = new KeyStringPair("foo", "bar").ToString();

            Assert.Equal(expected, actual);
        }
Пример #4
0
        public void op_GetHashCode()
        {
            var expected = string.Empty.GetHashCode() ^ string.Empty.GetHashCode();
            var actual   = new KeyStringPair().GetHashCode();

            Assert.Equal(expected, actual);
        }
Пример #5
0
        public void op_GetObjectData_SerializationInfoNull_StreamingContext()
        {
            var context = new StreamingContext(StreamingContextStates.All);

            ISerializable value = new KeyStringPair();

            // ReSharper disable AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => value.GetObjectData(null, context));

            // ReSharper restore AssignNullToNotNullAttribute
        }
Пример #6
0
        public void indexer_int_set_whenAdd()
        {
            var obj = new DataCollection
            {
                {
                    "one", "1"
                }
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => obj[1] = new KeyStringPair("two", "2"));
        }
Пример #7
0
        public void op_GetObjectData_SerializationInfo_StreamingContext()
        {
            var info    = new SerializationInfo(typeof(KeyStringPair), new FormatterConverter());
            var context = new StreamingContext(StreamingContextStates.All);

            ISerializable value = new KeyStringPair("foo", "bar");

            value.GetObjectData(info, context);

            Assert.Equal("foo", info.GetString("_key"));
            Assert.Equal("bar", info.GetString("_value"));
        }
Пример #8
0
        public void ctor_SerializationInfo_StreamingContext()
        {
            var           expected = new KeyStringPair("key", "value");
            KeyStringPair actual;

            using (Stream stream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, new KeyStringPair("key", "value"));
                stream.Position = 0;
                actual          = (KeyStringPair)formatter.Deserialize(stream);
            }

            Assert.Equal(expected, actual);
        }
Пример #9
0
        public void indexer_int_set()
        {
            var obj = new DataCollection
            {
                {
                    "one", "1"
                },
                {
                    "nine", "9"
                }
            };

            obj[1] = new KeyStringPair("two", "2");

            Assert.Equal("two", obj[1].Key);
            Assert.Equal("2", obj[1].Value);
        }
Пример #10
0
        public void op_Equals_KeyStringPair()
        {
            var obj = new KeyStringPair();

            Assert.True(new KeyStringPair().Equals(obj));
        }
Пример #11
0
        public void op_Equals_objectDiffers()
        {
            var obj = new KeyStringPair("key", "value");

            Assert.False(new KeyStringPair().Equals(obj));
        }
Пример #12
0
        public void op_Equals_object()
        {
            object obj = new KeyStringPair();

            Assert.True(new KeyStringPair().Equals(obj));
        }