Created
December 18, 2013 00:46
-
-
Save kijanawoodard/8015509 to your computer and use it in GitHub Desktop.
Patch document containing long value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Raven.Abstractions.Data; | |
using Raven.Tests.Helpers; | |
using System; | |
using Xunit; | |
namespace ClassLibrary1 | |
{ | |
public class SomeTest : RavenTestBase | |
{ | |
[Fact] | |
public void TestPatch() | |
{ | |
const long value = Int64.MaxValue - int.MaxValue; | |
using (var store = NewDocumentStore()) | |
{ | |
using (var session = store.OpenSession()) | |
{ | |
var foo = new Foo { Id = "foos/1", Bar = value, Baz = "hello" }; | |
session.Store(foo); | |
session.SaveChanges(); | |
} | |
store.DatabaseCommands.Patch( | |
"foos/1", | |
new[] | |
{ | |
new PatchRequest | |
{ | |
Type = PatchCommandType.Set, | |
Name = "Baz", | |
Value = "world" | |
} | |
}); | |
using (var session = store.OpenSession()) | |
{ | |
var foo = session.Load<Foo>("foos/1"); | |
Assert.Equal("world", foo.Baz); | |
Assert.Equal(value, foo.Bar); | |
} | |
store.DatabaseCommands.Patch( | |
"foos/1", | |
new ScriptedPatchRequest() | |
{ | |
Script = @"this.Baz = 'there'" | |
}); | |
using (var session = store.OpenSession()) | |
{ | |
var foo = session.Load<Foo>("foos/1"); | |
Assert.Equal("there", foo.Baz); | |
Assert.Equal(value, foo.Bar); | |
} | |
} | |
} | |
public class Foo | |
{ | |
public string Id { get; set; } | |
public long Bar { get; set; } | |
public string Baz { get; set; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment