public void Init() { string path = Path.Combine(Data.Directory, "mixed.txt"); bool[,] array = Bool.Read2DimArray(path); grid = new DataGrid<bool>(array); landscape = new Landscape.Landscape(grid); intShare = landscape.NewSiteVar<int>(InactiveSiteMode.Share1Value); intDistinct = landscape.NewSiteVar<int>(InactiveSiteMode.DistinctValues); objShare = landscape.NewSiteVar<Foo>(InactiveSiteMode.Share1Value); objDistinct = landscape.NewSiteVar<Foo>(InactiveSiteMode.DistinctValues); fooObjs = new Foo[landscape.SiteCount]; for (int i = 0; i < fooObjs.Length; ++i) fooObjs[i] = new Foo(i+1); }
public void ObjDistinct_SiteValues() { Foo lastInactiveSite = SetToFooObjs(objDistinct); Foo expectedFoo = new Foo(-333); objDistinct.SiteValues = expectedFoo; foreach (Site site in landscape.AllSites) { Assert.AreSame(expectedFoo, objDistinct[site]); } }
public void ObjDistinct_InactiveSiteValues() { Foo lastInactiveSite = SetToFooObjs(objDistinct); Foo expectedFoo = new Foo(-1234); objDistinct.InactiveSiteValues = expectedFoo; int index = 0; foreach (Site site in landscape.AllSites) { if (site.IsActive) Assert.AreSame(fooObjs[index], objDistinct[site]); else Assert.AreSame(expectedFoo, objDistinct[site]); index++; } }
public void ObjShare_SiteValues() { Foo lastInactiveSite = SetToFooObjs(objShare); Foo expectedFoo = new Foo(-22); objShare.SiteValues = expectedFoo; foreach (Site site in landscape.AllSites) { Assert.AreSame(expectedFoo, objShare[site]); } }
public void ObjShare_ActiveSiteValues() { Foo lastInactiveSite = SetToFooObjs(objShare); Foo expectedFoo = new Foo(-100); objShare.ActiveSiteValues = expectedFoo; foreach (Site site in landscape.AllSites) { if (site.IsActive) Assert.AreSame(expectedFoo, objShare[site]); else Assert.AreSame(lastInactiveSite, objShare[site]); } }