コード例 #1
0
ファイル: PluginRepository.Test.cs プロジェクト: minskowl/MY
        public void TestAddFilesWithOwnAssembly()
        {
            PluginRepository testRepository = new PluginRepository();

            Assembly self = Assembly.GetAssembly(GetType());

            testRepository.AddFiles(self.Location);

            Assert.AreEqual(1, testRepository.LoadedAssemblies.Count);
        }
コード例 #2
0
ファイル: PluginHost.cs プロジェクト: pr0gramm3r1/AngryTanks
    /// <summary>Initializes the plugin using an existing repository</summary>
    /// <param name="employer">Employer used assess and employ the plugin types</param>
    /// <param name="repository">Repository in which plugins will be stored</param>
    public PluginHost(Employer employer, PluginRepository repository) {
      this.employer = employer;
      this.repository = repository;

      foreach(Assembly assembly in this.repository.LoadedAssemblies) {
        employAssemblyTypes(assembly);
      }

      this.repository.AssemblyLoaded += new AssemblyLoadEventHandler(assemblyLoadHandler);
    }
コード例 #3
0
        /// <summary>Initializes the plugin using an existing repository</summary>
        /// <param name="employer">Employer used assess and employ the plugin types</param>
        /// <param name="repository">Repository in which plugins will be stored</param>
        public PluginHost(Employer employer, PluginRepository repository)
        {
            this.employer   = employer;
            this.repository = repository;

            foreach (Assembly assembly in this.repository.LoadedAssemblies)
            {
                employAssemblyTypes(assembly);
            }

            this.repository.AssemblyLoaded += new AssemblyLoadEventHandler(assemblyLoadHandler);
        }
コード例 #4
0
ファイル: PluginRepository.Test.cs プロジェクト: minskowl/MY
        public void TestAddAssembly()
        {
            PluginRepository testRepository = new PluginRepository();

            // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
            // the unit testing tool
            Assembly self = Assembly.GetAssembly(GetType());

            testRepository.AddAssembly(self);

            Assert.AreEqual(1, testRepository.LoadedAssemblies.Count);
        }
コード例 #5
0
        /// <summary>Mocks a subscriber for the events of a plugin repository</summary>
        /// <param name="mockery">Mockery to create an event subscriber in</param>
        /// <param name="repository">Repository to subscribe the mocked subscriber to</param>
        /// <returns>The mocked event subscriber</returns>
        private static Mock <IAssemblyLoadedSubscriber> mockSubscriber(
            MockFactory mockery, PluginRepository repository
            )
        {
            Mock <IAssemblyLoadedSubscriber> mockedSubscriber =
                mockery.CreateMock <IAssemblyLoadedSubscriber>();

            repository.AssemblyLoaded += new AssemblyLoadEventHandler(
                mockedSubscriber.MockObject.AssemblyLoaded
                );

            return(mockedSubscriber);
        }
コード例 #6
0
        public void TestAssemblyLoadingWithEmployFailure()
        {
            PluginRepository testRepository = new PluginRepository();
            PluginHost       testHost       = new PluginHost(new FailingEmployer(), testRepository);

            // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
            // the unit testing tool
            Assembly self = Assembly.GetAssembly(GetType());

            testRepository.AddAssembly(self);

            Assert.AreSame(testRepository, testHost.Repository);
        }
コード例 #7
0
ファイル: PluginRepository.Test.cs プロジェクト: minskowl/MY
        /// <summary>Mocks a subscriber for the events of a plugin repository</summary>
        /// <param name="mockery">Mockery to create an event subscriber in</param>
        /// <param name="repository">Repository to subscribe the mocked subscriber to</param>
        /// <returns>The mocked event subscriber</returns>
        private static IAssemblyLoadedSubscriber mockSubscriber(
            Mockery mockery, PluginRepository repository
            )
        {
            IAssemblyLoadedSubscriber mockedSubscriber =
                mockery.NewMock <IAssemblyLoadedSubscriber>();

            repository.AssemblyLoaded += new AssemblyLoadEventHandler(
                mockedSubscriber.AssemblyLoaded
                );

            return(mockedSubscriber);
        }
コード例 #8
0
    public void TestFullConstructorWithPreloadedAssembly() {
      PluginRepository testRepository = new PluginRepository();
      FactoryEmployer<PluginRepository> testEmployer = new FactoryEmployer<PluginRepository>();

      // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
      // the unit testing tool
      Assembly self = Assembly.GetAssembly(GetType());
      testRepository.AddAssembly(self);

      PluginHost testHost = new PluginHost(testEmployer, testRepository);

      Assert.AreSame(testEmployer, testHost.Employer);
      Assert.AreEqual(1, testEmployer.Factories.Count);
    }
コード例 #9
0
        public void TestAssemblyLoadingWithNoPluginAttribute()
        {
            PluginRepository testRepository = new PluginRepository();
            FactoryEmployer <PluginHostTest> testEmployer = new FactoryEmployer <PluginHostTest>();
            PluginHost testHost = new PluginHost(testEmployer, testRepository);

            // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
            // the unit testing tool
            Assembly self = Assembly.GetAssembly(GetType());

            testRepository.AddAssembly(self);

            Assert.AreSame(testRepository, testHost.Repository);
            Assert.AreEqual(0, testEmployer.Factories.Count);
        }
