Initialize() public method

public Initialize ( string targetDir ) : void
targetDir string
return void
示例#1
0
        public void TypeCacheIgnoresTypesContainingImportTest()
        {
            var typeCache = new TypeCache();
            typeCache.Initialize("TypeCacheIgnoresTypesContainingImportTest", @"TestData\TrianglesWithImport.etl");

            Assert.AreEqual(3, typeCache.Cache.Count);
        }
        public void EventStatisticCacheCreatesCsvTest()
        {
            TypeCache typecache = new TypeCache();
            typecache.Initialize("test2", new[] { testDataFile });

            EventStatisticCache cache = new EventStatisticCache();
            var result = cache.GetTypeStatistics(typecache, new[] { testDataFile });

            Assert.IsTrue(File.Exists(Path.Combine(Environment.CurrentDirectory, "TestData", Path.GetFileNameWithoutExtension(testDataFile) + ".csv")));

            File.Delete(Path.Combine(Environment.CurrentDirectory, Path.GetFileNameWithoutExtension(testDataFile) + ".csv"));
        }
示例#3
0
        public void TypeCacheInitHappyPathTest()
        {
            var typeCache = new TypeCache();
            typeCache.Initialize("test", new[] { testDataFile });

            var dir = typeCache.CacheDirectory;

            Assert.AreEqual(3, Directory.GetFiles(dir, "*.bond").Length);
            Assert.AreEqual(3, typeCache.Cache.Count);

            Utilities.ForceDeleteDirectory("test");
        }
        public void EventStatisticCacheGetTypeStatisticsHappyPathTest()
        {
            TypeCache typecache = new TypeCache();
            typecache.Initialize("test1", new[] { testDataFile });

            EventStatisticCache cache = new EventStatisticCache();
            var result = cache.GetTypeStatistics(typecache, new[] { testDataFile });

            Assert.AreEqual(3, result.Keys.Count);
            Assert.IsTrue(result.All(a => a.Value.EventCount == 10));

            var typeNames = new[] { "IsoscelesTriangle", "EquilateralTriangle", "RightAngledTriangle" };
            Assert.IsTrue(result.All(a => typeNames.Contains(a.Key.Name)));
        }
        public void EventStatisticLoadCsvValuesTest()
        {
            TypeCache typecache = new TypeCache();
            typecache.Initialize("test3", new[] { testDataFile });

            EventStatisticCache cache = new EventStatisticCache();
            var result = cache.GetTypeStatistics(typecache, new[] { testDataFile });

            Assert.IsTrue(File.Exists(Path.Combine(Environment.CurrentDirectory, "TestData", Path.GetFileNameWithoutExtension(testDataFile) + ".csv")));

            File.Delete(Path.Combine(Environment.CurrentDirectory, Path.GetFileNameWithoutExtension(testDataFile) + ".csv"));

            foreach (var item in result)
            {
                switch (item.Key.Name)
                {
                    case "IsoscelesTriangle":
                        Assert.AreEqual(27D, item.Value.AverageByteSize);
                        Assert.AreEqual(270, item.Value.ByteSize);
                        Assert.AreEqual(10, item.Value.EventCount);
                        Assert.AreEqual(0.0370, item.Value.EventsPerSecond);
                        break;

                    case "EquilateralTriangle":
                        Assert.AreEqual(25D, item.Value.AverageByteSize);
                        Assert.AreEqual(250, item.Value.ByteSize);
                        Assert.AreEqual(10, item.Value.EventCount);
                        Assert.AreEqual(0.0370, item.Value.EventsPerSecond);
                        break;

                    case "RightAngledTriangle":
                        Assert.AreEqual(29D, item.Value.AverageByteSize);
                        Assert.AreEqual(290, item.Value.ByteSize);
                        Assert.AreEqual(10, item.Value.EventCount);
                        Assert.AreEqual(0.037, item.Value.EventsPerSecond);
                        break;

                    default:
                        Assert.Fail("Unexpected test result. Test fails.");
                        break;
                }

            }
        }
        public void MultipleTypesStatsCalculationTest()
        {
            TypeCache typecache = new TypeCache();
            typecache.Initialize("MultipleTypesStatsCalculationTest", new[] { testDataFile });

            Assert.AreEqual(4, typecache.Cache.Count);
            Assert.IsTrue(typecache.Cache.All(a => a != null && a.Manifest != null && a.Type != null));

            EventStatisticCache cache = new EventStatisticCache();
            var result = cache.GetTypeStatistics(typecache, new[] { testDataFile });

            Assert.AreEqual(3, result.Count);

            var values = result.Values.ToArray();
            Assert.AreEqual(10, values[0].EventCount);
            Assert.AreEqual(10, values[1].EventCount);
            Assert.AreEqual(10, values[2].EventCount);

            File.Delete(Path.Combine("TestData", Path.GetFileNameWithoutExtension(testDataFile) + ".csv"));
        }
        public void ReadTypesFromSingleManifestTest()
        {
            TypeCache typecache = new TypeCache();
            typecache.Initialize("ReadTypesFromSingleManifestTest", new[] { testDataFile });

            Debug.WriteLine(typecache.CacheDirectory);

            Assert.AreEqual(4, typecache.Cache.Count);

            Debug.WriteLine(typecache.Cache[0].Manifest.ManifestId);
            Debug.WriteLine(typecache.Cache[1].Manifest.ManifestId);
            Debug.WriteLine(typecache.Cache[2].Manifest.ManifestId);
            Debug.WriteLine(typecache.Cache[3].Manifest.ManifestId);

            Debug.WriteLine(typecache.Cache[0].Type.Name);
            Debug.WriteLine(typecache.Cache[1].Type.Name);
            Debug.WriteLine(typecache.Cache[2].Type.Name);
            Debug.WriteLine(typecache.Cache[3].Type.Name);

            Assert.IsTrue(typecache.Cache.All(a => a != null && a.Manifest != null && a.Type != null));
        }
示例#8
0
 public void TypeCacheInitTargetDirNullTest()
 {
     var typeCache = new TypeCache();
     typeCache.Initialize(null, new string[] { testDataFile });
 }
示例#9
0
 public void TypeCacheInitNullFilesTest()
 {
     var typeCache = new TypeCache();
     typeCache.Initialize("dir", null);
 }
示例#10
0
 public void TypeCacheInitNoFilesTest()
 {
     var typeCache = new TypeCache();
     typeCache.Initialize("dir", new string[] { });
     typeCache.Initialize("dir", null);
 }