public PeopleOverseer(string mapName, string directory = "NPCs") { PeopleManager = new PeopleManager(mapName); Persister = SetupPersonPersister(mapName, directory); PeopleManager.LoadPeopleOrCreateNew(Persister); var actor = new PersisterActor <Person> { Persister = Persister }; var watcher = new CollectionWatcher <Person>(PeopleManager.People, actor); }
private static SpyActor SetupWatcher(out PeopleManager peopleManager) { var peopleCollection = PeopleManagerTests.SetupPeopleCollection(); var spyActor = new SpyActor(); peopleManager = new PeopleManager("test") { People = peopleCollection }; var watcher = new CollectionWatcher <Person>(peopleManager.People, spyActor); return(spyActor); }
public void AddingPersonTriggersAdd() { var want = 1; var zone = ExampleWorld.ZoneD(); var actor = new SpyActor(); var watcher = new CollectionWatcher <Person>(zone.Npcs, actor); zone.Npcs.Add(new Person(2, "test guy", Vector3.Zero)); int got = actor.CalledTimesAdd; Assert.Equal(want, got); }
public void WatcherTakesInCollection() { var peopleCollection = PeopleManagerTests.SetupPeopleCollection(); var spyActor = new SpyActor(); var peopleManager = new PeopleManager("test") { People = peopleCollection }; var watcher = new CollectionWatcher <Person>(peopleManager.People, spyActor); var want = PeopleManagerTests.SetupPeopleCollection(); for (var i = 0; i < want.Count; i++) { Assert.Equal(want[i], watcher.Collection[i]); } }
public ZoneOverseer(ZoneMapFactory zoneMapFactory, CollectionWatcher <Node> collectionWatcher) { ZoneMapFactory = zoneMapFactory; CollectionWatcher = collectionWatcher; }
/// <summary> /// Initializes a new instance of the <see cref="ValidationScope"/> class. /// </summary> /// <param name="root">The root element of the scope where the initial <see cref="ICollection{IError}"/> has been attached.</param> public ValidationScope(FrameworkElement root) { if (root == null) { throw new ArgumentNullException("root"); } this.fieldList = new FieldMap(); this.errorWatcher = new CollectionWatcher<IError, ValidationError>(this.OnAdded, this.OnRemoved, this.OnCleared); this.reattachErrorCommand = new RunAfterDispatchCommand(this.ReattachConversionErrors); Validation.AddErrorHandler(root, this.HandleDataConversionError); }