示例#1
0
        public void WriteLightListTest()
        {
            var file = new DxfFile();

            file.Clear();
            file.Header.Version = DxfAcadVersion.R2007;
            file.Entities.Add(new DxfLight()
            {
                Name = "light-name"
            });
            var lightList = new DxfLightList();

            lightList.Version = 42;
            lightList.Lights.Add((DxfLight)file.Entities.Single());
            file.Objects.Add(lightList);
            VerifyFileContains(file, @"
  0
LIGHTLIST
  5
#
100
AcDbLightList
 90
42
 90
1
  5
#
  1
light-name
");
        }
示例#2
0
        public void DictionaryRoundTripTest3()
        {
            // dictionary with default with DICTIONARYVAR values
            var dict = new DxfDictionaryWithDefault();

            dict.DefaultObject = new DxfDictionaryVariable()
            {
                Value = "default-value"
            };
            dict["key-1"] = new DxfDictionaryVariable()
            {
                Value = "value-1"
            };

            var file = new DxfFile();

            file.Clear();
            file.Header.Version = DxfAcadVersion.R2000;
            file.Objects.Add(dict);
            var text = ToString(file);

            var parsedFile       = Parse(text);
            var roundTrippedDict = parsedFile.Objects.OfType <DxfDictionaryWithDefault>().Single();

            Assert.Equal("value-1", ((DxfDictionaryVariable)roundTrippedDict["key-1"]).Value);
            Assert.Equal("default-value", ((DxfDictionaryVariable)roundTrippedDict.DefaultObject).Value);
        }
示例#3
0
        public void DictionaryRoundTripTest2()
        {
            // dictionary with sub-dictionary wit DICTIONARYVAR value
            var dict1 = new DxfDictionary();
            var dict2 = new DxfDictionary();

            dict1["key-1"] = dict2;
            dict2["key-2"] = new DxfDictionaryVariable()
            {
                Value = "value-2"
            };

            var file = new DxfFile();

            file.Clear();
            file.Header.Version = DxfAcadVersion.R2000;
            file.Objects.Add(dict1);
            var text = ToString(file);

            var parsedFile        = Parse(text);
            var roundTrippedDict1 = parsedFile.Objects.OfType <DxfDictionary>().First(d => d.ContainsKey("key-1"));
            var roundTrippedDict2 = (DxfDictionary)roundTrippedDict1["key-1"];

            Assert.Equal("value-2", ((DxfDictionaryVariable)roundTrippedDict2["key-2"]).Value);
        }
示例#4
0
        public void DictionaryRoundTripTest1()
        {
            // dictionary with DICTIONARYVAR values
            var dict = new DxfDictionary();

            dict["key-1"] = new DxfDictionaryVariable()
            {
                Value = "value-1"
            };
            dict["key-2"] = new DxfDictionaryVariable()
            {
                Value = "value-2"
            };

            var file = new DxfFile();

            file.Clear();
            file.Header.Version = DxfAcadVersion.R2000;
            file.Objects.Add(dict);
            var text = ToString(file);

            var parsedFile       = Parse(text);
            var roundTrippedDict = parsedFile.Objects.OfType <DxfDictionary>().Single(d => d.Keys.Count == 2);

            Assert.Equal("value-1", ((DxfDictionaryVariable)roundTrippedDict["key-1"]).Value);
            Assert.Equal("value-2", ((DxfDictionaryVariable)roundTrippedDict["key-2"]).Value);
        }
示例#5
0
        private static void EnsureFileContainsObject(DxfObject obj, string text, DxfAcadVersion version = DxfAcadVersion.R12)
        {
            var file = new DxfFile();

            file.Clear();
            file.Header.Version = version;
            file.Objects.Add(obj);
            VerifyFileContains(file, text);
        }
示例#6
0
        public void NullPlotSettingsName()
        {
            // artificially create a plot settings object without a plot view name
            var file = new DxfFile();

            file.Clear();
            var plotSettings = new DxfPlotSettings();

            // ensure it doesn't end up as a view
            file.Objects.Add(plotSettings);
            Assert.Equal(0, file.Views.Count);
            file.Normalize();
            Assert.Equal(0, file.Views.Count);

            // ensure that it ends up as a view when it has a valid name
            plotSettings.PlotViewName = "plot view name";
            file.Normalize();
            Assert.Equal(plotSettings.PlotViewName, file.Views.Single().Name);
        }
示例#7
0
        public void WriteSelfReferencingObjectRoundTripTest()
        {
            var dict = new DxfDictionary();

            dict["key"] = dict;

            var file = new DxfFile();

            file.Clear();
            file.Header.Version = DxfAcadVersion.R14;
            file.Objects.Add(dict);

            var text = ToString(file);

            file = Parse(text);
            dict = file.Objects.OfType <DxfDictionary>().Single(d => d.ContainsKey("key"));

            Assert.Equal(((IDxfItemInternal)dict).Handle, ((IDxfItemInternal)dict).OwnerHandle);
            Assert.Equal(((IDxfItemInternal)dict).Handle, ((IDxfItemInternal)dict["key"]).OwnerHandle);
        }
示例#8
0
        public void WriteSortentsTableTest()
        {
            var file = new DxfFile();

            file.Clear();
            file.Header.Version = DxfAcadVersion.R14;
            file.Entities.Add(new DxfModelPoint(new DxfPoint(1, 2, 3)));
            file.Entities.Add(new DxfModelPoint(new DxfPoint(4, 5, 6)));
            var sortents = new DxfSortentsTable();

            sortents.Entities.Add(file.Entities.First());
            sortents.SortItems.Add(file.Entities.Skip(1).First());
            file.Objects.Add(sortents);
            VerifyFileContains(file, @"
  0
POINT
  5
#
");
            VerifyFileContains(file, @"
  0
POINT
  5
#
");
            VerifyFileContains(file, @"
  0
SORTENTSTABLE
  5
#
100
AcDbSortentsTable
331
#
  5
#
");
        }