public async Task Put(T value) { if (Get(value) == null) { await _documentClient.CreateDocumentAsync(GetUri(), ValueObjectDocument <T> .Create(_valueType, value)); } }
private void ShouldReturnValueObject() { var document = ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A")); var value = document.Value; value.Should().Be(new TestValueObject("A")); }
private void ShouldReturnValueObjectType() { var document = ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A")); var type = document.Type; type.Should().Be("TestValueObject"); }
private void ShouldDefaultToNull() { var document = ValueObjectDocument <TestValueObject> .Create("TestValueObject", new TestValueObject("A")); var id = document.Id; id.Should().BeNull(); }
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); }
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"))); }