Addind more Unit Test

This commit is contained in:
Brady Bodily
2019-10-25 15:39:00 -06:00
parent ada7171a9d
commit 557ed0a03c
10 changed files with 284 additions and 40 deletions

View File

@@ -1,14 +1,20 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("UnitTests")]
namespace Shapes
{
[DataContract]
public class Circle : GeometricShape
{
internal IFileIO _fileWriter;
/**
* Constructor with x-y Location for center
*
@@ -19,6 +25,7 @@ namespace Shapes
*/
public Circle(double x, double y, double radius)
{
_fileWriter = new FileIO();
Stroke = Color.Black;
Validator.ValidatePositiveDouble(radius, "Invalid radius");
CenterPoint = new Point(x, y);
@@ -36,10 +43,9 @@ namespace Shapes
*/
public Circle(Point center, double radius)
{
_fileWriter = new FileIO();
Stroke = Color.Black;
Validator.ValidatePositiveDouble(radius, "Invalid radius");
if (center == null)
throw new ShapeException("Invalid center point");
CenterPoint = center;
Radius = radius;
Height = radius * 2;
@@ -58,6 +64,7 @@ namespace Shapes
[DataMember] public override double Width { get; internal set; }
[ExcludeFromCodeCoverage]
internal override void ComputeCenter()
{
//Does nothing to a circle
@@ -80,10 +87,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((int) Radius * 4, (int) Radius * 4);

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
@@ -112,6 +113,7 @@ namespace Shapes
public override void Scale(double scaleFactor)
{
Validator.ValidatePositiveDouble(scaleFactor, "Invalid scale factor");
foreach (var point in Points)
{
point.X *= scaleFactor;
@@ -124,6 +126,7 @@ namespace Shapes
_fileWriter.SaveShape(stream, this);
}
[ExcludeFromCodeCoverage]
public override void Draw(Stream stream)
{
var tmp = new Bitmap((int) Width * 2, (int) Height * 2);

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
@@ -28,6 +29,7 @@ namespace Shapes
public abstract void Scale(double scaleFactor);
public abstract void Save(Stream stream);
[ExcludeFromCodeCoverage]
public abstract void Draw(Stream stream);
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
@@ -88,19 +89,13 @@ namespace Shapes
public override void Scale(double scaleFactor)
{
Validator.ValidatePositiveDouble(scaleFactor, "Invalid scale factor");
foreach (var point in Points)
{
point.X *= scaleFactor;
point.Y *= scaleFactor;
}
foreach (var line in Lines)
{
line.Point1.X *= scaleFactor;
line.Point1.Y *= scaleFactor;
line.Point2.X *= scaleFactor;
line.Point2.Y *= scaleFactor;
}
}
public override void Save(Stream stream)
@@ -109,7 +104,7 @@ namespace Shapes
fileWriter.SaveShape(stream, this);
}
[ExcludeFromCodeCoverage]
public override void Draw(Stream stream)
{
var tmp = new Bitmap((int) Width * 2, (int) Height * 2);