Skip to content

Commit

Permalink
Fixed unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandKoenig committed Oct 13, 2021
1 parent 3f8bb52 commit 570290b
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/MessageCommunicator.TestGui.Tests/ViewServiceContainerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,17 +16,17 @@ public class ViewServiceContainerTests
[TestMethod]
public void Check_EmptyObject()
{
var fakeOwner = A.Fake<IControl>();
var viewServiceContainer = new ViewServiceContainer(fakeOwner);
var fakeOwner = A.Fake<IViewServiceHostControl>();
var viewServiceContainer = new OwnViewServiceContainer(fakeOwner);

Assert.IsFalse(viewServiceContainer.IsObserving);
}

[TestMethod]
public void Check_RegisterNullViewModel()
{
var fakeOwner = A.Fake<IControl>();
var viewServiceContainer = new ViewServiceContainer(fakeOwner);
var fakeOwner = A.Fake<IViewServiceHostControl>();
var viewServiceContainer = new OwnViewServiceContainer(fakeOwner);

var compositeDisposable = new CompositeDisposable();
viewServiceContainer.StartObserving(compositeDisposable, null);
Expand All @@ -37,8 +38,8 @@ public void Check_RegisterNullViewModel()
[TestMethod]
public void Check_RegisterNullViewModel_WithDeregister()
{
var fakeOwner = A.Fake<IControl>();
var viewServiceContainer = new ViewServiceContainer(fakeOwner);
var fakeOwner = A.Fake<IViewServiceHostControl>();
var viewServiceContainer = new OwnViewServiceContainer(fakeOwner);

var compositeDisposable = new CompositeDisposable();
viewServiceContainer.StartObserving(compositeDisposable, null);
Expand All @@ -52,8 +53,8 @@ public void Check_RegisterNullViewModel_WithDeregister()
[TestMethod]
public void Check_RegisterNullViewModel_WithViewService()
{
var fakeOwner = A.Fake<IControl>();
var viewServiceContainer = new ViewServiceContainer(fakeOwner);
var fakeOwner = A.Fake<IViewServiceHostControl>();
var viewServiceContainer = new OwnViewServiceContainer(fakeOwner);
var fakeViewService1 = A.Fake<IViewService>();
var fakeViewService2 = A.Fake<IViewService>();

Expand All @@ -73,8 +74,8 @@ public void Check_RegisterNullViewModel_WithViewService()
[TestMethod]
public void Check_RegisterNullViewModel__WithDeregister_WithViewService()
{
var fakeOwner = A.Fake<IControl>();
var viewServiceContainer = new ViewServiceContainer(fakeOwner);
var fakeOwner = A.Fake<IViewServiceHostControl>();
var viewServiceContainer = new OwnViewServiceContainer(fakeOwner);
var fakeViewService1 = A.Fake<IViewService>();
var fakeViewService2 = A.Fake<IViewService>();

Expand All @@ -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)}"));
}

//*********************************************************************
//*********************************************************************
//*********************************************************************
/// <summary>
/// Helper for Unit tests
/// </summary>
public interface IViewServiceHostControl : IControl, IViewServiceHost
{

}
}
}

0 comments on commit 570290b

Please sign in to comment.