예제 #1
0
        public void Bundle_Ok_WithIncludes()
        {
            // Arrange
            string fileContent = new StringBuilder()
                                 .AppendLine("#include \"v.s.w.t1\"")
                                 .AppendLine("#include \"v.s.w.t2\"")
                                 .AppendLine()
                                 .AppendLine("Unit v.s.n.t3")
                                 .AppendLine()
                                 .AppendLine("Main:")
                                 .AppendLine("End")
                                 .AppendLine()
                                 .AppendLine("End")
                                 .ToString();

            FileInfo mainTdilFile = CreateTmpFile(fileContent);
            FileInfo t1           = CreateTmpFile();
            FileInfo t2           = CreateTmpFile();

            byte[] fileData = Encoding.UTF8.GetBytes(
                fileContent
                .Replace("#include \"v.s.w.t1\"", string.Format("#include \"{0}\"", t1.Name))
                .Replace("#include \"v.s.w.t2\"", string.Format("#include \"{0}\"", t2.Name))
                );


            // Act
            UnitBundleTable unitBundleTable = new UnitBundler(new _ImportPathProvider(new [] { t1, t2 })).Bundle(mainTdilFile);

            // Assert
            Assert.NotNull(unitBundleTable, "unitBundleTable != null");

            UnitBundleTableEntry[] unitBundleTableEntries;
            using (IEnumerator <UnitBundleTableEntry> itr = unitBundleTable.GetEnumerator())
                unitBundleTableEntries = itr.ToArray();

            Assert.AreEqual(3, unitBundleTableEntries.Length, "unitBundleTableEntries.Length != 1");
            Assert.AreEqual("main.btc.tdil", unitBundleTableEntries[2].Name, "unitBundleTableEntries[0].Name != \"main.btc.tdil\"");
            CollectionAssert.AreEqual(fileData, unitBundleTableEntries[2].Data, "unitBundleTableEntries[0].Data != fileData");

            Assert.AreEqual(t1.Name, unitBundleTableEntries[0].Name, "unitBundleTableEntries[0].Name != t1.Name");
            CollectionAssert.AreEqual(File.ReadAllBytes(t1.FullName), unitBundleTableEntries[0].Data, "unitBundleTableEntries[0].Data != t1.Data");

            Assert.AreEqual(t2.Name, unitBundleTableEntries[1].Name, "unitBundleTableEntries[1].Name != t2.Name");
            CollectionAssert.AreEqual(File.ReadAllBytes(t2.FullName), unitBundleTableEntries[1].Data, "unitBundleTableEntries[1].Data != t1.Data");
        }
예제 #2
0
        public void Bundle_Ok_WithoutIncludes()
        {
            // Arrange
            FileInfo mainTdilFile = CreateTmpFile();

            byte[] fileData = File.ReadAllBytes(mainTdilFile.FullName);

            // Act
            UnitBundleTable unitBundleTable = new UnitBundler(new _ImportPathProvider()).Bundle(mainTdilFile);

            // Assert
            Assert.NotNull(unitBundleTable, "unitBundleTable != null");

            UnitBundleTableEntry[] unitBundleTableEntries;
            using (IEnumerator <UnitBundleTableEntry> itr = unitBundleTable.GetEnumerator())
                unitBundleTableEntries = itr.ToArray();

            Assert.AreEqual(1, unitBundleTableEntries.Length, "unitBundleTableEntries.Length != 1");
            Assert.AreEqual("main.btc.tdil", unitBundleTableEntries[0].Name, "unitBundleTableEntries[0].Name != \"main.btc.tdil\"");
            CollectionAssert.AreEqual(fileData, unitBundleTableEntries[0].Data, "unitBundleTableEntries[0].Data != fileData");
        }