Add() public method

Adds a file to the set
public Add ( SuiteRelativePath path ) : void
path SuiteRelativePath Path of the file relative to the suite root
return void
        public void SetUp()
        {
            kernel = new StandardKernel();

            tmp = new TempDirectory();
            rootDir = new LocalFileSystemDirectory(tmp);
            using (var writer = rootDir.CreateTextFile("file1"))
                writer.WriteLine("Contents of file 1");
            using (var writer = rootDir.CreateTextFile("file2"))
                writer.WriteLine("Contents of file 2");
            using (var writer = rootDir.CreateTextFile("file3"))
                writer.WriteLine("Contents of file 3");

            sourceSet1 = new SourceSet("test1");
            sourceSet1.Add(new SuiteRelativePath("file1"));
            sourceSet1.Add(new SuiteRelativePath("file2"));

            sourceSet2 = new SourceSet("test2");
            sourceSet2.Add(new SuiteRelativePath("file1"));
            sourceSet2.Add(new SuiteRelativePath("file3"));

            kernel.Bind<IFileSystemDirectory>().ToConstant(rootDir).WhenTargetHas<SuiteRootAttribute>();

            var factoryMock = new Mock<ISourceSetFingerprintFactory>();
            factoryMock.Setup(
                f =>
                f.CreateSourceSetFingerprint(It.IsAny<IEnumerable<SuiteRelativePath>>(), It.IsAny<Func<string, bool>>(), It.IsAny<bool>()))
                       .Returns<IEnumerable<SuiteRelativePath>, Func<string, bool>, bool>(
                            (files, exclusions, fullDependency) => new SourceSetFingerprint(rootDir, files, exclusions, fullDependency));
            fingerprintFactory = factoryMock.Object;
        }
Beispiel #2
0
        public void SourceSetIsNotCaseSensitive()
        {
            var set = new SourceSet("test");
            set.Add(new SuiteRelativePath("x/y/z.abc"));
            set.Add(new SuiteRelativePath("x/Y/z.abc"));
            set.Add(new SuiteRelativePath("x/y/Z.abc"));
            set.Add(new SuiteRelativePath("x/y/z.aBc"));

            set.Files.Should().HaveCount(1);
            set.Files.Should().HaveElementAt(0, new SuiteRelativePath("x/y/z.abc"));
        }
Beispiel #3
0
        public void FilesWithIdlExtensionAreFiltered()
        {
            var sourceSet = new SourceSet("cpp");
            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("a/b/c/z.c"));
            sourceSet.Add(new SuiteRelativePath("1.idl"));
            sourceSet.Add(new SuiteRelativePath("a/2.idl"));


            sourceSetRoot.SetFileContents("y.h", string.Empty);
            sourceSetRoot.SetFileContents("a/b/c/z.c", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(5);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("1.idl"));
            filteredSet.Files.Should().NotContain(new SuiteRelativePath("a/2.idl"));
        }
Beispiel #4
0
        public void GeneratedDllDataCIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");
            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/dlldata.c"));
            sourceSet.Add(new SuiteRelativePath("fake/dlldata.c"));

            const string realDllDataC =
                @"/*********************************************************
   DllData file -- generated by MIDL compiler 

        DO NOT ALTER THIS FILE

   This file is regenerated by MIDL on every IDL file compile.

   To completely reconstruct this file, delete it and rerun MIDL
   on all the IDL files in this DLL, specifying this file for the
   /dlldata command line option

*********************************************************/";

            const string fakeDllDataC = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/dlldata.c", realDllDataC);
            sourceSetRoot.SetFileContents("fake/dlldata.c", fakeDllDataC);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/dlldata.c"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/dlldata.c"));
        }
Beispiel #5
0
        public void GeneratedProxyStubIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");
            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/something.c"));
            sourceSet.Add(new SuiteRelativePath("fake/something.c"));

            const string realProxyStub = @"

/* this ALWAYS GENERATED file contains the proxy stub code */

...";

            const string fakeProxyStub = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/something.c", realProxyStub);
            sourceSetRoot.SetFileContents("fake/something.c", fakeProxyStub);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/something.c"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/something.c"));
        }
Beispiel #6
0
        public void GeneratedGuidDefinitionFileIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");
            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/something.c"));
            sourceSet.Add(new SuiteRelativePath("fake/something.c"));

            const string realGuidDef = @"

/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */

...";

            const string fakeGuidDef = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/something.c", realGuidDef);
            sourceSetRoot.SetFileContents("fake/something.c", fakeGuidDef);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/something.c"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/something.c"));
        }
Beispiel #7
0
        public void GeneratedIdlHeaderIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");
            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/something.h"));
            sourceSet.Add(new SuiteRelativePath("fake/something.h"));

            const string realIdlHeader = @"

/* this ALWAYS GENERATED file contains the definitions for the interfaces */

...";

            const string fakeIdlHeader = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/something.h", realIdlHeader);
            sourceSetRoot.SetFileContents("fake/something.h", fakeIdlHeader);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/something.h"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/something.h"));
        }