Ejemplo n.º 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");
        }
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }