[longomatch] Add some test to check service startup.
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add some test to check service startup.
- Date: Fri, 17 Apr 2015 16:23:35 +0000 (UTC)
commit a055112b24095faf6f5187816510ac90d5ee35c2
Author: Julien Moutte <julien fluendo com>
Date: Mon Apr 13 17:44:06 2015 +0200
Add some test to check service startup.
Tests/Makefile.am | 1 +
Tests/Services/TestServices.cs | 73 ++++++++++++++++++++++++++++++++++++++++
Tests/Tests.csproj | 1 +
3 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/Tests/Makefile.am b/Tests/Makefile.am
index 6b5dfca..2c4455d 100644
--- a/Tests/Makefile.am
+++ b/Tests/Makefile.am
@@ -43,6 +43,7 @@ SOURCES = Core/Common/TestColor.cs \
Services/TestFileStorage.cs \
Services/TestPlayerController.cs \
Services/TestRenderingJobsManager.cs \
+ Services/TestServices.cs \
Services/TestTemplatesService.cs \
Utils.cs
diff --git a/Tests/Services/TestServices.cs b/Tests/Services/TestServices.cs
new file mode 100644
index 0000000..9ad8ce0
--- /dev/null
+++ b/Tests/Services/TestServices.cs
@@ -0,0 +1,73 @@
+//
+// 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 System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Moq;
+using LongoMatch.Core.Interfaces;
+using LongoMatch.Services;
+
+namespace Tests.Services
+{
+ [TestFixture ()]
+ public class TestServices
+ {
+ [Test ()]
+ public void TestServicesStartStop ()
+ {
+ List<int> levels = new List<int> ();
+
+ var msvc1 = new Mock<IService> ();
+ var msvc2 = new Mock<IService> ();
+
+ msvc1.SetupGet (s => s.Level).Returns (10);
+ msvc1.Setup (s => s.Start ()).Returns (true).Callback (() => levels.Add (10));
+ msvc1.Setup (s => s.Stop ()).Returns (true).Callback (() => levels.Add (10));
+ msvc2.SetupGet (s => s.Level).Returns (20);
+ msvc2.Setup (s => s.Start ()).Returns (true).Callback (() => levels.Add (20));
+ msvc2.Setup (s => s.Stop ()).Returns (true).Callback (() => levels.Add (20));
+
+ CoreServices.RegisterService (msvc1.Object);
+ CoreServices.RegisterService (msvc2.Object);
+
+ msvc1.Verify (s => s.Start (), Times.Never);
+ msvc2.Verify (s => s.Start (), Times.Never);
+ msvc1.Verify (s => s.Stop (), Times.Never);
+ msvc2.Verify (s => s.Stop (), Times.Never);
+
+ CoreServices.StartServices ();
+
+ msvc1.Verify (s => s.Start (), Times.Once);
+ msvc2.Verify (s => s.Start (), Times.Once);
+ msvc1.Verify (s => s.Stop (), Times.Never);
+ msvc2.Verify (s => s.Stop (), Times.Never);
+ Assert.AreEqual (new List<int> { 10, 20 }, levels);
+
+ levels.Clear ();
+
+ CoreServices.StopServices ();
+
+ msvc1.Verify (s => s.Start (), Times.Once);
+ msvc2.Verify (s => s.Start (), Times.Once);
+ msvc1.Verify (s => s.Stop (), Times.Once);
+ msvc2.Verify (s => s.Stop (), Times.Once);
+ Assert.AreEqual (new List<int> { 20, 10 }, levels);
+ }
+ }
+}
+
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index 964f421..0037f2e 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -85,6 +85,7 @@
<Compile Include="Services\TestPlayerController.cs" />
<Compile Include="Core\Store\TestActionLink.cs" />
<Compile Include="Core\Store\Templates\TestDashboard.cs" />
+ <Compile Include="Services\TestServices.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LongoMatch.Core\LongoMatch.Core.csproj">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]