Exemplo n.º 1
0
        public void GetHashCode_EqualObjects()
        {
            var rootAsm1 = new RootAssembly(typeof(object).Assembly, true);
            var rootAsm2 = new RootAssembly(typeof(object).Assembly, false);

            Assert.That(rootAsm1.GetHashCode(), Is.EqualTo(rootAsm2.GetHashCode()));
        }
Exemplo n.º 2
0
        public void Equals_False()
        {
            var rootAsm1 = new RootAssembly(typeof(object).Assembly, true);
            var rootAsm2 = new RootAssembly(typeof(RootAssemblyTest).Assembly, true);

            Assert.That(rootAsm1, Is.Not.EqualTo(rootAsm2));
        }
Exemplo n.º 3
0
        public void Equals_True()
        {
            var rootAsm1 = new RootAssembly(typeof(object).Assembly, true);
            var rootAsm2 = new RootAssembly(typeof(object).Assembly, false);

            Assert.That(rootAsm1, Is.EqualTo(rootAsm2));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create an instance of this object, add several content types to it and then write the information to disk as a STEP AP214 file or just get the relevant byte data.
        /// </summary>
        /// <param name="path">Path where you want the STEP file to be written. File will be overwritten if it already exists. The path will be written into the STEP file too.</param>
        /// <param name="assemblyName">Name of the root assembly. Will be visible in all CAD programs.</param>
        public StepFile(string path, string assemblyName)
        {
            this.FilePath     = path;
            this.AssemblyName = assemblyName;
            stepManager       = new StepManager();

            // keep track of all assembly children and each parent id
            idToContent  = new Dictionary <int, IChild>();
            idToParentId = new Dictionary <int, int>();

            // create root assembly (at the moment only a single root assembly is supported)
            ASSEMBLY_ROOT_ID = NewId();
            rootAssembly     = new RootAssembly(this.stepManager, assemblyName, ASSEMBLY_ROOT_ID);
        }
        public void FindRootAssemblies_UsesCombinedFinder()
        {
            var innerFinderStub = MockRepository.GenerateStub <IRootAssemblyFinder> ();
            var rootAssembly    = new RootAssembly(typeof(object).Assembly, true);

            innerFinderStub.Stub(stub => stub.FindRootAssemblies()).Return(new[] { rootAssembly });
            innerFinderStub.Replay();

            var finderMock = new MockRepository().PartialMock <SearchPathRootAssemblyFinder> (
                "baseDirectory",
                "relativeSearchPath",
                false,
                "dynamicDirectory",
                _loaderStub);

            finderMock.Expect(mock => mock.CreateCombinedFinder()).Return(new CompositeRootAssemblyFinder(new[] { innerFinderStub }));
            finderMock.Replay();

            var result = finderMock.FindRootAssemblies();

            Assert.That(result, Is.EqualTo(new[] { rootAssembly }));

            finderMock.VerifyAllExpectations();
        }
Exemplo n.º 6
0
        void Resolve()
        {
            RegisterDependency(RootAssembly);
            var cattrs = RootAssembly.GetCustomAttributes <AsyncTestSuiteAttribute> ().ToList();

            if (cattrs.Count == 0)
            {
                throw new InternalErrorException("Assembly '{0}' is not a Xamarin.AsyncTests test suite.", RootAssembly);
            }

            foreach (var cattr in cattrs)
            {
                Assembly assembly;
                AsyncTestSuiteAttribute attribute;

                string thisName = cattr.Name;

                if (cattr.IsReference)
                {
                    assembly = cattr.Type.GetTypeInfo().Assembly;
                    RegisterDependency(assembly);
                    var refcattrs = assembly.GetCustomAttributes <AsyncTestSuiteAttribute> ().ToList();
                    if (refcattrs.Count == 0)
                    {
                        throw new InternalErrorException("Referenced assembly '{0}' (referenced by '{1}') is not a Xamarin.AsyncTests test suite.", assembly, RootAssembly);
                    }
                    else if (refcattrs.Count > 1)
                    {
                        throw new InternalErrorException("Referenced assembly '{0}' (referenced by '{1}') contains multiple '[AsyncTestSuite]' attributes.", assembly, RootAssembly);
                    }

                    attribute = refcattrs [0];

                    if (attribute.IsReference)
                    {
                        throw new InternalErrorException("Assembly '{0}' references '{1}', which is a reference itself.", RootAssembly, assembly);
                    }
                }
                else
                {
                    attribute = cattr;
                    assembly  = RootAssembly;
                }

                if (thisName == null)
                {
                    thisName = attribute.Name ?? assembly.GetName().Name;
                }

                assemblies.Add(new ReflectionTestAssembly(thisName, attribute, assembly));
                providers.Add(attribute.Type);

                if (attribute.Dependencies != null)
                {
                    foreach (var dependency in attribute.Dependencies)
                    {
                        RegisterDependency(dependency.GetTypeInfo().Assembly);
                        providers.Add(dependency);
                    }
                }
            }
        }
 public void SetUp()
 {
     _root1 = new RootAssembly(typeof(object).Assembly, true);
     _root2 = new RootAssembly(typeof(CompositeRootAssemblyFinder).Assembly, true);
     _root3 = new RootAssembly(typeof(CompositeRootAssemblyFinderTest).Assembly, true);
 }
Exemplo n.º 8
0
        public void ToString_WithFollowReferencesSetToFalse()
        {
            var rootAsm = new RootAssembly(typeof(object).Assembly, false);

            Assert.That(rootAsm.ToString(), Is.EqualTo(typeof(object).Assembly.FullName));
        }
Exemplo n.º 9
0
        public void ToString_WithFollowReferencesSetToTrue()
        {
            var rootAsm = new RootAssembly(typeof(object).Assembly, true);

            Assert.That(rootAsm.ToString(), Is.EqualTo(typeof(object).Assembly.FullName + ", including references"));
        }