コード例 #1
0
        public void CanSetupTreeStructureWithUpdates()
        {
            string document = ComplexObject
                              .Create()
                              .WithId(SetTo.Value("ID123"))
                              .WithItems(
                item => item
                .WithId(SetTo.Value("ARandomGuid"))
                .WithTags(
                    tag1 => tag1
                    .WithKey(SetTo.Value("Importance"))
                    .WithValue(SetTo.Value("High")),
                    tag2 => tag2
                    .WithKey(SetTo.Value("Level"))
                    .WithValue(SetTo.Null),
                    tag3 => tag3
                    .WithKey(SetTo.Value("Games"))
                    .WithValue(SetTo.Null)))
                              .WithName(SetTo.Value("Test"))
                              .UpdateExistingTagAtIndex(0,
                                                        item => item
                                                        .UpdateExistingTagAtIndex(1, tag => tag.WithValue(SetTo.Value("Medium")))
                                                        .WithTags(Updated.ByRemovingAtIndex(0)));

            Assert.Equal(
                @"{""id"":""ID123"",""items"":[{""id"":""ARandomGuid"",""tags"":[{""key"":""Level"",""value"":""Medium""},{""key"":""Games"",""value"":null}]}],""name"":""Test""}",
                document);
        }
コード例 #2
0
        public void SerializeComplexObject()
        {
            var c = ComplexObject.Create();

            Assert.True(ComplexObject.IsSame(c));

            var s = VPack.Serialize(c);
            var d = VPack.Deserialize <ComplexObject>(s);

            Assert.True(ComplexObject.IsSame(d));
        }
コード例 #3
0
    public void Get_ComplexObject_ReturnedObjectIsIdentical(CosmosCache.InsertMode mode)
    {
        // Arrange
        var cache = CreateCache <ComplexObject>(mode);

        var value = ComplexObject.Create();

        cache.Set(new CacheItem <ComplexObject>(CacheKey, value, TimeSpan.FromSeconds(5)));

        // Act
        var result = cache.Get(CacheKey);

        // Assert
        Assert.False(object.ReferenceEquals(result, value));
        Assert.Equal(result, value);
    }
コード例 #4
0
        public void CanCreateComplexObject()
        {
            string document = ComplexObject.Create();

            Assert.Equal("{}", document);
        }