Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CPKreu committed Dec 24, 2020
1 parent 8148e14 commit 0231803
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class BitmapManagerTests
public void TestThatBitmapManagerSetsCorrectTool()
{
BitmapManager bitmapManager = new BitmapManager();
bitmapManager.SetActiveTool(new MockedSinglePixelPen());
Assert.Equal(ToolType.Pen, bitmapManager.SelectedTool.ToolType);
bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
Assert.Equal(typeof(MockedSinglePixelPenTool), bitmapManager.SelectedTool.GetType());
}

[Fact]
Expand Down Expand Up @@ -63,7 +63,7 @@ public void TestThatGeneratePreviewLayerGeneratesPreviewLayer()
[Fact]
public void TestThatIsOperationToolWorks()
{
MockedSinglePixelPen singlePixelPen = new MockedSinglePixelPen();
MockedSinglePixelPenTool singlePixelPen = new MockedSinglePixelPenTool();
Assert.True(BitmapManager.IsOperationTool(singlePixelPen));
}

Expand All @@ -81,7 +81,7 @@ public void TestThatBitmapChangesExecuteToolExecutesPenTool()
bitmapManager.ActiveDocument = bitmapManager.Documents[0];

bitmapManager.ActiveDocument.AddNewLayer("Layer");
bitmapManager.SetActiveTool(new MockedSinglePixelPen());
bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
bitmapManager.PrimaryColor = Colors.Green;

bitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void TestThatBitmapOperationsUtilityExecutesPenToolProperly()

List<Coordinates> mouseMove = new List<Coordinates>(new[] { new Coordinates(0, 0) });

util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPen());
util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPenTool());
Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), Colors.Black);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System.Windows.Media;
using PixiEditor.Models.DataHolders;
using PixiEditor.Models.DataHolders;
using PixiEditor.Models.Layers;
using PixiEditor.Models.Position;
using PixiEditor.Models.Tools;
using System.Windows.Media;

namespace PixiEditorTests.ModelsTests.ControllersTests
{
public class MockedSinglePixelPen : BitmapOperationTool
public class MockedSinglePixelPenTool : BitmapOperationTool
{
public override ToolType ToolType { get; } = ToolType.Pen;

public override LayerChange[] Use(Layer layer, Coordinates[] mouseMove, Color color)
{
return Only(BitmapPixelChanges.FromSingleColoredArray(new[] { mouseMove[0] }, color), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public TestReadonlyTool(Action toolAction)

public Action ToolAction { get; set; }

public override ToolType ToolType => ToolType.Select;

public override void Use(Coordinates[] pixels)
{
ToolAction();
Expand Down
7 changes: 4 additions & 3 deletions PixiEditorTests/ViewModelsTests/ViewModelMainTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using PixiEditor.Models.IO;
using PixiEditor.Models.Position;
using PixiEditor.Models.Tools;
using PixiEditor.Models.Tools.Tools;
using PixiEditor.ViewModels;
using Xunit;

Expand Down Expand Up @@ -72,11 +73,11 @@ public void TestThatSelectToolCommandSelectsNewTool()
{
ViewModelMain viewModel = new ViewModelMain();

Assert.Equal(ToolType.Move, viewModel.BitmapManager.SelectedTool.ToolType);
Assert.Equal(typeof(MoveTool), viewModel.BitmapManager.SelectedTool.GetType());

viewModel.ToolsSubViewModel.SelectToolCommand.Execute(ToolType.Line);
viewModel.ToolsSubViewModel.SelectToolCommand.Execute(typeof(LineTool));

Assert.Equal(ToolType.Line, viewModel.BitmapManager.SelectedTool.ToolType);
Assert.Equal(typeof(LineTool), viewModel.BitmapManager.SelectedTool.GetType());
}

[StaFact]
Expand Down

0 comments on commit 0231803

Please sign in to comment.