public void messing_around_with_autoamppers_cloneing_functionality() { var firstChild = new FlatPropertyBag() { IntProperty = 4, StringProperty = "I remember this C#..." }; var secondChild = new FlatPropertyBag() { IntProperty = 5, StringProperty = "deeply nested object initializer nonsense" }; var childList = new List <FlatPropertyBag>() { firstChild, secondChild }; var sample = new DeepPropertyBag() { ChildBags = childList, DeepChild = new DeepPropertyBag() { DeepStringProperty = "Sigh, I wish there were a better way" }, DeepStringProperty = "Newed" }; var clonedViaAutomapper = (DeepPropertyBag)sample.Clone(); clonedViaAutomapper.Should().NotBeNull(); //ahh, so automapper doesnt actually perform a deep copy for me unless I create make maps for each child property type. clonedViaAutomapper.Should().NotBeSameAs(sample); clonedViaAutomapper.DeepChild.Should().NotBeSameAs(sample.DeepChild); clonedViaAutomapper.ChildBags.First().Should().BeSameAs(firstChild); }
public void when_rolling_back() { //setup const string originalValue = "Original!"; var baseObject = new FlatPropertyBag() {StringProperty = originalValue}; var targetSite = baseObject.PropertyInfoFor(x => x.StringProperty).GetSetMethod(); const int targetVersion = 1; var controller = new PropertyBagVersionController<FlatPropertyBag>(baseObject, _testHelper.MakeConfiguredCloneFactoryFor<FlatPropertyBag>(), TestHelper.ChangeSet("Change!", targetSite, targetVersion + 1), _testHelper.MakeConfiguredVisitorFactory(), _testHelper.MakeConfiguredProxyFactory()); //act controller.RollbackTo(targetVersion); //assert A.CallTo(() => _testHelper.ProvidedVisitorFactory.MakeRollbackVisitor(targetVersion)).MustHaveHappened(); A.CallTo(() => _testHelper.ProvidedRollbackVisitor.OnEntry(controller)).MustHaveHappened(); }
public void when_redoing_delta() { //setup const string targetValue = "New Value!"; var baseObject = new FlatPropertyBag() {StringProperty = "Original!"}; var targetSite = baseObject.PropertyInfoFor(x => x.StringProperty).GetSetMethod(); var controller = new PropertyBagVersionController<FlatPropertyBag>(baseObject, _testHelper.MakeConfiguredCloneFactoryFor<FlatPropertyBag>(), TestHelper.ChangeSet(targetValue, targetSite, version: 1, isActive: false), _testHelper.MakeConfiguredVisitorFactory(), _testHelper.MakeConfiguredProxyFactory()); //act controller.RedoLastAssignmentTo(x => x.StringProperty); //assert A.CallTo(() => _testHelper.ProvidedDeltaApplicationVisitor.OnEntry(controller)).MustHaveHappened(); A.CallTo(() => _testHelper.ProvidedVisitorFactory.MakeDeltaApplicationVisitor(ChangeType.Redo, false, targetSite)).MustHaveHappened(); }
private static bool calledWithBaseObjectAndChangeSet(ArgumentCollection args, FlatPropertyBag baseObject, TimestampedPropertyVersionDelta versionDelta) { var correct = args.Get<IVersionControlNode>(ExistingControllerArgumentName).Mutations.Single().Equals(versionDelta); correct &= args.Get<FlatPropertyBag>(ExistingObjectArgumentName).Equals(baseObject); return correct; }