Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CourseApp\CourseApp.csproj" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet>
<GenerateFullPaths>true</GenerateFullPaths>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="../_stylecop/stylecop.json" />
</ItemGroup>

</Project>
85 changes: 58 additions & 27 deletions CourseApp.Tests/PlatypusTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,81 @@ namespace CourseApp.Tests
public class PlatypusTest
{
[Fact]
public void TestEmptyConstructor()
public void TestCreateTable()
{
var item = new Platypus();
Assert.Equal(0, item.Age);
Assert.Equal("Untitled", item.Name);
Assert.True(item.IsMale);
var item = new Table(12, 13, "white");
Assert.Equal(12, item.Weight);
Assert.Equal(13, item.Height);
Assert.Equal("white", item.Color);
}

[Fact]
public void TestView()
public void TestCreateTableWithoutColor()
{
var item = new Platypus();
var view = @"
_.-^~~^^^`~-,_,,~''''''```~,''``~'``~,
______,' -o :. _ . ; ,'`, `.
( -\.._,.;;'._ ,( } _`_-_,, `, `,
``~~~~~~' ((/'((((____/~~~~~~'(,(,___> `~'
";
Assert.Equal(view, item.View());
var item = new Table(12, 13);
Assert.Equal(12, item.Weight);
Assert.Equal(13, item.Height);
Assert.Equal("black", item.Color);
}

[Fact]
public void TestSetAge()
public void TestGetToString()
{
var item = new Platypus();
item.Age = 5;
Assert.Equal(5, item.Age);
var ecString = "Weight = 400, Height = 400, Color = black";
var item = new Table(400, 400, "black");
Assert.Equal(ecString, item.ToString());
}

[Fact]
public void TestIncorrectSetAge()
public void TestCreateTableWithWrongWeigth()
{
var item = new Platypus();
item.Age = -5;
Assert.Equal(0, item.Age);
try
{
var item = new Table(0, 12, "red");
}
catch (Exception exc)
{
Assert.Equal("Value does not fall within the expected range.", exc.Message);
}
}

[Fact]
public void TestCorrectIncorrectSetAge()
public void TestCreateTableWithWrongHeigth()
{
var item = new Platypus();
item.Age = 10;
item.Age = -5;
Assert.Equal(10, item.Age);
try
{
var item = new Table(12, 0, "red");
}
catch (Exception exc)
{
Assert.Equal("Value does not fall within the expected range.", exc.Message);
}
}

[Fact]
public void TestCreateTableWithWrongColorNull()
{
try
{
var item = new Table(12, 12, null);
}
catch (Exception exc)
{
Assert.Equal("Value does not fall within the expected range.", exc.Message);
}
}

[Fact]
public void TestCreateTableWithWrongColorEmpty()
{
try
{
var item = new Table(12, 12, string.Empty);
}
catch (Exception exc)
{
Assert.Equal("Value does not fall within the expected range.", exc.Message);
}
}
}
}
3 changes: 0 additions & 3 deletions CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet>
<GenerateFullPaths>true</GenerateFullPaths>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="../_stylecop/stylecop.json" />
</ItemGroup>

</Project>
60 changes: 0 additions & 60 deletions CourseApp/Platypus.cs

This file was deleted.

23 changes: 20 additions & 3 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,27 @@ public static void Main(string[] args)
Console.WriteLine($"x={xB[i]} y={taskB[i]}");
}

var item = new Platypus();
Console.WriteLine(item.View());
List<Table> tables = new List<Table>()
{
new Table(12, 12),
new Table(12, 12, "red")
};

for (int i = 0; i < tables.Count; i++)
{
Console.WriteLine(tables[i].ToString());
}

try
{
tables.Add(new Table(0, 12, null));
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}

Console.ReadLine();
Console.ReadLine();
}
}
}
30 changes: 30 additions & 0 deletions CourseApp/Table.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;

namespace CourseApp
{
public class Table
{
public Table(double weight, double height, string color = "black")
{
if (weight == 0 || height == 0 || string.IsNullOrEmpty(color))
{
throw new ArgumentException();
}

Weight = weight;
Height = height;
Color = color;
}

public double Weight { get; private set; }

public double Height { get; private set; }

public string Color { get; private set; }

public override string ToString()
{
return "Weight = " + Weight + ", Height = " + Height + ", Color = " + Color;
}
}
}
12 changes: 0 additions & 12 deletions _stylecop/stylecop.json

This file was deleted.

14 changes: 0 additions & 14 deletions _stylecop/stylecop.ruleset

This file was deleted.