~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/Diff/NoDifferentFilesTestFixture.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using ICSharpCode.WixBinding;
 
5
using NUnit.Framework;
 
6
using System;
 
7
using System.Collections.Generic;
 
8
using System.Text;
 
9
 
 
10
namespace WixBinding.Tests.Diff
 
11
{
 
12
        [TestFixture]
 
13
        public class NoDifferentFilesTestFixture : IDirectoryReader
 
14
        {
 
15
                WixPackageFilesDiffResult[] diffResults;
 
16
                List<string> directories;
 
17
                List<string> directoryExistsChecks;
 
18
                
 
19
                [TestFixtureSetUp]
 
20
                public void SetUpFixture()
 
21
                {
 
22
                        directories = new List<string>();
 
23
                        directoryExistsChecks = new List<string>();
 
24
                        WixDocument doc = new WixDocument();
 
25
                        doc.FileName = @"C:\Projects\Setup\Setup.wxs";
 
26
                        doc.LoadXml(GetWixXml());
 
27
                        WixPackageFilesDiff diff = new WixPackageFilesDiff(this);
 
28
                        diffResults = diff.Compare(doc.GetRootDirectory());
 
29
                }
 
30
                
 
31
                [Test]
 
32
                public void NoDiffResultsFound()
 
33
                {
 
34
                        Assert.AreEqual(0, diffResults.Length);
 
35
                }
 
36
                
 
37
                [Test]
 
38
                public void FilesRequestedFromDirectory()
 
39
                {
 
40
                        Assert.AreEqual(1, directories.Count);
 
41
                        Assert.AreEqual(@"C:\Projects\Setup\bin", directories[0]);
 
42
                }
 
43
                
 
44
                [Test]
 
45
                public void DirectoryExistsChecks()
 
46
                {
 
47
                        StringBuilder directoriesChecked = new StringBuilder();
 
48
                        foreach (string dir in directoryExistsChecks) {
 
49
                                directoriesChecked.AppendLine(dir);
 
50
                        }
 
51
                        Assert.AreEqual(1, directoryExistsChecks.Count, directoriesChecked.ToString());
 
52
                        Assert.AreEqual(@"C:\Projects\Setup\bin", directoryExistsChecks[0]);
 
53
                }
 
54
 
 
55
                public string[] GetFiles(string path)
 
56
                {
 
57
                        directories.Add(path);
 
58
                        return new string[] {@"license.rtf"};
 
59
                }
 
60
                
 
61
                public string[] GetDirectories(string path)
 
62
                {
 
63
                        return new string[0];
 
64
                }
 
65
                
 
66
                public bool DirectoryExists(string path)
 
67
                {
 
68
                        directoryExistsChecks.Add(path);
 
69
                        return true;
 
70
                }
 
71
                
 
72
                string GetWixXml()
 
73
                {
 
74
                        return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
 
75
                                "\t<Product Name='Test' \r\n" +
 
76
                                "\t         Version='1.0' \r\n" +
 
77
                                "\t         Language='1013' \r\n" +
 
78
                                "\t         Manufacturer='#develop' \r\n" +
 
79
                                "\t         Id='????????-????-????-????-????????????'>\r\n" +
 
80
                                "\t\t<Package/>\r\n" +
 
81
                                "\t\t<Directory Id='TARGETDIR' SourceName='SourceDir'>\r\n" +
 
82
                                "\t\t\t<Directory Id='ProgramFilesFolder' Name='PFiles'>\r\n" +
 
83
                                "\t\t\t\t<Directory Id='INSTALLDIR' Name='YourApp' LongName='Your Application'>\r\n" +
 
84
                                "\t\t\t\t\t<Component Id='MyComponent' DiskId='1'>\r\n" +
 
85
                                "\t\t\t\t\t\t<File Id='LicenseFile' Name='license.rtf' Source='bin\\license.rtf' />\r\n" +
 
86
                                "\t\t\t\t\t</Component>\r\n" +
 
87
                                "\t\t\t\t</Directory>\r\n" +
 
88
                                "\t\t\t</Directory>\r\n" +
 
89
                                "\t\t</Directory>\r\n" +
 
90
                                "\t</Product>\r\n" +
 
91
                                "</Wix>";
 
92
                }
 
93
        }
 
94
}