|
using System;
using System.Collections.Generic;
using System.Text;
using Vestris.ResourceLib;
using System.IO;
using System.Web;
using NUnit.Framework;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Vestris.ResourceLibUnitTests
{
[TestFixture]
public class GenericResourceTests
{
[Test]
public void TestLoadSave()
{
string atldll = Path.Combine(Environment.SystemDirectory, "atl.dll");
Assert.IsTrue(File.Exists(atldll));
string targetFilename = Path.Combine(Path.GetTempPath(), "genericResourceTestLoadSave.dll");
Console.WriteLine(targetFilename);
File.Copy(atldll, targetFilename, true);
// write the resource to a binary
GenericResource genericResource = new GenericResource(
new ResourceId("TESTTYPE"), new ResourceId("TESTNAME"), ResourceUtil.USENGLISHLANGID);
genericResource.Data = Guid.NewGuid().ToByteArray();
genericResource.SaveTo(targetFilename);
// reload and compare
GenericResource newGenericResource = new GenericResource(
new ResourceId("TESTTYPE"), new ResourceId("TESTNAME"), ResourceUtil.USENGLISHLANGID);
newGenericResource.LoadFrom(targetFilename);
ByteUtils.CompareBytes(newGenericResource.Data, genericResource.Data);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Daniel Doubrovkine has been in software engineering for twelve years and is currently development manager at Application Security Inc. in New York City. He has been involved in many software ventures, including Xo3 and Vestris Inc, was a development lead at Microsoft Corp. in Redmond, and director of Engineering at Visible Path Corp. in New York City. Daniel also builds and runs a foodie website, http://www.foodcandy.com.