From 570290b617a84f0f6f81f2279e47c452662e74d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20K=C3=B6nig?= Date: Wed, 13 Oct 2021 15:25:20 +0200 Subject: [PATCH] Fixed unittests --- .../ViewServiceContainerTests.cs | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/MessageCommunicator.TestGui.Tests/ViewServiceContainerTests.cs b/src/MessageCommunicator.TestGui.Tests/ViewServiceContainerTests.cs index 0da22e1..6b9ed12 100644 --- a/src/MessageCommunicator.TestGui.Tests/ViewServiceContainerTests.cs +++ b/src/MessageCommunicator.TestGui.Tests/ViewServiceContainerTests.cs @@ -5,6 +5,7 @@ using System.Text; using Avalonia.Controls; using FakeItEasy; +using FirLib.Core.Patterns.Mvvm; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MessageCommunicator.TestGui.Tests @@ -15,8 +16,8 @@ public class ViewServiceContainerTests [TestMethod] public void Check_EmptyObject() { - var fakeOwner = A.Fake(); - var viewServiceContainer = new ViewServiceContainer(fakeOwner); + var fakeOwner = A.Fake(); + var viewServiceContainer = new OwnViewServiceContainer(fakeOwner); Assert.IsFalse(viewServiceContainer.IsObserving); } @@ -24,8 +25,8 @@ public void Check_EmptyObject() [TestMethod] public void Check_RegisterNullViewModel() { - var fakeOwner = A.Fake(); - var viewServiceContainer = new ViewServiceContainer(fakeOwner); + var fakeOwner = A.Fake(); + var viewServiceContainer = new OwnViewServiceContainer(fakeOwner); var compositeDisposable = new CompositeDisposable(); viewServiceContainer.StartObserving(compositeDisposable, null); @@ -37,8 +38,8 @@ public void Check_RegisterNullViewModel() [TestMethod] public void Check_RegisterNullViewModel_WithDeregister() { - var fakeOwner = A.Fake(); - var viewServiceContainer = new ViewServiceContainer(fakeOwner); + var fakeOwner = A.Fake(); + var viewServiceContainer = new OwnViewServiceContainer(fakeOwner); var compositeDisposable = new CompositeDisposable(); viewServiceContainer.StartObserving(compositeDisposable, null); @@ -52,8 +53,8 @@ public void Check_RegisterNullViewModel_WithDeregister() [TestMethod] public void Check_RegisterNullViewModel_WithViewService() { - var fakeOwner = A.Fake(); - var viewServiceContainer = new ViewServiceContainer(fakeOwner); + var fakeOwner = A.Fake(); + var viewServiceContainer = new OwnViewServiceContainer(fakeOwner); var fakeViewService1 = A.Fake(); var fakeViewService2 = A.Fake(); @@ -73,8 +74,8 @@ public void Check_RegisterNullViewModel_WithViewService() [TestMethod] public void Check_RegisterNullViewModel__WithDeregister_WithViewService() { - var fakeOwner = A.Fake(); - var viewServiceContainer = new ViewServiceContainer(fakeOwner); + var fakeOwner = A.Fake(); + var viewServiceContainer = new OwnViewServiceContainer(fakeOwner); var fakeViewService1 = A.Fake(); var fakeViewService2 = A.Fake(); @@ -90,9 +91,18 @@ public void Check_RegisterNullViewModel__WithDeregister_WithViewService() Assert.IsTrue(compositeDisposable.Count == 0); Assert.IsFalse(viewServiceContainer.IsObserving); Assert.IsTrue(Fake.GetCalls(fakeViewService1).Any(actCall => actCall.Method.Name == $"add_{nameof(IViewService.ViewServiceRequest)}")); - Assert.IsTrue(Fake.GetCalls(fakeViewService1).Any(actCall => actCall.Method.Name == $"remove_{nameof(IViewService.ViewServiceRequest)}")); Assert.IsTrue(Fake.GetCalls(fakeViewService2).Any(actCall => actCall.Method.Name == $"add_{nameof(IViewService.ViewServiceRequest)}")); - Assert.IsTrue(Fake.GetCalls(fakeViewService2).Any(actCall => actCall.Method.Name == $"remove_{nameof(IViewService.ViewServiceRequest)}")); + } + + //********************************************************************* + //********************************************************************* + //********************************************************************* + /// + /// Helper for Unit tests + /// + public interface IViewServiceHostControl : IControl, IViewServiceHost + { + } } }