コード例 #1
0
 public void TestInitialization() {
   GameServiceContainer gameServices = new GameServiceContainer();
   MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService();
   gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics);
   using(
     SharedContentManager contentManager = new SharedContentManager(gameServices)
   ) {
     contentManager.Initialize();
   }
 }
コード例 #2
0
 public void TestConstructor() {
   GameServiceContainer gameServices = new GameServiceContainer();
   MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService();
   gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics);
   using(
     SharedContentManager contentManager = new SharedContentManager(gameServices)
   ) {
     // Nonsense, but avoids compiler warning about unused variable :)
     Assert.IsNotNull(contentManager);
   }
 }
コード例 #3
0
 public void TestInitializationWithExistingGraphicsDevice() {
   GameServiceContainer gameServices = new GameServiceContainer();
   MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService();
   gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics);
   using(IDisposable keeper = mockedGraphics.CreateDevice()) {
     using(
       SharedContentManager contentManager = new SharedContentManager(gameServices)
     ) {
       contentManager.Initialize();
     }
   }
 }
コード例 #4
0
    public void TestServiceRegistration() {
      GameServiceContainer gameServices = new GameServiceContainer();
      MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService();
      gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics);
      using(
        SharedContentManager contentManager = new SharedContentManager(gameServices)
      ) {
        object service = gameServices.GetService(typeof(ISharedContentService));

        Assert.AreSame(contentManager, service);
      }
    }
コード例 #5
0
    public void TestDispose() {
      GameServiceContainer gameServices = new GameServiceContainer();
      MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService();
      gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics);
      using(
        SharedContentManager contentManager = new SharedContentManager(gameServices)
      ) {
        object service = gameServices.GetService(typeof(ISharedContentService));
        Assert.AreSame(contentManager, service);
      }

      // Make sure the service was unregistered again when the shared content manager
      // got disposed
      object serviceAfterDispose = gameServices.GetService(typeof(ISharedContentService));
      Assert.IsNull(serviceAfterDispose);
    }