public void SetsNewValue() { var obj = new MockModel { Value = "currentValue" }; var propertyChangeUndo = new PropertyChangeUndo(obj, "Value", "previousValue", "nextValue"); propertyChangeUndo.Redo(); Assert.AreEqual("nextValue", obj.Value); }
public void ShouldChangeBackgroundOnValidationError() { var element = new TextBox(); var background = new SolidColorBrush(); var model = new MockModel(); OnValidationError.SetToggleBackground(element, background); CreateBindingThatValidatesOnExceptions(element, model); element.Text = "InvalidValue"; Assert.AreEqual(background, element.Background); }
public void SetsOldAndNewValue() { var action = new ActionUndo(this, () => MockModel.Change("previousValue"), () => MockModel.Change("nextValue")); action.Undo(); Assert.AreEqual("previousValue", MockModel.Name); action.Redo(); Assert.AreEqual("nextValue", MockModel.Name); action.Undo(); Assert.AreEqual("previousValue", MockModel.Name); }
public void Validator_WhenValidatorExistsAndThereAreErrors_ShouldThrowFailedValidationErrorWithDetailedErrorMessage() { MockModel obj = new MockModel(); ContainerBuilder builder = new ContainerBuilder(); builder.RegisterType <MockModel.Validator>().As <IValidator <MockModel> >(); IContainer container = builder.Build(); IValidatorService validatorService = new ValidatorService(container); const string expectedErrorMessage = "'Property1' must not be empty.;'Property2' must not be empty."; Action action = () => validatorService.Validate(obj); action.Should().Throw <FailedValidationException>().WithMessage(expectedErrorMessage); }
public void CancelsSubscriptionForInstance() { var obj = new MockModel { Value = "value1" }; var service = new MementoService(); service.RegisterObject(obj); service.UnregisterObject(obj); obj.Value = "newvalue"; Assert.IsFalse(service.CanUndo); }
public void ShouldSetToolTipOnError() { var element = new TextBox(); var model = new MockModel(); model.ExceptionMessage = "My custom Exception message"; OnValidationError.SetShowToolTip(element, true); CreateBindingThatValidatesOnExceptions(element, model); var originalTooltip = ToolTipService.GetToolTip(element); element.Text = "InvalidValue"; Assert.IsNotNull(ToolTipService.GetToolTip(element)); Assert.AreEqual(model.ExceptionMessage, ToolTipService.GetToolTip(element)); }
public void ShouldChangeToOriginalBackgroundErrorRemoved() { var element = new TextBox(); var originalBackground = new SolidColorBrush(); element.Background = originalBackground; var model = new MockModel(); OnValidationError.SetToggleBackground(element, new SolidColorBrush()); CreateBindingThatValidatesOnExceptions(element, model); element.Text = "InvalidValue"; Assert.AreNotEqual(originalBackground, element.Background); element.Text = "ValidValue"; Assert.AreEqual(originalBackground, element.Background); }
public void Constructor_WithEntityThatHasUntrimmedAndEmptyStrings_TrimsAndNullifiesStrings() { var entity = new Entity("mock") { Id = Guid.NewGuid() }; entity["dfe_field3"] = " a field3\n\rgoes here\n\r "; entity["dfe_field4"] = " "; var mock = new MockModel(entity, _crm, _mockValidatorFactory.Object); mock.Field3.Should().Be("a field3\n\rgoes here"); mock.Field4.Should().BeNull(); }
public void ShouldRemoveToolTipOnErrorRemoved() { var element = new TextBox(); var model = new MockModel(); OnValidationError.SetShowToolTip(element, true); CreateBindingThatValidatesOnExceptions(element, model); var originalTooltip = ToolTipService.GetToolTip(element); element.Text = "InvalidValue"; Assert.IsNotNull(ToolTipService.GetToolTip(element)); element.Text = "ValidValue"; Assert.AreEqual(originalTooltip, ToolTipService.GetToolTip(element)); }
public void OneTimeSetUp() { MockNeo4JPersistenceProvider persistenceProvider = new MockNeo4JPersistenceProvider("bolt://localhost:7687", "neo4j", "neo"); PersistenceProvider.CurrentPersistenceProvider = persistenceProvider; TearDown(); string projectFolder = Environment.CurrentDirectory + "\\..\\..\\..\\"; GeneratorSettings settings = new GeneratorSettings(projectFolder); GeneratorResult result = Generator.Execute <MockModel>(settings); MockModel model = new MockModel(); model.Execute(true); }
public void ClearsCurrentUndoRedoStackForInstance() { var obj = new MockModel { Value = "value1" }; var service = new MementoService(); service.RegisterObject(obj); obj.Value = "newvalue1"; Assert.IsFalse(service.CanRedo); service.UnregisterObject(obj); Assert.IsFalse(service.CanUndo); }
public void ShouldSetDefaultSortingByAttributes() { // Arrange var items = MockModel.ArrangeFixture(); var settings = new PagedDataSettings() { }; // Act var transformedSettings = DataPagerAdapter.TransformSettings(settings, this.GetType().GetMethod(nameof(ShouldSetDefaultSortingByAttributes))); // Assert Assert.Equal(transformedSettings.Sorting.Count, 1); Assert.True(transformedSettings.Sorting.Where(x => x.Property == "MyDefaultSortingProperty").Any()); }
public void ToEntity_DoesNotWriteNullRelationships() { var mock = new MockModel() { Id = Guid.NewGuid() }; var mockEntity = new Entity("mock", (Guid)mock.Id); _mockService.Setup(m => m.BlankExistingEntity("mock", mockEntity.Id, _context)).Returns(mockEntity); _mockService.Setup(m => m.NewEntity("relatedMock", _context)).Returns <Entity>(null); mock.ToEntity(_crm, _context); _mockService.Verify(m => m.AddLink(mockEntity, It.IsAny <Relationship>(), It.IsAny <Entity>(), _context), Times.Never()); }
public void SerializeAndDeserializeChangeTracked_BehavesCorrectly() { // Ensures the JSON serializer correctly deserializes // ChangedPropertyNames (and doesn't inadvertently change it // during the deserialization process when writing to attributes). var model = new MockModel() { Id = Guid.NewGuid(), Field3 = "test" }; model.ChangedPropertyNames.Should().BeEquivalentTo(new HashSet <string>() { "Id", "Field3", "FieldDefinedWithValue" }); // Test serializing/deseriaizing model. var json = model.SerializeChangeTracked(); var deserializedModel = json.DeserializeChangeTracked <MockModel>(); deserializedModel.Id.Should().Be(model.Id); deserializedModel.Field3.Should().Be(model.Field3); deserializedModel.ChangedPropertyNames.Should().BeEquivalentTo(new HashSet <string>() { "Id", "Field3", "FieldDefinedWithValue" }); // Test deserializing model with ChangedPropertyNames in different order/combinations. json = "{\"ChangedPropertyNames\":[\"Id\",\"Field1\"],\"Field3\":\"test\",\"Field2\":123}"; deserializedModel = json.DeserializeChangeTracked <MockModel>(); deserializedModel.Field2.Should().Be(123); deserializedModel.Field3.Should().Be("test"); deserializedModel.ChangedPropertyNames.Should().BeEquivalentTo(new HashSet <string>() { "Id", "Field1", "FieldDefinedWithValue" }); json = "{\"Field3\":\"test\",\"Field2\":123,\"ChangedPropertyNames\":[\"Id\",\"Field1\"]}"; deserializedModel = json.DeserializeChangeTracked <MockModel>(); deserializedModel.Field2.Should().Be(123); deserializedModel.Field3.Should().Be("test"); deserializedModel.ChangedPropertyNames.Should().BeEquivalentTo(new HashSet <string>() { "Id", "Field1", "FieldDefinedWithValue" }); }
public void ToEntity_WithExisting() { var mock = new MockModel() { Id = Guid.NewGuid(), Field1 = Guid.NewGuid(), Field2 = 1, Field3 = "field3", RelatedMock = new MockRelatedModel() { Id = Guid.NewGuid() }, RelatedMocks = new List <MockRelatedModel>() { new MockRelatedModel() { Id = Guid.NewGuid() } }, }; var mockEntity = new Entity("mock"); var relatedMockEntity = new Entity("mock") { EntityState = EntityState.Created }; _mockService.Setup(m => m.BlankExistingEntity("mock", (Guid)mock.Id, _context)) .Returns(mockEntity); _mockService.Setup(m => m.BlankExistingEntity("relatedMock", (Guid)mock.RelatedMock.Id, _context)).Returns(relatedMockEntity); _mockService.Setup(m => m.BlankExistingEntity("relatedMock", (Guid)mock.RelatedMocks.First().Id, _context)).Returns(relatedMockEntity); mock.ToEntity(_crm, _context); mockEntity.GetAttributeValue <EntityReference>("dfe_field1").Id.Should().Be((Guid)mock.Field1); mockEntity.GetAttributeValue <EntityReference>("dfe_field1").LogicalName.Should().Be("dfe_list"); mockEntity.GetAttributeValue <OptionSetValue>("dfe_field2").Value.Should().Be(mock.Field2); mockEntity.GetAttributeValue <string>("dfe_field3").Should().Be(mock.Field3); _mockService.Verify(m => m.AddLink(mockEntity, new Relationship("dfe_mock_dfe_relatedmock_mock"), relatedMockEntity, _context)); _mockService.Verify(m => m.AddLink(mockEntity, new Relationship("dfe_mock_dfe_relatedmock_mocks"), relatedMockEntity, _context)); }
public void ToEntity_DoesNotWriteUnchangedProperties() { var mock = new MockModel() { Id = Guid.NewGuid(), Field1 = null, Field3 = "new value" }; var mockEntity = new Entity("mock", (Guid)mock.Id); _mockService.Setup(m => m.BlankExistingEntity("mock", mockEntity.Id, _context)).Returns(mockEntity); mock.ToEntity(_crm, _context); var numberOfChangedAttributes = mockEntity.Attributes.Count(); numberOfChangedAttributes.Should().Be(2); }
public async Task <MockModel> GetMock(Guid guid, string httpMethod) { MockModel mock = null; GuidMethodsModel guidMethods = await GetHttpMethodsByGuid(guid); await guidMethods.IsNotNullAsync(async() => { httpMethod = guidMethods.HttpMethods.Contains(httpMethod) ? httpMethod : "GET"; string path = Path.Combine(_githubSetting.HttpMethodsFolderPath, httpMethod.ToUpper()); string content = await _githubService.GetFileContent(path, guid); mock = JsonSerializer.Deserialize <MockModel>(content); }); return(mock); }
public void TestArraySpecification() { var model = new MockModel() { Z = new double[] { 1, 2, 3 } }; simulation.Children.Add(model); Utilities.InitialiseModel(simulation); report.VariableNames = new string[] { "[MockModel].Z[3]" }; Assert.IsNull(runner.Run()); Assert.AreEqual(storage.Get <double>("MockModel.Z(3)"), new double[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }); }
public void ShouldSetToolTipToOriginalOnErrorRemoved() { var element = new TextBox(); string originalToolTip = "Please enter a valid value"; ToolTipService.SetToolTip(element, originalToolTip); var model = new MockModel(); OnValidationError.SetShowToolTip(element, true); CreateBindingThatValidatesOnExceptions(element, model); element.Text = "InvalidValue"; Assert.IsNotNull(ToolTipService.GetToolTip(element)); element.Text = "ValidValue"; Assert.AreEqual(originalToolTip, ToolTipService.GetToolTip(element)); }
public void ToEntity_WithNewThatHasExistingRelationships() { var mock = new MockModel() { RelatedMock = new MockRelatedModel(), }; var mockEntity = new Entity("mock"); var relatedMockEntity = new Entity("mock"); _mockService.Setup(m => m.NewEntity("mock", _context)).Returns(mockEntity); _mockService.Setup(m => m.NewEntity("relatedMock", _context)).Returns(relatedMockEntity); mock.ToEntity(_crm, _context); _mockService.Verify(m => m.AddLink(mockEntity, new Relationship("dfe_mock_dfe_relatedmock_mock"), relatedMockEntity, _context), Times.Never); }
public void HandlesDoubleUndo() { var obj = new MockModel { Value = "value1" }; var service = new MementoService(); service.RegisterObject(obj); obj.Value = "value2"; obj.Value = "value3"; service.Undo(); Assert.AreEqual("value2", obj.Value); service.Undo(); Assert.AreEqual("value1", obj.Value); }
public void EndsBatchWhenThereAlreadyIsABatch() { var mementoService = new MementoService(); var model = new MockModel(); var firstBatch = mementoService.BeginBatch("FirstBatch"); mementoService.Add(new PropertyChangeUndo(model, "Value", model.Value)); Assert.AreEqual(1, firstBatch.ActionCount); var secondBatch = mementoService.BeginBatch("SecondBatch"); mementoService.Add(new PropertyChangeUndo(model, "Value", model.Value)); Assert.AreEqual(1, secondBatch.ActionCount); mementoService.EndBatch(); Assert.AreEqual(2, mementoService.UndoBatches.Count()); }
public void CanGetPagedData() { // Arrange var items = MockModel.ArrangeFixture(); var pagedSize = 5; var settings = new PagedDataSettings() { TotalPerPage = pagedSize }; // Act var result = _dataPager.GetPagedData(items.AsQueryable(), settings); // Assert Assert.True(result.TotalRecords == items.Count, "Total records in the paged result does not match the total in the fixture collection."); Assert.True(result.Result.Count == pagedSize, "Total items in first paged batch does not match the configured page size."); }
public void Constructor_WithEntity() { var entity = new Entity("mock") { Id = Guid.NewGuid() }; entity["dfe_field1"] = new EntityReference { Id = Guid.NewGuid() }; entity["dfe_field2"] = new OptionSetValue { Value = 1 }; entity["dfe_field3"] = "field3"; var relatedEntity1 = new Entity("relatedMock") { Id = Guid.NewGuid() }; var relatedEntity2 = new Entity("relatedMock") { Id = Guid.NewGuid() }; _mockService.Setup(m => m.RelatedEntities(entity, "dfe_mock_dfe_relatedmock_mock")) .Returns(new List <Entity> { relatedEntity1 }); _mockService.Setup(m => m.RelatedEntities(entity, "dfe_mock_dfe_relatedmock_mocks")) .Returns(new List <Entity> { relatedEntity2 }); var mock = new MockModel(entity, _crm, _mockValidatorFactory.Object); mock.Id.Should().Be(entity.Id); mock.Field1.Should().Be(entity.GetAttributeValue <EntityReference>("dfe_field1").Id); mock.Field2.Should().Be(entity.GetAttributeValue <OptionSetValue>("dfe_field2").Value); mock.Field3.Should().Be(entity.GetAttributeValue <string>("dfe_field3")); mock.RelatedMock.Id.Should().Be(relatedEntity1.Id); mock.RelatedMocks.First().Id.Should().Be(relatedEntity2.Id); }
public async Task GetMock(HttpContext context) { string[] paths = context.Request.Path.Value.Split('/'); Guid guid = Guid.Parse(paths[2]); MockModel mock = await _mockService.GetMock(guid, context.Request.Method); (await mock.IsNotNullAsync(async() => { context.Request.HasQueryValues((query) => { mock.ResolveDynamicBody(query); }); await context.Response.WriteMock(mock); })) .IsNull(() => { context.Response.StatusCode = 404; }); }
public void ToEntity_WhenRelatedModelToEntityReturnsNull_DoesNotWriteNullRelationship() { var relatedMock = new Mock <MockRelatedModel>(); var mock = new MockModel() { RelatedMock = relatedMock.Object, }; var mockEntity = new Entity("mock"); var relatedMockEntity = new Entity("mock"); _mockService.Setup(m => m.NewEntity("mock", _context)).Returns(mockEntity); _mockService.Setup(m => m.NewEntity("relatedMock", _context)).Returns(relatedMockEntity); relatedMock.Setup(m => m.ToEntity(_crm, _context)).Returns <Entity>(null); mock.ToEntity(_crm, _context); _mockService.Verify(m => m.AddLink(mockEntity, new Relationship("dfe_mock_dfe_relatedmock_mock"), relatedMockEntity, _context), Times.Never); }
public void ToEntity_WithNewThatHasExistingRelationships() { var mock = new MockModel() { RelatedMock = new MockRelatedModel(), }; var mockEntity = new Entity("mock"); var relatedMockEntity = new Entity("mock"); _mockService.Setup(m => m.NewEntity("mock", _context)).Returns(mockEntity); _mockService.Setup(m => m.NewEntity("relatedMock", _context)).Returns(relatedMockEntity); mock.ToEntity(_crm, _context); // Ensure a pre-existing related entity is linked (if it is already linked to the entity this // will have no effect, which is desirable). _mockService.Verify(m => m.AddLink(mockEntity, new Relationship("dfe_mock_dfe_relatedmock_mock"), relatedMockEntity, _context), Times.Once); }
public void ShouldInitiallySetSelectedItemInSelectorFromModel() { var model = new MockModel(); var item1 = new MockItem { Property = 1 }; var item2 = new MockItem { Property = 2 }; var itemsSource = new List<MockItem> { item1, item2 }; var selector = new ComboBox(); selector.ItemsSource = itemsSource; SelectorExtensions.SetSelectedValuePath(selector, "Property"); model.SelectedValueInModel = 2; Binding valueBinding = new Binding("SelectedValueInModel"); valueBinding.Mode = BindingMode.TwoWay; valueBinding.Source = model; selector.SetBinding(SelectorExtensions.SelectedValueProperty, valueBinding); Assert.AreSame(item2, selector.SelectedItem); }
public void InvalidValuePathThrows() { var model = new MockModel(); var item1 = new MockItem { Property = 1 }; var itemsSource = new List <MockItem> { item1 }; var selector = new ComboBox(); selector.ItemsSource = itemsSource; Binding valueBinding = new Binding("SelectedValueInModel"); valueBinding.Mode = BindingMode.TwoWay; valueBinding.Source = model; selector.SetBinding(SelectorExtensions.SelectedValueProperty, valueBinding); SelectorExtensions.SetSelectedValuePath(selector, "InvalidProperty"); }
public void UndoBatches() { var model = new MockModel(); var mementoService = new MementoService(); mementoService.RegisterObject(model); string originalNumber = model.Value; mementoService.BeginBatch(); model.Value = "1000"; model.Value = "100"; model.Value = "10"; var mementoBatch = mementoService.EndBatch(); mementoBatch.Undo(); Assert.AreEqual(originalNumber, model.Value); }
public void ShouldUpdateModelOnSelectionChange() { var model = new MockModel(); var item1 = new MockItem { Property = 1 }; var item2 = new MockItem { Property = 2 }; var itemsSource = new List<MockItem> { item1, item2 }; var selector = new ComboBox(); selector.ItemsSource = itemsSource; SelectorExtensions.SetSelectedValuePath(selector, "Property"); Binding valueBinding = new Binding("SelectedValueInModel"); valueBinding.Mode = BindingMode.TwoWay; valueBinding.Source = model; selector.SetBinding(SelectorExtensions.SelectedValueProperty, valueBinding); selector.SelectedItem = item1; Assert.AreEqual(item1.Property, model.SelectedValueInModel); selector.SelectedItem = item2; Assert.AreEqual(item2.Property, model.SelectedValueInModel); }
public void TestArraySpecification() { var model = new MockModel() { Z = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } }; simulation.Children.Add(model); Utilities.InitialiseModel(simulation); report.VariableNames = new string[] { "[MockModel].Z[3]", "[MockModel].Z[10]" }; List <Exception> errors = runner.Run(); Assert.NotNull(errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(storage.Get <double>("MockModel.Z(3)"), new double[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }); Assert.AreEqual(storage.Get <double>("MockModel.Z(10)"), new double[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }); }
public void TestArrayRangeWithStartAndEndSpecification() { var mod = new MockModel() { Z = new double[] { 1, 2, 3 } }; simulation.Children.Add(mod); simulation.Children.Remove(storage); var datastore = new DataStore(); simulation.Children.Add(datastore); Utilities.InitialiseModel(simulation); report.VariableNames = new string[] { "[MockModel].Z[2:3]" }; List <Exception> errors = runner.Run(); Assert.NotNull(errors); Assert.AreEqual(0, errors.Count); datastore.Writer.Stop(); datastore.Reader.Refresh(); var data = datastore.Reader.GetData("Report"); var columnNames = DataTableUtilities.GetColumnNames(data); Assert.IsFalse(columnNames.Contains("MockModel.Z(0)")); Assert.IsFalse(columnNames.Contains("MockModel.Z(1)")); Assert.IsTrue(columnNames.Contains("MockModel.Z(2)")); Assert.IsTrue(columnNames.Contains("MockModel.Z(3)")); Assert.IsFalse(columnNames.Contains("MockModel.Z(4)")); Assert.AreEqual(DataTableUtilities.GetColumnAsDoubles(data, "MockModel.Z(2)"), new double[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }); Assert.AreEqual(DataTableUtilities.GetColumnAsDoubles(data, "MockModel.Z(3)"), new double[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }); }
public void Constructor_WithEntityThatHasAnInvalidFieldAttributeValue_NullifiesValue() { var entity = new Entity("mock") { Id = Guid.NewGuid() }; entity["dfe_field2"] = new OptionSetValue { Value = 123 }; entity["dfe_field3"] = "an-invalid-value"; var mockValidator = new Mock <IValidator>(); var validationResult = new ValidationResult(); _mockValidatorFactory.Setup(m => m.GetValidator(It.IsAny <Type>())).Returns(mockValidator.Object); mockValidator.Setup(m => m.Validate(It.IsAny <BaseModel>())).Returns(validationResult); validationResult.Errors.Add(new ValidationFailure("Field3", "this value is not valid!")); var mock = new MockModel(entity, _crm, _mockValidatorFactory.Object); mock.Field2.Should().Be(123); mock.Field3.Should().BeNull(); }
public void ToEntity_WritesNullProperties() { var mock = new MockModel() { Id = Guid.NewGuid(), Field1 = null, Field2 = null, Field3 = null, }; var mockEntity = new Entity("mock", (Guid)mock.Id); _mockService.Setup(m => m.BlankExistingEntity("mock", mockEntity.Id, _context)).Returns(mockEntity); mock.ToEntity(_crm, _context); mockEntity.GetAttributeValue <EntityReference>("dfe_field1").Should().BeNull(); mockEntity.GetAttributeValue <OptionSetValue>("dfe_field2").Should().BeNull(); mockEntity.GetAttributeValue <string>("dfe_field3").Should().BeNull(); var numberOfChangedAttributes = mockEntity.Attributes.Count(); numberOfChangedAttributes.Should().Be(3); }
public void InvalidValuePathThrows() { var model = new MockModel(); var item1 = new MockItem { Property = 1 }; var itemsSource = new List<MockItem> { item1 }; var selector = new ComboBox(); selector.ItemsSource = itemsSource; Binding valueBinding = new Binding("SelectedValueInModel"); valueBinding.Mode = BindingMode.TwoWay; valueBinding.Source = model; selector.SetBinding(SelectorExtensions.SelectedValueProperty, valueBinding); SelectorExtensions.SetSelectedValuePath(selector, "InvalidProperty"); }
public void ShouldNotFailIfItemsSourceIsNotSetBeforeSettingTheBindingToModel() { var model = new MockModel(); var item1 = new MockItem { Property = 1 }; var item2 = new MockItem { Property = 2 }; var itemsSource = new List<MockItem> { item1, item2 }; var selector = new ComboBox(); SelectorExtensions.SetSelectedValuePath(selector, "Property"); Binding valueBinding = new Binding("SelectedValueInModel"); valueBinding.Mode = BindingMode.TwoWay; valueBinding.Source = model; selector.SetBinding(SelectorExtensions.SelectedValueProperty, valueBinding); selector.ItemsSource = itemsSource; }
public void ClearsCurrentUndoRedoStackForInstance() { var obj = new MockModel {Value = "value1"}; var service = new MementoService(); service.RegisterObject(obj); obj.Value = "newvalue1"; Assert.IsFalse(service.CanRedo); service.UnregisterObject(obj); Assert.IsFalse(service.CanUndo); }
public void HandlesDoubleUndo() { var obj = new MockModel {Value = "value1"}; var service = new MementoService(); service.RegisterObject(obj); obj.Value = "value2"; obj.Value = "value3"; service.Undo(); Assert.AreEqual("value2", obj.Value); service.Undo(); Assert.AreEqual("value1", obj.Value); }
public void CancelsSubscriptionForInstance() { var obj = new MockModel {Value = "value1"}; var service = new MementoService(); service.RegisterObject(obj); service.UnregisterObject(obj); obj.Value = "newvalue"; Assert.IsFalse(service.CanUndo); }