public void TestInitialization() {
   GameServiceContainer gameServices = new GameServiceContainer();
   MockedGraphicsDeviceService mockedGraphics = new MockedGraphicsDeviceService();
   gameServices.AddService(typeof(IGraphicsDeviceService), mockedGraphics);
   using(
     SharedContentManager contentManager = new SharedContentManager(gameServices)
   ) {
     contentManager.Initialize();
   }
 }
 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);
   }
 }
 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();
     }
   }
 }
    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);
      }
    }
    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);
    }