コード例 #1
0
        public void BenchmarkZoneMapFfxi()
        {
            string mapName   = SetupPersister.GetCurrentMethodName();
            var    persister = new FilePersister(mapName);
            var    want      = SetupZoneMap.SetupFfxiSizeGrid();
            // Path assumes to start from ./debug/ so we want to set it to the test fixtures dir.
            string grandParentDirectory = Directory.GetParent(persister.FilePath).FullName;
            string parentDirectory      = Directory.GetParent(grandParentDirectory).FullName;

            persister.FilePath = Path.Combine(parentDirectory, "fixtures");

            int time = Benchmark.Run("StreamReader.ReadToEnd", 5, () =>
            {
                persister.Save(want);
                var got = persister.Load <ZoneMap>();
                persister.Delete();
            });

            int benchTime = 1200;

            // Best time so far: 23548ms
            // New record!:      10214ms
            Assert.True(time < benchTime,
                        "time per iteration was: " + time + "ms which is greater than expected time of: " + benchTime + "ms");
        }
コード例 #2
0
        public void SaveAndLoad()
        {
            var filePersister = new FilePersister(string.Empty);

            WorkflowEntity workflowEntity = new WorkflowEntity
            {
                CurrentState                 = "CurrentState",
                DomainContextId              = Guid.NewGuid(),
                DomainContextStatusProperty  = "DomainContextStatusProperty",
                DomainContextTypeDescription = "DomainContextTypeDescription",
                MachineConfiguration         = "MachineConfiguration",
                WorkflowId = Guid.NewGuid()
            };

            filePersister.Save(workflowEntity);

            var path = string.Format("{0}.xml", workflowEntity.WorkflowId);

            Assert.That(File.Exists(path));

            var workflowEntity1 = filePersister.Load(workflowEntity.WorkflowId);

            Assert.AreEqual(workflowEntity1.CurrentState, workflowEntity.CurrentState);
            Assert.AreEqual(workflowEntity1.DomainContextId, workflowEntity.DomainContextId);
            Assert.AreEqual(workflowEntity1.DomainContextStatusProperty, workflowEntity.DomainContextStatusProperty);
            Assert.AreEqual(workflowEntity1.DomainContextTypeDescription, workflowEntity.DomainContextTypeDescription);
            Assert.AreEqual(workflowEntity1.MachineConfiguration, workflowEntity.MachineConfiguration);
            Assert.AreEqual(workflowEntity1.WorkflowId, workflowEntity.WorkflowId);
            Assert.AreEqual(workflowEntity1.WorkflowId, workflowEntity.WorkflowId);

            File.Delete(path);
        }
コード例 #3
0
        public void KnownNodeActorCanUpdateKnownNodes()
        {
            var    map       = SetupZoneMap.SetupSmallGrid();
            string mapName   = SetupPersister.GetCurrentMethodName();
            var    persister = new FilePersister(mapName);
            var    actor     = new KnownNodeActor(persister, map);
            var    traveler  = new Traveler();
            var    watcher   = new Watcher(traveler, actor);

            var newPos = new Vector3(1, 0, 1);

            traveler.Position = newPos;

            var wantGrid = SetupZoneMap.SetupSmallGrid();

            wantGrid.AddKnownNode(newPos);

            var want = wantGrid.UnknownNodes;
            var got  = persister.Load <ZoneMap>();

            Assert.Equal(want.Count, got.UnknownNodes.Count);
            for (var i = 0; i < want.Count; i++)
            {
                Assert.Equal(want[i], got.UnknownNodes[i]);
            }
        }
コード例 #4
0
ファイル: GridFileTests.cs プロジェクト: raboley/Pathfinder
        public void TestCanSaveToFile()
        {
            var want      = SetupZoneMap.SetupSmallGrid();
            var mapName   = SetupPersister.GetCurrentMethodName();
            var persister = new FilePersister(mapName);

            persister.Save(want);

            var got = persister.Load <ZoneMap>();

            persister.Delete();

            SetupZoneMap.AssertGridMapEqual(want.MapGrid, got.MapGrid);
        }
コード例 #5
0
ファイル: GridFileTests.cs プロジェクト: raboley/Pathfinder
        public void TestCanLoadGridFromFile()
        {
            var want      = SetupZoneMap.SetupSmallGrid();
            var mapName   = SetupPersister.GetCurrentMethodName();
            var persister = new FilePersister(mapName);
            // Path assumes to start from ./debug/ so we want to set it to the test fixtures dir.
            string grandParentDirectory = Directory.GetParent(persister.FilePath).FullName;
            string parentDirectory      = Directory.GetParent(grandParentDirectory).FullName;

            persister.FilePath = Path.Combine(parentDirectory, "fixtures");

            // Uncomment to make golden file if zoneMap changes.
            persister.Save(want);

            var got = persister.Load <ZoneMap>();

            SetupZoneMap.AssertGridMapEqual(want.MapGrid, got.MapGrid);
        }