Пример #1
0
        public void TestRoles()
        {
            COBieBinaryDeserialiser deserialiser = new COBieBinaryDeserialiser(cobieFile);
            COBieWorkbook workbook = deserialiser.Deserialise();
            using (XbimModel model = new XbimModel())
            {
                model.Open(xbimFile);
                workbook.ValidateRoles(model, COBieMergeRoles.Mechanical | COBieMergeRoles.Electrical | COBieMergeRoles.Plumbing);
            }

            Assert.IsNotNull(workbook);
        }
        public void Should_Roundtrip_Serialise()
        {
            string output = Path.GetTempFileName();
            COBieBinarySerialiser serialiser = new COBieBinarySerialiser(output);
            serialiser.Serialise(_book);

            // Deserialiser into a new workbook.
            Stopwatch timer = new Stopwatch();
            timer.Start();
            COBieBinaryDeserialiser deserialiser = new COBieBinaryDeserialiser(output);
            COBieWorkbook newBook = deserialiser.Deserialise();
            timer.Stop();
            Debug.WriteLine(string.Format("COBieBinaryDeserialiser Time = {0}", timer.Elapsed.TotalSeconds.ToString()));

            Assert.AreEqual(19, _book.Count);
        }
        public void Should_Have_HashValue_Serialise()
        {
            string hashCode1, hashCode2;
            string output = Path.GetTempFileName();
            hashCode1 = _book[Constants.WORKSHEET_FACILITY][0].RowHashValue;
            Debug.WriteLine(string.Format("Serialised Row hash Value = {0}", hashCode1));
            string hashCodeSerial1 = _book[Constants.WORKSHEET_FACILITY][0].InitialRowHashValue;
            Debug.WriteLine(string.Format("Created Row Hash Value Was = {0}", hashCodeSerial1));
            // Act
            COBieBinarySerialiser serialiser = new COBieBinarySerialiser(output);
            serialiser.Serialise(_book);

            // Deserialiser into a new workbook.
            COBieBinaryDeserialiser deserialiser = new COBieBinaryDeserialiser(output);

            COBieWorkbook newBook = deserialiser.Deserialise();
            hashCode2 = newBook[Constants.WORKSHEET_FACILITY][0].RowHashValue;
            Debug.WriteLine(string.Format("Deserialised Row hash Value = {0}", hashCode2));
            string hashCodeSerial2 = newBook[Constants.WORKSHEET_FACILITY][0].InitialRowHashValue;
            Debug.WriteLine(string.Format("Created Row Hash Value Was = {0}", hashCodeSerial2));

            // Assert
            Assert.AreEqual(hashCode1, hashCode2);
        }
        public void Should_XBimSerialise()
        {
            COBieWorkbook workBook;
            COBieContext context;
            COBieBuilder builder;
            COBieWorkbook book;

            COBieBinaryDeserialiser deserialiser = new COBieBinaryDeserialiser(DuplexBinaryFile);
            workBook = deserialiser.Deserialise();

            using (COBieXBimSerialiser xBimSerialiser = new COBieXBimSerialiser(Path.ChangeExtension(DuplexBinaryFile, ".Ifc")))//Path.ChangeExtension(Path.GetFullPath(BinaryFile), ".Ifc")
            {
                xBimSerialiser.Serialise(workBook);

                context = new COBieContext(null);
                context.TemplateFileName = ExcelTemplateFile;
                context.Model = xBimSerialiser.Model;

                builder = new COBieBuilder(context);
                book = builder.Workbook;
            }

            // Assert
            Assert.AreEqual(19, book.Count);
        }
        public void Should_BinarySerialiser_with_roles()
        {
            COBieWorkbook workBook, workBook2;
            COBieContext context;
            COBieBuilder builder;

            context = new COBieContext(null);
            context.TemplateFileName = ExcelTemplateFile;

            using (XbimModel model = new XbimModel())
            {
                model.Open(DuplexFile, XbimDBAccess.ReadWrite, delegate(int percentProgress, object userState)
                {
                    Console.Write("\rReading File {1} {0}", percentProgress, DuplexFile);
                });
                context.Model = model;
                context.MapMergeRoles[model] = COBieMergeRoles.Mechanical;

                builder = new COBieBuilder(context);
                workBook = builder.Workbook;
                COBieBinarySerialiser serialiser = new COBieBinarySerialiser(DuplexBinaryFile);
                serialiser.Serialise(workBook);

                COBieBinaryDeserialiser deserialiser = new COBieBinaryDeserialiser(DuplexBinaryFile);
                workBook2 = deserialiser.Deserialise();

            }

            Assert.IsTrue(workBook2[Constants.WORKSHEET_COMPONENT].RemovedRows.Count() > 0);
        }
 public static void LoadModel(TestContext context)
 {
     COBieBinaryDeserialiser deserialiser = new COBieBinaryDeserialiser(BinaryFile);
     _book = deserialiser.Deserialise();
 }