[longomatch] Add unit test for RenderingJobsManager with new dependency.



commit 5cf758bccf5bb8944f3a09413a7d516684ba2ebf
Author: Julien Moutte <julien fluendo com>
Date:   Tue Mar 17 18:13:24 2015 +0100

    Add unit test for RenderingJobsManager with new dependency.
    
    We now use Moq for mocking the services and implement service unit tests.

 Tests/Makefile.am                          |    1 +
 Tests/Services/TestRenderingJobsManager.cs |   74 ++++++++++++++++++++++++++++
 Tests/Tests.csproj                         |    2 +
 3 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/Tests/Makefile.am b/Tests/Makefile.am
index 9897754..34bd926 100644
--- a/Tests/Makefile.am
+++ b/Tests/Makefile.am
@@ -38,6 +38,7 @@ SOURCES = Core/Common/TestColor.cs \
        Core/Store/TestTimer.cs \
        DB/TestStorage.cs \
        Services/TestFileStorage.cs \
+       Services/TestRenderingJobsManager.cs \
        Utils.cs
 
 RESOURCES = Core/dibujo.svg
diff --git a/Tests/Services/TestRenderingJobsManager.cs b/Tests/Services/TestRenderingJobsManager.cs
new file mode 100644
index 0000000..4a52ac2
--- /dev/null
+++ b/Tests/Services/TestRenderingJobsManager.cs
@@ -0,0 +1,74 @@
+//
+//  Copyright (C) 2015 FLUENDO S.A.
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using NUnit.Framework;
+using Moq;
+using LongoMatch;
+using LongoMatch.Core.Common;
+using LongoMatch.Core.Interfaces.GUI;
+using LongoMatch.Core.Interfaces.Multimedia;
+using LongoMatch.Core.Store;
+using LongoMatch.Core.Store.Playlists;
+using LongoMatch.Services;
+
+namespace Tests.Services
+{
+       [TestFixture ()]
+       public class TestRenderingJobsManager
+       {
+               [Test ()]
+               public void TestMediaFileUsage ()
+               {
+                       Project p = Utils.CreateProject ();
+
+                       try {
+                               PlaylistPlayElement element = new PlaylistPlayElement (p.Timeline [0], 
p.Description.FileSet);
+
+                               // Playlist with one event
+                               var playlist = new Playlist ();
+                               playlist.Elements.Add (element);
+
+                               // Create a job
+                               const string outputFile = "path";
+                               EncodingSettings settings = new EncodingSettings (VideoStandards.P720, 
EncodingProfiles.MP4, EncodingQualities.Medium,
+                                                                   25, 1, outputFile, true, true, 20);
+                               EditionJob job = new EditionJob (playlist, settings);
+
+                               // Mock IMultimediaToolkit and video editor
+                               var mtk = Mock.Of<IMultimediaToolkit> (m => m.GetVideoEditor () == 
Mock.Of<IVideoEditor> ());
+                               // and guitoolkit
+                               var gtk = Mock.Of<IGUIToolkit> (g => g.RenderingStateBar == 
Mock.Of<IRenderingStateBar> ());
+                               // And eventbroker
+                               Config.EventsBroker = Mock.Of<EventsBroker> ();
+
+                               // Create a rendering object with mocked interfaces
+                               RenderingJobsManager renderer = new RenderingJobsManager (mtk, gtk);
+
+                               renderer.AddJob (job);
+
+                               // Check that AddSegment is called with the right video file.
+                               var mock = Mock.Get<IVideoEditor> (mtk.GetVideoEditor ());
+                               mock.Verify (m => m.AddSegment (It.Is<string> (f => f == 
p.Description.FileSet [0].FilePath),
+                                       It.IsAny<long> (), It.IsAny<long> (), It.IsAny<double> (), 
It.IsAny<string> (), It.IsAny<bool> ()));
+
+                       } finally {
+                               Utils.DeleteProject (p);
+                       }
+               }
+       }
+}
+
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index 3d44a0b..ef288e7 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -32,6 +32,7 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="nunit.framework" />
+    <Reference Include="Moq" />
     <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b9a188c8922137c6">
       <Package>newtonsoft-json</Package>
     </Reference>
@@ -79,6 +80,7 @@
     <Compile Include="Core\Store\TestCoordinates.cs" />
     <Compile Include="DB\TestStorage.cs" />
     <Compile Include="Services\TestTemplatesService.cs" />
+    <Compile Include="Services\TestRenderingJobsManager.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\LongoMatch.Core\LongoMatch.Core.csproj">


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]