unit tests are done

This commit is contained in:
Brady
2019-10-25 23:25:50 -06:00
parent 62c09e84d6
commit b64540c812
22 changed files with 569 additions and 115 deletions

View File

@@ -1,20 +1,37 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
[assembly:InternalsVisibleTo("UnitTests")]
namespace Shapes
{
[DataContract]
public class CompositeShape : Shape
{
private readonly List<Shape> thisShapesList = new List<Shape>();
[DataMember]
internal readonly List<Shape> thisShapesList = new List<Shape>();
[DataMember]
public override Color Fill { get; set; }
[DataMember]
public override Color Stroke { get; set; }
[DataMember]
public override List<Point> Points { get; protected set; }
internal IFileIO _fileWriter;
public CompositeShape()
{
Points = new List<Point>();
}
public void Add(Shape shape)
{
Stroke = Color.Black;
Points.AddRange(shape.Points);
if (shape.CompositeShape)
throw new ShapeException("This shape has already been added to a composite");
if (shape == this)
@@ -36,10 +53,10 @@ namespace Shapes
public override void Save(Stream stream)
{
var fileWriter = new FileIO();
fileWriter.SaveShape(stream, this);
_fileWriter.SaveShape(stream, this);
}
[ExcludeFromCodeCoverage]
public override void Draw(Stream stream)
{
var tmp = new Bitmap(1000, 1000);
@@ -60,6 +77,13 @@ namespace Shapes
public void RemoveShape(Shape shape)
{
if(Points.Count > 0)
{
foreach (var point in shape.Points)
{
Points.Remove(point);
}
}
if (!thisShapesList.Contains(shape))
throw new ShapeException($"{shape.GetType().Name} is not part of the composite shape.");
thisShapesList.Remove(shape);
@@ -71,7 +95,7 @@ namespace Shapes
while (thisShapesList.Count > 0)
{
thisShapesList[0].CompositeShape = false;
thisShapesList.Remove(thisShapesList[0]);
RemoveShape(thisShapesList[0]);
}
}
}