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
6 changes: 6 additions & 0 deletions CourseApp.Tests/CourseApp.Tests.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27428.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "CourseApp.Tests.csproj", "{F0AA3B44-F9EE-4875-88F6-26523A7914C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "..\CourseApp\CourseApp.csproj", "{A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{F0AA3B44-F9EE-4875-88F6-26523A7914C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0AA3B44-F9EE-4875-88F6-26523A7914C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0AA3B44-F9EE-4875-88F6-26523A7914C9}.Release|Any CPU.Build.0 = Release|Any CPU
{A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
69 changes: 69 additions & 0 deletions CourseApp.Tests/UnitTest3.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Xunit;
using ConsoleApp2;
using static ConsoleApp2.Furniture;

namespace CourseApp.Tests
{
Expand Down Expand Up @@ -30,5 +31,73 @@ public void TestElementInMassive()
Assert.Equal("Polsha", furniture[1].Produced);
Assert.Equal("derevo", furniture[1].Material);
}

[Fact]
public void TestIComparable1()
{
Furniture[] furnitur = new Furniture[2];
furnitur[0] = new Stol("B");
furnitur[1] = new Shcaf("Aljir");
Array.Sort(furnitur);
Assert.Equal("Aljir", furnitur[0].Name);
}

[Fact]
public void TestIComparable2()
{
Furniture[] furnitur = new Furniture[4];
furnitur[0] = new Stol("Ru");
furnitur[1] = new Shcaf("Ge");
furnitur[2] = new Shcaf("Al");
furnitur[3] = new Stol("Be");
Array.Sort(furnitur);
Assert.Equal("Al", furnitur[0].Name);
Assert.Equal("Be", furnitur[1].Name);
Assert.Equal("Ge", furnitur[2].Name);
Assert.Equal("Ru", furnitur[3].Name);
}

[Fact]
public void TestIComparable3()
{
Furniture[] furnitur = new Furniture[4];
furnitur[0] = new Stol("1");
furnitur[1] = new Shcaf("A");
furnitur[2] = new Shcaf("S");
furnitur[3] = new Stol("2");
Array.Sort(furnitur);
Assert.Equal("1", furnitur[0].Name);
Assert.Equal("2", furnitur[1].Name);
Assert.Equal("A", furnitur[2].Name);
Assert.Equal("S", furnitur[3].Name);
}

[Fact]
public void TestIPrint1()
{
Stol stol2 = new Stol("Russia", 160, 200);
Assert.Equal("Stol", stol2.Mebel());
}

[Fact]
public void TestIPrint2()
{
Shcaf shcaf1 = new Shcaf("Russia", "Supastol", "береза");
Assert.Equal("Schaf", shcaf1.Mebel());
}

[Fact]
public void TestIPrint3()
{
Stol stol3 = new Stol("Russia", 200, 200);
Assert.Equal(40000, stol3.Ploshad());
}

[Fact]
public void TestIPrint4()
{
Stol stol1 = new Stol("Rus", 160, 200);
Assert.Equal(32000, stol1.Ploshad());
}
}
}
4 changes: 4 additions & 0 deletions CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Program1.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>
Expand Down
17 changes: 16 additions & 1 deletion CourseApp/Furniture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace ConsoleApp2
{
using System;

public abstract class Furniture
public abstract partial class Furniture : IComparable<Furniture>, IPrint
{
private string produced;
private string name;
Expand Down Expand Up @@ -64,5 +64,20 @@ public override string ToString()
}

public abstract string GetInfo();

public int CompareTo(Furniture other)
{
return Name.CompareTo(other.Name);
}

public virtual string Mebel()
{
return "Ya mebel'";
}

public int Ploshad()
{
return height * length;
}
}
}
9 changes: 9 additions & 0 deletions CourseApp/IPrint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace ConsoleApp2
{
public interface IPrint
{
string Mebel();

int Ploshad();
}
}
10 changes: 10 additions & 0 deletions CourseApp/Shcaf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public Shcaf()
Name = "chto-to";
}

public Shcaf(string name)
{
Name = name;
}

public Shcaf(string produced, string name, string material)
: base(produced, name)
{
Expand All @@ -29,5 +34,10 @@ public override string GetInfo()
{
return $"Произведенно в:{Produced} Имя:{Name} Материал:{Material}";
}

public override string Mebel()
{
return "Shcaf";
}
}
}
14 changes: 11 additions & 3 deletions CourseApp/Stol.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace ConsoleApp2
namespace ConsoleApp2
{
using System;

Expand All @@ -12,6 +10,11 @@ public Stol()
Produced = "Russia";
}

public Stol(string name)
{
Name = name;
}

public Stol(string produced, string name, int length, int height)
: base(produced, name)
{
Expand All @@ -38,5 +41,10 @@ public override string GetInfo()
{
return $"Произведенно в : {Produced} Имя: {Name} Длина: {Lenght} Высота: {Height}";
}

public override string Mebel()
{
return "Stol";
}
}
}
Loading