// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop;
using ICSharpCode.WixBinding;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using System;
using System.Drawing;
using System.Collections.Generic;
using System.IO;
using WixBinding.Tests.Utils;
namespace WixBinding.Tests.Document
{
///
/// Tests that WixBinaries class does not try to add the same binary id to the hash table.
///
[TestFixture]
public class DuplicateBinaryIdTestFixture : ITextFileReader
{
WixBinaries binaries;
string projectDirectory;
[TestFixtureSetUp]
public void SetUpFixture()
{
SD.InitializeForUnitTests();
MessageLoopHelper.RegisterStubService();
WixProject p = WixBindingTestsHelper.CreateEmptyWixProject();
projectDirectory = p.Directory;
p.Name = "MySetup";
FileProjectItem item = new FileProjectItem(p, ItemType.Compile);
item.Include = "Setup.wxs";
string docFileName = item.FileName;
ProjectService.AddProjectItem(p, item);
item = new FileProjectItem(p, ItemType.Compile);
item.Include = "Binaries.wxs";
ProjectService.AddProjectItem(p, item);
WixDocument doc = new WixDocument(p);
doc.FileName = docFileName;
doc.LoadXml(GetMainWixXml());
binaries = new WixBinaries(doc, this);
}
[Test]
public void GetDialogBitmapFileName()
{
string expectedFileName = Path.Combine(projectDirectory, "Bitmaps/Dialog.bmp");
Assert.AreEqual(expectedFileName, binaries.GetBinaryFileName("Dialog"));
}
public TextReader Create(string fileName)
{
fileName = Path.GetFileName(fileName);
if (fileName == "Binaries.wxs") {
return new StringReader(GetWixFragmentXml());
}
return new StringReader(GetMainWixXml());
}
string GetMainWixXml()
{
return "\r\n" +
"\t\r\n" +
"\t\t\r\n" +
"\t\r\n" +
"";
}
string GetWixFragmentXml()
{
return "\r\n" +
"\t\r\n" +
"\t\t\r\n" +
"\t\t\r\n" +
"\t\r\n" +
"";
}
}
}