public void ProviderShouldTrackPropertyChanges() { IEntityStateManager manager = GetStateManager(); var stateModel = GetModel(); var snapshot = manager.CreateSnapshot(stateModel); snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.Guid)).ShouldBeFalse(); snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.String)).ShouldBeFalse(); snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.Int)).ShouldBeFalse(); stateModel.Int = int.MaxValue; stateModel.String = null; stateModel.Guid = Guid.Empty; snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.Guid)).ShouldBeTrue(); snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.String)).ShouldBeTrue(); snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.Int)).ShouldBeTrue(); stateModel.Int = IntValue; stateModel.String = StringValue; stateModel.Guid = GuidValue; snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.Guid)).ShouldBeFalse(); snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.String)).ShouldBeFalse(); snapshot.HasChanges(stateModel, ToolkitExtensions.GetMemberName <EntityStateModel>(() => model => model.Int)).ShouldBeFalse(); }
public void ProviderShouldSaveAndApplyState() { IEntityStateManager manager = GetStateManager(); var stateModel = GetModel(); manager.CreateSnapshot(stateModel); stateModel.Int = int.MaxValue; stateModel.String = null; stateModel.Guid = Guid.Empty; stateModel.Guid.ShouldEqual(Guid.Empty); stateModel.String.ShouldBeNull(); stateModel.Int.ShouldEqual(int.MaxValue); }
public void ProviderShouldTrackObjectChanges() { IEntityStateManager manager = GetStateManager(); var stateModel = GetModel(); var snapshot = manager.CreateSnapshot(stateModel); snapshot.HasChanges(stateModel).ShouldBeFalse(); stateModel.Int = int.MaxValue; snapshot.HasChanges(stateModel).ShouldBeTrue(); stateModel.Int = IntValue; snapshot.HasChanges(stateModel).ShouldBeFalse(); stateModel.String = null; snapshot.HasChanges(stateModel).ShouldBeTrue(); stateModel.String = StringValue; snapshot.HasChanges(stateModel).ShouldBeFalse(); stateModel.Guid = Guid.Empty; snapshot.HasChanges(stateModel).ShouldBeTrue(); stateModel.Guid = GuidValue; snapshot.HasChanges(stateModel).ShouldBeFalse(); }