public void ShouldNotRemoveAnyShape() { const int expectedCount = 1; var shapes = new List <IShape>() { new Square { SideLength = 2 } }; _MockShapesRepository.Setup(p => p.GetShapes()).Returns(shapes); _MockShapesRepository.Setup(p => p.RemoveShape(It.IsAny <IShape>())).Callback <IShape>(sh => shapes.Remove(sh)); var viewModel = new ShapesViewModel(_MockShapesRepository.Object, _MockComputeAreaService.Object, _MockSubmissionService.Object); viewModel.Start(); viewModel.SelectedShape = null; viewModel.RemoveShapeCommand.Execute(null); shapes.Count.Should().Be(expectedCount); }
public void ShouldAddShapeToShapesWhenShapeIsAddedToRepo() { const int expectedCount = 2; var shapes = new List <IShape>() { new Square { SideLength = 2 } }; _MockShapesRepository.Setup(p => p.GetShapes()).Returns(shapes); var viewModel = new ShapesViewModel(_MockShapesRepository.Object, _MockComputeAreaService.Object, _MockSubmissionService.Object); viewModel.Start(); _MockShapesRepository.Raise(repository => repository.ShapeAdded += null, new ShapeEventArgs(new Circle())); viewModel.Shapes.Count.Should().Be(expectedCount); }