public void when_attempting_to_version_a_property_bag() { var originalAddress = "12345 Fake Street"; var subscriber = new SimpleMementoingClass() { Domainees = new List<DomainPropertyBag>() { new DomainPropertyBag(), new DomainPropertyBag() }, ChiefDomainee = new DomainPropertyBag(), Address = originalAddress, FirstName = "If only Customer Objects", LastName = "were ever this simple" }; var mementor = new Mementor(); var newAddress = "Changed Address!"; mementor.PropertyChange(subscriber, () => subscriber.Address); //ohhh typing is a little weak here. subscriber.Address = newAddress; //ahh, note the order matters of course. subscriber.Address.Should().Be(newAddress); mementor.Undo(); //and I cant undo specific changes, just the last one. subscriber.Address.Should().Be(originalAddress); //still, very cool. //In terms of a deployed program, this is tough to implement. //I like the pub-sub design of it, code is superbly clean. }
public void when_attempting_to_restore_an_externally_tracked_list() { var mementor = new Mementor(isEnabled: true); var collection = new List<string>(); var item = "hey!"; mementor.ElementAdd(collection, item);//this is an extension method? Oh I see, he didnt want to put custom-list logic on Mementor. Nice. //it also doesnt actually add the element to the list: collection.Add(item); collection.Should().HaveCount(1); mementor.Undo(); //hmm, so it expects the caller to do the Add but it will handle the remove? collection.Should().BeEmpty(); }