Пример #1
0
        public void PartitionKeyValue_WhenSet_ThenMatchCorrespondingProperty()
        {
            const string partitionKey = "Schlüssel";
            var          item         = new MyCosmosItem {
                Id = "BABEFEED", Key = partitionKey, Value = 42
            };

            Assert.Equal(partitionKey, item.PartitionKeyValue);
        }
Пример #2
0
        public void ShallowCopy_IfCopy_ThenPropertiesAreSame()
        {
            var item = new MyCosmosItem {
                Id = "BABEFEED", Key = "Schlüssel", Value = 42
            };
            MyCosmosItem copy = item.ShallowCopy();

            Assert.Equal(item.Id, copy.Id);
            Assert.Equal(item.Key, copy.Key);
            Assert.Equal(item.Value, copy.Value);
        }
Пример #3
0
        public void ToString_WhenSerialized_ThenJsonIsCorrect()
        {
            var item = new MyCosmosItem {
                Id = "BABEFEED", Key = "Schlüssel", Value = 42
            };
            string  jsonText   = item.ToString();
            JObject jsonObject = JObject.Parse(jsonText);

            Assert.Equal(item.Id, (string)jsonObject["id"]);
            Assert.Equal(item.Key, (string)jsonObject["key"]);
            Assert.Equal(item.Value, (int)jsonObject["value"]);
        }
Пример #4
0
        public void GetHashCode_WhenPropertiesChange_ThenHashAlsoChanges()
        {
            var item = new MyCosmosItem {
                Id = "BABEFEED", Key = "Schlüssel", Value = 42
            };
            int hashCodeBefore = item.GetHashCode();

            item.Value = 696;
            int hashCodeAfter = item.GetHashCode();

            Assert.NotEqual(hashCodeBefore, hashCodeAfter);
        }