From 4b7e56e6ea16804d75373d8b0b14dd7ce00a2513 Mon Sep 17 00:00:00 2001 From: yangxiaodong Date: Thu, 8 Dec 2016 11:29:13 +0800 Subject: [PATCH] fix test environment --- .../Npoi.Core.Ooxml.TestCases.xproj | 7 +- Code/Npoi.Core.Ooxml.TestCases/project.json | 21 +- .../DDF/TestEscherBlipRecord.cs | 179 ------------------ .../DDF/TestEscherBlipWMFRecord.cs | 1 + .../Npoi.Core.TestCases.xproj | 7 +- Code/Npoi.Core.TestCases/project.json | 21 +- Code/Npoi.Core/DDF/EscherRGBProperty.cs | 1 + 7 files changed, 40 insertions(+), 197 deletions(-) delete mode 100644 Code/Npoi.Core.TestCases/DDF/TestEscherBlipRecord.cs diff --git a/Code/Npoi.Core.Ooxml.TestCases/Npoi.Core.Ooxml.TestCases.xproj b/Code/Npoi.Core.Ooxml.TestCases/Npoi.Core.Ooxml.TestCases.xproj index 942988d..9a8121c 100644 --- a/Code/Npoi.Core.Ooxml.TestCases/Npoi.Core.Ooxml.TestCases.xproj +++ b/Code/Npoi.Core.Ooxml.TestCases/Npoi.Core.Ooxml.TestCases.xproj @@ -4,7 +4,6 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - 9d85eebc-8b2d-45d3-aa35-c1af45c2a737 @@ -13,9 +12,11 @@ .\bin\ v4.5.2 - 2.0 + + + - + \ No newline at end of file diff --git a/Code/Npoi.Core.Ooxml.TestCases/project.json b/Code/Npoi.Core.Ooxml.TestCases/project.json index d0e5f88..770d925 100644 --- a/Code/Npoi.Core.Ooxml.TestCases/project.json +++ b/Code/Npoi.Core.Ooxml.TestCases/project.json @@ -1,16 +1,25 @@ { "version": "1.1.0-*", "buildOptions": { "nowarn": [ "CS0618", "CS0612" ] }, + "dependencies": { - "NETStandard.Library": "1.6.0", "Npoi.Core.TestCases": "1.1.0-*", "Npoi.Core.Ooxml": "1.1.0-*", - "nunit": "3.2.1", - "SharpZipLib.NETStandard": "0.86.0.1" + "SharpZipLib.NETStandard": "0.86.0.1", + "NUnit": "3.5.0", + "dotnet-test-nunit": "3.4.0-beta-3" }, + "frameworks": { - "netstandard1.6": { - "imports": "dnxcore50" + "netcoreapp1.0": { + "imports": "portable-net45+win8", + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } + } } - } + }, + "testRunner": "nunit" } \ No newline at end of file diff --git a/Code/Npoi.Core.TestCases/DDF/TestEscherBlipRecord.cs b/Code/Npoi.Core.TestCases/DDF/TestEscherBlipRecord.cs deleted file mode 100644 index a78739c..0000000 --- a/Code/Npoi.Core.TestCases/DDF/TestEscherBlipRecord.cs +++ /dev/null @@ -1,179 +0,0 @@ - -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for Additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ - - - -namespace TestCases.DDF -{ - - using System; - using System.Text; - using System.Collections.Generic; - using System.IO; - - using NUnit.Framework; - using Npoi.Core.DDF; - using Npoi.Core.Util; - - /** - * Test Read/Serialize of escher blip records - * - * @author Yegor Kozlov - */ - [TestFixture] - public class TestEscherBlipRecord - { - static POIDataSamples _samples = POIDataSamples.GetDDFInstance(); - - - //Test Reading/serializing of a PNG blip - [Test] - public void TestReadPNG() - { - //provided in bug-44886 - byte[] data = _samples.ReadFile("Container.dat"); - - EscherContainerRecord record = new EscherContainerRecord(); - record.FillFields(data, 0, new DefaultEscherRecordFactory()); - EscherContainerRecord bstore = (EscherContainerRecord)record.ChildRecords[1]; - EscherBSERecord bse1 = (EscherBSERecord)bstore.ChildRecords[0]; - Assert.AreEqual(EscherBSERecord.BT_PNG, bse1.BlipTypeWin32); - Assert.AreEqual(EscherBSERecord.BT_PNG, bse1.BlipTypeMacOS); - Assert.IsTrue(Arrays.Equals(new byte[]{ - 0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC, - 0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2 - }, bse1.UID)); - Assert.AreEqual(255, bse1.Tag); - Assert.AreEqual(32308, bse1.Size); - - EscherBitmapBlip blip1 = (EscherBitmapBlip)bse1.BlipRecord; - Assert.AreEqual(0x6E00, blip1.Options); - Assert.AreEqual(EscherBitmapBlip.RECORD_ID_PNG, blip1.RecordId); - Assert.IsTrue(Arrays.Equals(new byte[]{ - 0x65, 0x07, 0x4A, (byte)0x8D, 0x3E, 0x42, (byte)0x8B, (byte)0xAC, - 0x1D, (byte)0x89, 0x35, 0x4F, 0x48, (byte)0xFA, 0x37, (byte)0xC2 - }, blip1.UID)); - - //Serialize and Read again - byte[] ser = bse1.Serialize(); - EscherBSERecord bse2 = new EscherBSERecord(); - bse2.FillFields(ser, 0, new DefaultEscherRecordFactory()); - Assert.AreEqual(bse1.RecordId, bse2.RecordId); - Assert.AreEqual(bse1.BlipTypeWin32, bse2.BlipTypeWin32); - Assert.AreEqual(bse1.BlipTypeMacOS, bse2.BlipTypeMacOS); - Assert.IsTrue(Arrays.Equals(bse1.UID, bse2.UID)); - Assert.AreEqual(bse1.Tag, bse2.Tag); - Assert.AreEqual(bse1.Size, bse2.Size); - - EscherBitmapBlip blip2 = (EscherBitmapBlip)bse1.BlipRecord; - Assert.AreEqual(blip1.Options, blip2.Options); - Assert.AreEqual(blip1.RecordId, blip2.RecordId); - Assert.AreEqual(blip1.UID, blip2.UID); - - Assert.IsTrue(Arrays.Equals(blip1.PictureData, blip1.PictureData)); - } - - //Test Reading/serializing of a PICT metafile - [Test] - public void TestReadPICT() - { - //provided in bug-44886 - byte[] data = _samples.ReadFile("Container.dat"); - - EscherContainerRecord record = new EscherContainerRecord(); - record.FillFields(data, 0, new DefaultEscherRecordFactory()); - EscherContainerRecord bstore = (EscherContainerRecord)record.ChildRecords[1]; - EscherBSERecord bse1 = (EscherBSERecord)bstore.ChildRecords[1]; - //System.out.println(bse1); - Assert.AreEqual(EscherBSERecord.BT_WMF, bse1.BlipTypeWin32); - Assert.AreEqual(EscherBSERecord.BT_PICT, bse1.BlipTypeMacOS); - Assert.IsTrue(Arrays.Equals(new byte[]{ - (byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F, - 0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13 - }, bse1.UID)); - Assert.AreEqual(255, bse1.Tag); - Assert.AreEqual(1133, bse1.Size); - - EscherMetafileBlip blip1 = (EscherMetafileBlip)bse1.BlipRecord; - Assert.AreEqual(0x5430, blip1.Options); - Assert.AreEqual(EscherMetafileBlip.RECORD_ID_PICT, blip1.RecordId); - Assert.IsTrue(Arrays.Equals(new byte[]{ - 0x57, 0x32, 0x7B, (byte)0x91, 0x23, 0x5D, (byte)0xDB, 0x36, - 0x7A, (byte)0xDB, (byte)0xFF, 0x17, (byte)0xFE, (byte)0xF3, (byte)0xA7, 0x05 - }, blip1.UID)); - Assert.IsTrue(Arrays.Equals(new byte[]{ - (byte)0xC7, 0x15, 0x69, 0x2D, (byte)0xE5, (byte)0x89, (byte)0xA3, 0x6F, - 0x66, 0x03, (byte)0xD6, 0x24, (byte)0xF7, (byte)0xDB, 0x1D, 0x13 - }, blip1.PrimaryUID)); - - //Serialize and Read again - byte[] ser = bse1.Serialize(); - EscherBSERecord bse2 = new EscherBSERecord(); - bse2.FillFields(ser, 0, new DefaultEscherRecordFactory()); - Assert.AreEqual(bse1.RecordId, bse2.RecordId); - Assert.AreEqual(bse1.Options, bse2.Options); - Assert.AreEqual(bse1.BlipTypeWin32, bse2.BlipTypeWin32); - Assert.AreEqual(bse1.BlipTypeMacOS, bse2.BlipTypeMacOS); - Assert.IsTrue(Arrays.Equals(bse1.UID, bse2.UID)); - Assert.AreEqual(bse1.Tag, bse2.Tag); - Assert.AreEqual(bse1.Size, bse2.Size); - - EscherMetafileBlip blip2 = (EscherMetafileBlip)bse1.BlipRecord; - Assert.AreEqual(blip1.Options, blip2.Options); - Assert.AreEqual(blip1.RecordId, blip2.RecordId); - Assert.AreEqual(blip1.UID, blip2.UID); - Assert.AreEqual(blip1.PrimaryUID, blip2.PrimaryUID); - - Assert.IsTrue(Arrays.Equals(blip1.PictureData, blip1.PictureData)); - } - - //integral Test: check that the Read-Write-Read round trip is consistent - [Test] - public void TestContainer() - { - byte[] data = _samples.ReadFile("Container.dat"); - - EscherContainerRecord record = new EscherContainerRecord(); - record.FillFields(data, 0, new DefaultEscherRecordFactory()); - - byte[] ser = record.Serialize(); - Assert.IsTrue(Arrays.Equals(data, ser)); - } - - /** - * The test data was created from pl031405.xls attached to Bugzilla #47143 - */ - [Test] - public void Test47143() - { - byte[] data = _samples.ReadFile("47143.dat"); - EscherBSERecord bse = new EscherBSERecord(); - bse.FillFields(data, 0, new DefaultEscherRecordFactory()); - bse.ToString(); //assert that toString() works - Assert.IsTrue(bse.BlipRecord is EscherMetafileBlip); - - EscherMetafileBlip blip = (EscherMetafileBlip)bse.BlipRecord; - blip.ToString(); //assert that toString() works - byte[] remaining = blip.RemainingData; - Assert.IsNotNull(remaining); - - byte[] ser = bse.Serialize(); //serialize and assert against the source data - Assert.IsTrue(Arrays.Equals(data, ser)); - } - } -} \ No newline at end of file diff --git a/Code/Npoi.Core.TestCases/DDF/TestEscherBlipWMFRecord.cs b/Code/Npoi.Core.TestCases/DDF/TestEscherBlipWMFRecord.cs index 1f4a09c..53fc29b 100644 --- a/Code/Npoi.Core.TestCases/DDF/TestEscherBlipWMFRecord.cs +++ b/Code/Npoi.Core.TestCases/DDF/TestEscherBlipWMFRecord.cs @@ -27,6 +27,7 @@ namespace TestCases.DDF using NUnit.Framework; using Npoi.Core.DDF; using Npoi.Core.Util; + [TestFixture] public class TestEscherBlipWMFRecord { diff --git a/Code/Npoi.Core.TestCases/Npoi.Core.TestCases.xproj b/Code/Npoi.Core.TestCases/Npoi.Core.TestCases.xproj index abc2bae..fa8ea8f 100644 --- a/Code/Npoi.Core.TestCases/Npoi.Core.TestCases.xproj +++ b/Code/Npoi.Core.TestCases/Npoi.Core.TestCases.xproj @@ -4,7 +4,6 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - 49472345-4ec8-4138-9f44-cf8ff51d67be @@ -13,9 +12,11 @@ .\bin\ v4.5.2 - 2.0 + + + - + \ No newline at end of file diff --git a/Code/Npoi.Core.TestCases/project.json b/Code/Npoi.Core.TestCases/project.json index e359c4c..cce1c60 100644 --- a/Code/Npoi.Core.TestCases/project.json +++ b/Code/Npoi.Core.TestCases/project.json @@ -5,14 +5,23 @@ "define": [ "HIDE_UNREACHABLE_CODE" ] }, "dependencies": { - "NETStandard.Library": "1.6.0", - "Npoi.Core": "1.1.0-*", - "nunit": "3.2.1" + "NUnit": "3.5.0", + "dotnet-test-nunit": "3.4.0-beta-3", + // "NETStandard.Library": "1.6.0", + "Npoi.Core": "1.1.0-*" + //"nunit": "3.2.1" }, "frameworks": { - "netstandard1.6": { - "imports": "dnxcore50" + "netcoreapp1.0": { + "imports": "portable-net45+win8", + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } + } } - } + }, + "testRunner": "nunit" } diff --git a/Code/Npoi.Core/DDF/EscherRGBProperty.cs b/Code/Npoi.Core/DDF/EscherRGBProperty.cs index 919bf82..dd90f5b 100644 --- a/Code/Npoi.Core/DDF/EscherRGBProperty.cs +++ b/Code/Npoi.Core/DDF/EscherRGBProperty.cs @@ -65,6 +65,7 @@ namespace Npoi.Core.DDF /// The blue. public byte Blue { get { return (byte)((propertyValue >> 16) & 0xFF); } + } public override String ToXml(string tab) {