Determines the namespace to use, based on a supplied list of type declarations.
Пример #1
0
        public void SetUpTestnameTest()
        {
            /*this.typeDeclarations = new CodeTypeDeclarationCollection();
             * this.testClassDeclaration = new System.CodeDom.CodeTypeDeclaration();
             * typeDeclarations.Add(this.testClassDeclaration);*/

            testClassDeclaration.UserData[NStubConstants.UserDataClassTypeKey] = typeof(NStub.CSharp.Tests.Stubs.InfoApe);
            testClassDeclaration.Name = "NStub.CSharp.TopRootClass";
            typeDeclarations.Add(this.testClassDeclaration);

            testClassDeclaration.UserData[NStubConstants.UserDataClassTypeKey] = typeof(NStub.CSharp.Tests.Stubs.InfoApe);
            testClassDeclaration.Name = "NStub.CSharp.BlaFasel.MyWorkClass";

            this.namespaceDetector = new NStub.CSharp.NamespaceDetector(typeDeclarations);
            this.testObject        = new CodeTypeSetup(this.namespaceDetector, buildData, this.testClassDeclaration);
            // testObject.SetUpCodeNamespace("NStub.CSharp", new[] { "System.F**k", "Rhino.Mocks" });

            var expected = "MyWorkClass";
            var actual   = testObject.SetUpTestname();

            Assert.AreEqual(expected, actual);
            Assert.AreEqual("NStub.CSharp.BlaFasel.MyWorkClass", testObject.BaseKey);
            Assert.AreEqual("MyWorkClassTest", testClassDeclaration.Name);

            // testObject.SetUpCodeNamespace("Jedzia.Loves.Testing", new[] { "System.F**k", "Rhino.Mocks" });
        }
Пример #2
0
        public void SetUp()
        {
            buildData                 = new BuildDataDictionary();
            this.typeDeclarations     = new CodeTypeDeclarationCollection();
            this.testClassDeclaration = new System.CodeDom.CodeTypeDeclaration();
            typeDeclarations.Add(this.testClassDeclaration);

            this.namespaceDetector = new NStub.CSharp.NamespaceDetector(typeDeclarations);
            this.testObject        = new CodeTypeSetup(this.namespaceDetector, buildData, this.testClassDeclaration);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeTypeSetup"/> class.
 /// </summary>
 /// <param name="namespaceDetector">The namespace detector.</param>
 /// <param name="buildData">The build data properties.</param>
 /// <param name="testClassDeclaration">The class declaration of the object under test.</param>
 public CodeTypeSetup(NamespaceDetector namespaceDetector, IBuildDataDictionary buildData, CodeTypeDeclaration testClassDeclaration)
 {
     Guard.NotNull(() => namespaceDetector, namespaceDetector);
     this.namespaceDetector = namespaceDetector;
     Guard.NotNull(() => buildData, buildData);
     this.buildData = buildData;
     Guard.NotNull(() => testClassDeclaration, testClassDeclaration);
     this.testClassDeclaration = testClassDeclaration;
     //result = SetUp();
 }
Пример #4
0
        public void PrepareNamespaceImportsTest()
        {
            var imports = new[] { "System","System.Linq", "MbUnit.Framework" };
            var expected = ".Tests.SubNamespace";
            var actual = testObject.PrepareNamespaceImports(imports);
            Assert.AreElementsEqual(imports, actual.Select(e => e.Namespace));

            var expectedPrepared = new[] { "System", "System.Linq", "global::MbUnit.Framework" };
            typeDeclarations.Add(new CodeTypeDeclaration("Jedzia.Loves.Testing.MbUnit.SubClass"));
            this.testObject = new NamespaceDetector(this.typeDeclarations);
            actual = testObject.PrepareNamespaceImports(imports);
            Assert.AreElementsEqual(expectedPrepared, actual.Select(e => e.Namespace));
        }
Пример #5
0
 public void SetUp()
 {
     this.typeDeclarations = new System.CodeDom.CodeTypeDeclarationCollection();
     typeDeclarations.Add(new CodeTypeDeclaration("Jedzia.Loves.Testing.TheClassToTest"));
     this.testObject = new NamespaceDetector(this.typeDeclarations);
 }
Пример #6
0
 public void ConstructWithParametersTypeDeclarationsTest()
 {
     this.typeDeclarations = new System.CodeDom.CodeTypeDeclarationCollection();
     this.testObject = new NamespaceDetector(this.typeDeclarations);
     Assert.Throws<ArgumentNullException>(() => new NamespaceDetector(null));
 }