public void Update_SingleChange_Success() { var expectedUpdateDefinition = new BsonDocument("$set", new BsonDocument("Name", "John Smith")); var model = GetTrackedFlatAggregate(out var trackedModel); model.Name = "John Smith"; var strategy = new DeltaUpdateStrategy <FlatAggregate>(); var writeModel = strategy.GetWriteModelForUpdate(trackedModel); AssertModelEqualsExpectedDefinition(expectedUpdateDefinition, writeModel); }
public void Update_DeltaSubEntityUpdated_Success() { var expectedUpdateDefinition = new BsonDocument("$set", new BsonDocument("DeltaValue.Value", "NewValue")); var model = GetTrackedSubEntityAggregate(out var trackedModel); model.DeltaValue.Value = "NewValue"; var strategy = new DeltaUpdateStrategy <SubEntityAsDeltaAggregate>(); var writeModel = strategy.GetWriteModelForUpdate(trackedModel); AssertModelEqualsExpectedDefinition(expectedUpdateDefinition, writeModel); }
public void Update_DecimalDecrementally_Success() { var expectedUpdateDefinition = new BsonDocument("$inc", new BsonDocument("Decimal", -89.4M)); var model = GetTrackedIncrementNumeralsAggregate(out var trackedModel); model.Decimal -= 89.4M; var strategy = new DeltaUpdateStrategy <IncrementNumeralsAggregate>(); var writeModel = strategy.GetWriteModelForUpdate(trackedModel); AssertModelEqualsExpectedDefinition(expectedUpdateDefinition, writeModel); }
public void Update_LongIncrementally_Success() { var expectedUpdateDefinition = new BsonDocument("$inc", new BsonDocument("Long", 10567)); var model = GetTrackedIncrementNumeralsAggregate(out var trackedModel); model.Long += 10567; var strategy = new DeltaUpdateStrategy <IncrementNumeralsAggregate>(); var writeModel = strategy.GetWriteModelForUpdate(trackedModel); AssertModelEqualsExpectedDefinition(expectedUpdateDefinition, writeModel); }
public void Update_NonDeltaSubEntityValueToNull_Success() { var expectedUpdateDefinition = new BsonDocument("$set", new BsonDocument("NonDeltaValue", BsonNull.Value)); var model = GetTrackedSubEntityAggregate(out var trackedModel); model.NonDeltaValue = null; var strategy = new DeltaUpdateStrategy <SubEntityAsDeltaAggregate>(); var writeModel = strategy.GetWriteModelForUpdate(trackedModel); AssertModelEqualsExpectedDefinition(expectedUpdateDefinition, writeModel); }
public void Update_DoubleDecrementally_Success() { var expectedUpdateDefinition = new BsonDocument("$inc", new BsonDocument("Double", -12.896)); var model = GetTrackedIncrementNumeralsAggregate(out var trackedModel); model.Double -= 12.896; var strategy = new DeltaUpdateStrategy <IncrementNumeralsAggregate>(); var writeModel = strategy.GetWriteModelForUpdate(trackedModel); AssertModelEqualsExpectedDefinition(expectedUpdateDefinition, writeModel, new Dictionary <string, Action <BsonValue, BsonValue> > { { "$inc.Double", (expected, actual) => { Assert.That(actual.AsDouble, Is.EqualTo(expected.AsDouble).Within(0.0000000001)); } } }); }