コード例 #10
0
ファイル: PluginRepository.Test.cs プロジェクト: minskowl/MY
        public void TestAssemblyLoadedEvent()
        {
            Mockery mockery = new Mockery();

            PluginRepository          testRepository = new PluginRepository();
            IAssemblyLoadedSubscriber subscriber     = mockSubscriber(mockery, testRepository);

            Expect.Once.On(subscriber).Method("AssemblyLoaded").WithAnyArguments();

            Assembly self = Assembly.GetAssembly(GetType());

            testRepository.AddAssembly(self);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #11
0
        public void TestAssemblyLoadedEvent()
        {
            MockFactory mockery = new MockFactory();

            PluginRepository testRepository             = new PluginRepository();
            Mock <IAssemblyLoadedSubscriber> subscriber = mockSubscriber(mockery, testRepository);

            subscriber.Expects.One.Method(m => m.AssemblyLoaded(null, null)).WithAnyArguments();

            Assembly self = Assembly.GetAssembly(GetType());

            testRepository.AddAssembly(self);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #12
0
        public void TestFullConstructorWithPreloadedAssembly()
        {
            PluginRepository testRepository = new PluginRepository();
            FactoryEmployer <PluginRepository> testEmployer = new FactoryEmployer <PluginRepository>();

            // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
            // the unit testing tool
            Assembly self = Assembly.GetAssembly(GetType());

            testRepository.AddAssembly(self);

            PluginHost testHost = new PluginHost(testEmployer, testRepository);

            Assert.AreSame(testEmployer, testHost.Employer);
            Assert.AreEqual(1, testEmployer.Factories.Count);
        }
コード例 #13
0
    public void TestAssemblyLoadedEvent() {
      Mockery mockery = new Mockery();

      PluginRepository testRepository = new PluginRepository();
      IAssemblyLoadedSubscriber subscriber = mockSubscriber(mockery, testRepository);

      Expect.Once.On(subscriber).Method("AssemblyLoaded").WithAnyArguments();

      Assembly self = Assembly.GetAssembly(GetType());
      testRepository.AddAssembly(self);

      mockery.VerifyAllExpectationsHaveBeenMet();
    }
コード例 #14
0
    public void TestAddAssembly() {
      PluginRepository testRepository = new PluginRepository();

      // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
      // the unit testing tool
      Assembly self = Assembly.GetAssembly(GetType());
      testRepository.AddAssembly(self);

      Assert.AreEqual(1, testRepository.LoadedAssemblies.Count);
    }
コード例 #15
0
    public void TestAddFilesWithOwnAssembly() {
      PluginRepository testRepository = new PluginRepository();

      Assembly self = Assembly.GetAssembly(GetType());
      testRepository.AddFiles(self.Location);

      Assert.AreEqual(1, testRepository.LoadedAssemblies.Count);
    }
コード例 #16
0
 public void TestAddFilesWithZeroMatches() {
   PluginRepository testRepository = new PluginRepository();
   testRepository.AddFiles(Guid.NewGuid().ToString());
 }
コード例 #17
0
    public void TestEmployerStorage() {
      PluginRepository testRepository = new PluginRepository();
      FactoryEmployer<PluginRepository> testEmployer = new FactoryEmployer<PluginRepository>();
      PluginHost testHost = new PluginHost(testEmployer, testRepository);

      Assert.AreSame(testEmployer, testHost.Employer);
    }
コード例 #18
0
    public void TestAssemblyLoadingWithEmployFailure() {
      PluginRepository testRepository = new PluginRepository();
      PluginHost testHost = new PluginHost(new FailingEmployer(), testRepository);

      // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
      // the unit testing tool
      Assembly self = Assembly.GetAssembly(GetType());
      testRepository.AddAssembly(self);

      Assert.AreSame(testRepository, testHost.Repository);
    }
コード例 #19
0
    /// <summary>Mocks a subscriber for the events of a plugin repository</summary>
    /// <param name="mockery">Mockery to create an event subscriber in</param>
    /// <param name="repository">Repository to subscribe the mocked subscriber to</param>
    /// <returns>The mocked event subscriber</returns>
    private static IAssemblyLoadedSubscriber mockSubscriber(
      Mockery mockery, PluginRepository repository
    ) {
      IAssemblyLoadedSubscriber mockedSubscriber =
        mockery.NewMock<IAssemblyLoadedSubscriber>();

      repository.AssemblyLoaded += new AssemblyLoadEventHandler(
        mockedSubscriber.AssemblyLoaded
      );

      return mockedSubscriber;
    }
コード例 #20
0
    public void TestAssemblyLoadingWithNoPluginAttribute() {
      PluginRepository testRepository = new PluginRepository();
      FactoryEmployer<PluginHostTest> testEmployer = new FactoryEmployer<PluginHostTest>();
      PluginHost testHost = new PluginHost(testEmployer, testRepository);

      // Might also use Assembly.GetCallingAssembly() here, but this leads to the exe of
      // the unit testing tool
      Assembly self = Assembly.GetAssembly(GetType());
      testRepository.AddAssembly(self);

      Assert.AreSame(testRepository, testHost.Repository);
      Assert.AreEqual(0, testEmployer.Factories.Count);
    }
コード例 #21
0
ファイル: PluginRepository.Test.cs プロジェクト: minskowl/MY
        public void TestAddFilesWithZeroMatches()
        {
            PluginRepository testRepository = new PluginRepository();

            testRepository.AddFiles(Guid.NewGuid().ToString());
        }