Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Increased test coverage of TaggerController.
Browse files Browse the repository at this point in the history
  • Loading branch information
rold2007 committed Sep 23, 2017
1 parent 789e2b0 commit e03a076
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void Initialize()

// Must initialize the object detection controller first so that all points
// loaded by the tagger are sent to the object detection controller
this.taggerController.Initialize();
////this.taggerController.Initialize();
}

public void Close()
Expand Down
24 changes: 9 additions & 15 deletions Plugins/ImageProcessing/Controllers/TaggerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace ImageProcessing.Controllers
public class TaggerController
{
private TaggerService taggerService;
private string selectedLabel;

public TaggerController(TaggerService taggerService)
{
Expand All @@ -34,6 +33,12 @@ public IEnumerable<string> Labels
}
}

public string SelectedLabel
{
get;
private set;
}

public string DisplayName
{
get
Expand All @@ -42,17 +47,6 @@ public string DisplayName
}
}

public void Initialize()
{
////this.taggerView.SetTaggerModel(this.taggerModel);

////this.taggerView.LabelAdded += this.TaggerView_LabelAdded;

////this.imageManagerController.ActiveImageChanged += this.ImageManagerController_ActiveImageChanged;

this.RegisterActiveImage();
}

public void Close()
{
}
Expand All @@ -79,14 +73,14 @@ public void SelectLabel(string label)
this.taggerService.Labels.ShouldContain(label);
}

this.selectedLabel = label;
this.SelectedLabel = label;
}

public void SelectPixel(IImageSource imageSource, Point pixelPosition)
{
if (this.selectedLabel != null)
if (this.SelectedLabel != null)
{
this.taggerService.SelectPixel(imageSource, this.selectedLabel, pixelPosition);
this.taggerService.SelectPixel(imageSource, this.SelectedLabel, pixelPosition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,61 @@ public void RemovePoint()

taggerController.GetPoints(LabelName).Count.ShouldBe(0);
}

[Fact]
public void Close()
{
TaggerController taggerController = this.Container.GetInstance<TaggerController>();

taggerController.Close();
}

[Fact]
public void SelectLabel()
{
TaggerController taggerController = this.Container.GetInstance<TaggerController>();

taggerController.SelectedLabel.ShouldBeNull();

// Cannot select label which has not been added yet
Assert.Throws<Shouldly.ShouldAssertException>(() => { taggerController.SelectLabel(LabelName); });

taggerController.AddLabel(LabelName);

taggerController.SelectLabel(LabelName);

taggerController.SelectedLabel.ShouldBe(LabelName);

taggerController.SelectLabel(null);

taggerController.SelectedLabel.ShouldBeNull();
}

[Fact]
public void SelectPixel()
{
TaggerController taggerController = this.Container.GetInstance<TaggerController>();

taggerController.GetPoints(LabelName).Count().ShouldBe(0);

taggerController.SelectPixel(null, Point.Empty);

taggerController.GetPoints(LabelName).Count().ShouldBe(0);

taggerController.AddLabel(LabelName);

taggerController.SelectPixel(null, Point.Empty);

taggerController.GetPoints(LabelName).Count().ShouldBe(0);

taggerController.SelectLabel(LabelName);

taggerController.SelectPixel(null, new Point(42, 54));

taggerController.GetPoints(LabelName).Count().ShouldBe(1);

taggerController.GetPoints(LabelName)[0].X.ShouldBe(42);
taggerController.GetPoints(LabelName)[0].Y.ShouldBe(54);
}
}
}

0 comments on commit e03a076

Please sign in to comment.