public void AddingSameViewTwiceThrows() { var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; IView myView = new MockView(); region.Add(myView); try { region.Add(myView); Assert.Fail(); } catch (InvalidOperationException ex) { Assert.AreEqual("View already exists in region.", ex.Message); } catch { Assert.Fail(); } }
public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs() { object removedView = null; var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; IView myView = new MockView(); region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Remove) { removedView = e.OldItems[0]; } }; region.Add(myView); Assert.IsNull(removedView); region.Remove(myView); Assert.AreSame(myView, removedView); }
public void AddViewRaisesCollectionViewEvent() { bool viewAddedCalled = false; var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; IView myView = new MockView(); region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { viewAddedCalled = true; } }; object model = new object(); Assert.IsFalse(viewAddedCalled); region.Add(myView); Assert.IsTrue(viewAddedCalled); }
public virtual void Start() { //eventData = Instantiate(eventDataCopy); isResolving = false; isResolved = false; if (ResourceManager.instance != null) { resManager = ResourceManager.instance; } if (EventManager.instance != null) { eventManager = EventManager.instance; } if (RegionManager.instance != null) { regionManager = RegionManager.instance; } if (TurnManager.instance != null) { turnManager = TurnManager.instance; } this.GetComponent <Button>().onClick.AddListener(Click); this.GetComponent <BindToRegion> ().regionOrigin = regionOrigin; turnManager.EndTurnEvent.AddListener(UpdateEvent); cityOrign = regionOrigin.cityOrigin; tutorialManager = cityOrign.tutorialManager; if (turnsLeft > 0) { GetComponent <Image>().sprite = timerSprites[turnsLeft - 1]; } isEventUiPanel = false; }
public override HtmlRegion GetHtmlFromDb(RegionBase region, string pageName) { HtmlRegion htmlRegion = new HtmlRegion(region); if (pageCache == null) { var locations = from towns in context.ChosenTowns where towns.town == pageName select towns; pageCache = locations.FirstOrDefault(); } var data = string.Empty; if (pageCache != null) { string wikiPurl = "http://en.wikipedia.org/wiki/" + pageName; switch (region.mappedObject) { // mapping from objects to database fields case "description": data = pageCache.cleaneddata + "<br /><a target='_blank' href='" + wikiPurl + "' rel='nofollow'><i class='fa fa-wikipedia-w' alt='more from wikipedia' title='more from wikipedia'></i></a>"; break; case "links": data = GetLinks(pageName); break; } } htmlRegion.data = new Html(data); return(htmlRegion); }
public void ShowViewFiresViewShowedEvent() { bool viewActivated = false; var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; IView myView = new MockView(); region.ActiveViews.CollectionChanged += (o, e) => { if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems.Contains(myView)) { viewActivated = true; } }; region.Add(myView); Assert.IsFalse(viewActivated); region.Activate(myView); Assert.IsTrue(viewActivated); }
private void OnTriggerEnter(Collider other) { if (other.tag == RegionBase.RegionTag) { m_currentRegion = other.GetComponent <RegionBase>(); } }
public void RemoveViewFiresViewRemovedEvent() { bool viewRemoved = false; var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; IView myView = new MockView(); region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Remove) { viewRemoved = true; } }; region.Add(myView); Assert.IsFalse(viewRemoved); region.Remove(myView); Assert.IsTrue(viewRemoved); }
public void CanAddContentToRegion() { var control = new MockControl(); IRegion region = new RegionBase(control); region.Add(new MockView()); Assert.AreEqual(1, region.Views.Cast <object>().Count()); }
public void AddNamedViewWithNullOrEmptyStringNameThrows() { var control = new MockControl(); IRegion region = new RegionBase(control); IView myView = new MockView(); region.Add(myView, string.Empty); }
public void GetViewWithNullOrEmptyStringThrows() { var control = new MockControl(); IRegion region = new RegionBase(control); IView myView = new MockView(); region.GetView(string.Empty); }
public void GetViewReturnsNullWhenViewDoesNotExistInRegion() { var control = new MockControl(); IRegion region = new RegionBase(control); IView myView = new MockView(); Assert.IsNull(region.GetView("InexistentView")); }
public void AddingDuplicateNamedViewThrows() { var control = new MockControl(); IRegion region = new RegionBase(control); IView myView = new MockView(); region.Add(myView, "MyView"); region.Add(myView, "MyView"); }
public void RemoveNonexistViewNothingHappen() { var control = new MockControl(); IRegion region = new RegionBase(control); IView view = new MockView(); region.Remove(view); Assert.AreEqual(0, region.Views.Cast <object>().Count()); }
public void CanRemoveContentFromRegion() { var control = new MockControl(); IRegion region = new RegionBase(control); IView view = new MockView(); region.Add(view); region.Remove(view); Assert.AreEqual(0, region.Views.Cast <object>().Count()); }
public void ActivateNullViewThrows() { var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; IView nonAddedView = new MockView(); region.Activate(null); }
private void OnTriggerExit(Collider other) { if (other.tag == RegionBase.RegionTag) { RegionBase otherRegion = other.GetComponent <RegionBase>(); if (otherRegion == m_currentRegion) { m_currentRegion = null; } } }
public void GetViewReturnsNullAfterRemovingViewFromRegion() { var control = new MockControl(); IRegion region = new RegionBase(control); IView myView = new MockView(); region.Add(myView, "MyView"); region.Remove(myView); Assert.IsNull(region.GetView("MyView")); }
public void AddNamedViewIsAlsoListedInViewsCollection() { var control = new MockControl(); IRegion region = new RegionBase(control); IView myView = new MockView(); region.Add(myView, "MyView"); Assert.AreEqual(1, region.Views.Cast <object>().Count()); Assert.AreSame(myView, region.Views.Cast <object>().ElementAt(0)); }
public void CanAddAndRetrieveNamedViewInstance() { var control = new MockControl(); IRegion region = new RegionBase(control); IView myView = new MockView(); region.Add(myView, "MyView"); object returnedView = region.GetView("MyView"); Assert.IsNotNull(returnedView); Assert.AreSame(returnedView, myView); }
public void ChangingNameOnceItIsSetThrows() { var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; region.Name = "MyRegion"; region.Name = "ChangedRegionName"; }
public void CreatingNewScopesAsksTheRegionManagerForNewInstance() { var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; var myView = new MockView(); region.Add(myView, "MyView", true); Assert.IsTrue(regionManager.CreateRegionManagerCalled); }
public void AddViewReturnsNewRegionManager() { var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; var myView = new MockView(); var returnedRegionManager = region.Add(myView, "MyView", true); Assert.AreNotSame(regionManager, returnedRegionManager); }
public void AddingNonDependencyObjectToRegionDoesNotThrow() { var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; var myView = new MockView(); region.Add(myView); Assert.AreEqual(1, region.Views.Cast <object>().Count()); }
public override GalleryRegion GetGalleryFromDb(RegionBase region, string pageName, string rootPath) { Gallery g = new Gallery(); GalleryRegion galleryRegion = new GalleryRegion(region); switch (region.mappedObject) { case "thumbImages": g = GetThumbGallery(pageName, rootPath); break; } galleryRegion.data = g; return(galleryRegion); }
/// <summary> /// Removes a given WorldObject from the region it belongs to /// </summary> /// <param name="b"></param> public static void RemoveObject(WorldObjectBase b) { if (b == null) { return; } lock (currentRegions) { RegionBase ba = GetRegion(b.worldX, b.worldY); if (ba != null && ba.GetWorldObjects().Contains(b)) { ba.GetWorldObjects().Remove(b); } } }
public void RegionExposesCollectionOfContainedViews() { var control = new MockControl(); IRegion region = new RegionBase(control); IView view = new MockView(); region.Add(view); var views = region.Views; Assert.IsNotNull(views); Assert.AreEqual(1, views.Cast <object>().Count()); Assert.AreSame(view, views.Cast <object>().ElementAt(0)); }
public void RemovingViewAlsoRemovesItFromActiveViews() { var regionManager = new MockRegionManager(); var control = new MockControl(); IRegion region = new RegionBase(control); region.RegionManager = regionManager; IView myView = new MockView(); region.Add(myView); region.Activate(myView); Assert.IsTrue(region.ActiveViews.Contains(myView)); region.Remove(myView); Assert.IsFalse(region.ActiveViews.Contains(myView)); }
/// <summary> /// Loads the region at the region coordinates given and adds it to the world stack /// Ignores if the region is already loaded /// </summary> /// <param name="rx"></param> /// <param name="ry"></param> private static void LoadRegion(int rx, int ry) { RegionTag reg = new RegionTag(rx, ry); if (currentRegions.ContainsKey(reg)) { return; } RegionBase s = Save.SaveData.LoadRegion(reg); if (s == null) { s = new RegionBase(reg); } s.Load(); lock (currentRegions) currentRegions.Add(reg, s); }
void Start() { regionOrigin = cityOrigin.regionOrigin; if (RegionManager.instance != null) { regionManager = RegionManager.instance; } if (ResourceManager.instance != null) { resourceManager = ResourceManager.instance; } foreach (var region in regionManager.regionList) { //GameObject dropdownOptionPrefab = Instantiate(); } if (TurnManager.instance != null) { turnManager = TurnManager.instance; } tutorialManager = cityOrigin.tutorialManager; turnManager.EndTurnEvent.AddListener(SetUIText); regionListCopy = new List <RegionBase>(regionManager.regionList); regionListCopy.Remove(regionOrigin); regionOriginName.text = regionOrigin.cityOrigin.name; foreach (var item in regionListCopy) { cityName.Add(item.cityOrigin.name); } for (int i = 0; i <= regionListCopy.Count - 1; i++) { transferFields[i].transferPanel = this; transferFields[i].cityToTransferName.text = regionListCopy[i].cityOrigin.name; transferFields[i].cityTarget = regionListCopy[i].cityOrigin; } dropdown.AddOptions(cityName); SetUIText(); }