コード例 #1
0
        public void FindAssemblies()
        {
            _loaderMock.Expect(mock => mock.TryLoadAssembly(_name1, "Specification: n1")).Return(_assembly1);
            _loaderMock.Expect(mock => mock.TryLoadAssembly(_name2, "Specification: n2")).Return(_assembly2);
            _loaderMock
            .Expect(mock => mock.TryLoadAssembly(_name3, "Specification: n3, Version=1.0.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"))
            .Return(_assembly3);
            _loaderMock.Replay();

            var finder     = CreateRootAssemblyFinder(_specification1, _specification2, _specification3);
            var assemblies = finder.FindRootAssemblies().ToArray();

            _loaderMock.VerifyAllExpectations();
            Assert.That(assemblies.Select(a => a.Assembly).ToArray(), Is.EquivalentTo(new[] { _assembly1, _assembly2, _assembly3 }));
        }
コード例 #2
0
        public void Initialize()
        {
            m_fileSystem = MockRepository.GenerateMock <IFileSystem>();
            m_fileSystem.Expect(f => f.GetFiles(string.Empty, "*.dll", true)).Return(new string[] { "Giacomelli.Unity.Metadata.Domain.UnitTests.dll" });
            var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Giacomelli.Unity.Metadata.Domain.UnitTests.dll");

            m_fileSystem.Expect(f => f.GetFullPath("Giacomelli.Unity.Metadata.Domain.UnitTests.dll")).Return(fullPath);
            m_assemblyLoader = MockRepository.GenerateMock <IAssemblyLoader>();
            m_assemblyLoader.Expect(a => a.LoadFrom(null)).IgnoreArguments().WhenCalled(m =>
            {
                m.ReturnValue = Assembly.LoadFrom(m.Arguments[0] as string);
            }).Return(null);
            m_target = new TypeService(m_fileSystem, m_assemblyLoader);
        }
コード例 #3
0
        public void FindAssemblies()
        {
            var specification1 = new FilePatternSpecification("*.dll", FilePatternSpecificationKind.IncludeFollowReferences);
            var specification2 = new FilePatternSpecification("*.exe", FilePatternSpecificationKind.IncludeFollowReferences);

            StubSearchService("*.dll", "1.dll", "2.dll");
            StubSearchService("*.exe", "1.exe");

            _loaderMock.Expect(mock => mock.TryLoadAssembly("1.dll")).Return(_assembly1);
            _loaderMock.Expect(mock => mock.TryLoadAssembly("2.dll")).Return(_assembly2);
            _loaderMock.Expect(mock => mock.TryLoadAssembly("1.exe")).Return(_assembly3);
            _loaderMock.Replay();

            var finder = CreateRootAssemblyFinder(specification1, specification2);

            var rootAssemblies = finder.FindRootAssemblies().Select(ra => ra.Assembly).ToArray();

            _loaderMock.VerifyAllExpectations();
            Assert.That(rootAssemblies, Is.EquivalentTo(new[] { _assembly1, _assembly2, _assembly3 }));
        }