コード例 #1
0
 public async Task Put(T value)
 {
     if (Get(value) == null)
     {
         await _documentClient.CreateDocumentAsync(GetUri(), ValueObjectDocument <T> .Create(_valueType, value));
     }
 }
コード例 #2
0
            private void ShouldReturnValueObject()
            {
                var document = ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A"));

                var value = document.Value;

                value.Should().Be(new TestValueObject("A"));
            }
コード例 #3
0
            private void ShouldReturnValueObjectType()
            {
                var document = ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A"));

                var type = document.Type;

                type.Should().Be("TestValueObject");
            }
コード例 #4
0
            private void ShouldDefaultToNull()
            {
                var document = ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A"));

                var id = document.Id;

                id.Should().BeNull();
            }
コード例 #5
0
            private void ShouldSerialiseAsJson()
            {
                var document = ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A"));

                var serialised = JsonConvert.SerializeObject(document);

                JsonConvert.DeserializeObject <ValueObjectDocument <TestValueObject> >(serialised)
                .Should()
                .BeEquivalentTo(document);
            }
コード例 #6
0
            private void ShouldDeserialiseFromJson()
            {
                const string json = @"{""Type"":""TestValueObject"",""ValueObject"":{""Name"":""A""}}";

                var document = JsonConvert.DeserializeObject <ValueObjectDocument <TestValueObject> >(json);

                document
                .Should()
                .BeEquivalentTo(
                    ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A")));
            }