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
30 changes: 30 additions & 0 deletions CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<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>
22 changes: 22 additions & 0 deletions CourseApp.Tests/TestAbstractClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestAbstractClass
{
[Fact]
public void Test_ProverkaRabotyMassivaClassov()
{
Pet[] pet = new Pet[2];
pet[0] = new Dog();
pet[1] = new Cat();
foreach (Pet i in pet)
{
Assert.Equal(15, i.Age);
Assert.Equal("K", i.Pol);
}
}
}
}
64 changes: 64 additions & 0 deletions CourseApp.Tests/TestCat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestCat
{
[Fact]
public void Test_ProverkaBezZnachenij()
{
Cat murka = new Cat();

Assert.Equal(15, murka.Age);
Assert.Equal(15.0f, murka.Weight);
Assert.Equal("K", murka.Pol);
}

[Fact]
public void Test_ProverkaPolaBoy()
{
Cat murka = new Cat("K");
Assert.Equal(9, murka.Age);
Assert.Equal(10.0f, murka.Weight);
}

[Fact]
public void Test_ProverkaPolaGirl()
{
Cat murka = new Cat("Kisa");
Assert.Equal(11, murka.Age);
Assert.Equal(12.0f, murka.Weight);
}

[Fact]
public void Test_ProverkaMetodaPicture()
{
Cat murka = new Cat();
Assert.Equal(
@"
/\___/\
( o o )
/ * \
\__\_/__/ meow!
/ \
/ ___ \
\/___\/", murka.Picture());
}

[Fact]
public void Test_ProverkaMetodaGolos()
{
Cat murka = new Cat();
Assert.Equal($"��� �������� {15} ����� ����� ��� ", murka.Golos());
}

[Fact]
public void Test_ProverkaMetodaToString()
{
Cat murka = new Cat();
Assert.Equal("��� �������� 15 � ����� K", murka.ToString());
}
}
}
33 changes: 33 additions & 0 deletions CourseApp.Tests/TestDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestDate
{
private readonly Date birthday = new Date();
private readonly DateTime today = new DateTime(2019, 3, 5);

[Fact]
public void TestDate20070909()
{
DateTime age = new DateTime(2007, 09, 09);
Assert.Equal(@"Year: 11 Month: 05 Day: 27 ", birthday.Age(age, today));
}

[Fact]
public void TestDate19800515()
{
DateTime age = new DateTime(1980, 05, 15);
Assert.Equal(@"Year: 38 Month: 09 Day: 20 ", birthday.Age(age, today));
}

[Fact]
public void TestDate19300307()
{
DateTime age = new DateTime(1930, 03, 07);
Assert.Equal(@"Year: 88 Month: 11 Day: 28 ", birthday.Age(age, today));
}
}
}
60 changes: 60 additions & 0 deletions CourseApp.Tests/TestDog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestDog
{
[Fact]
public void Test_ProverkaBezZnachenij()
{
Dog snech = new Dog();

Assert.Equal(15, snech.Age);
Assert.Equal(50.0f, snech.Weight);
Assert.Equal("K", snech.Pol);
}

[Fact]
public void Test_ProverkaPolaGirl()
{
Dog snech = new Dog("S");
Assert.Equal(12, snech.Age);
Assert.Equal(45.0f, snech.Weight);
}

[Fact]
public void Test_ProverkaPolaBoy()
{
Dog snech = new Dog("K");
Assert.Equal(14, snech.Age);
Assert.Equal(50.0f, snech.Weight);
}

[Fact]
public void Test_ProverkaMetodaPicture()
{
Dog snech = new Dog();
Assert.Equal(
@" __ _
o'')}____//
`_/ )
(_(_/-(_/", snech.Picture());
}

[Fact]
public void Test_ProverkaMetodaGolos()
{
Dog snech = new Dog();
Assert.Equal($"������ �������� {15} ������ ����� ���-��� ", snech.Golos());
}

[Fact]
public void Test_ProverkaMetodaToString()
{
Dog snech = new Dog();
Assert.Equal("������ �������� 15 � ����� K", snech.ToString());
}
}
}
44 changes: 44 additions & 0 deletions CourseApp.Tests/TestFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using CourseApp;
using Xunit;

namespace CourseApp.Tests
{
public class TestFunction
{
[Fact]
public void TestWith0()
{
var res = Program.Prgrm(0.0, 0.0f, 0.0f);
Assert.Equal(double.NaN, res, 3);
}

[Fact]
public void Test_SecondConst2()
{
var res = Program.Prgrm(0.0, 0.0f, 2.0f);
Assert.Equal(double.NaN, res, 3);
}

[Fact]
public void Test_Xraven1_FirstConst2()
{
var res = Program.Prgrm(1.0, 2.0f, 0.0f);
Assert.Equal(-0.898, res, 3);
}

[Fact]
public void Test_Xraven2()
{
var res = Program.Prgrm(2.0, 0.0f, 0.0f);
Assert.Equal(double.NaN, res, 3);
}

[Fact]
public void Test_SecondConstPoltora()
{
var res = Program.Prgrm(0.0, 0.0f, 1.5f);
Assert.Equal(double.NaN, res, 3);
}
}
}
32 changes: 32 additions & 0 deletions CourseApp.Tests/TestInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestInterface
{
private Dog sharik = new Dog();

[Fact]
public void TestStrokeDog()
{
Assert.Equal("stroke a dog", sharik.Stroke_dog());
}

[Fact]
public void TestIComparable_0_S_S()
{
Dog snech = new Dog("S");
Dog nura = new Dog("S");
Dog[] dogs = new Dog[] { snech, sharik, nura };
Array.Sort(dogs);
Assert.Equal(nura.Weight, dogs[0].Weight);
Assert.Equal(nura.Pol, dogs[0].Pol);
Assert.Equal(snech.Weight, dogs[1].Weight);
Assert.Equal(snech.Pol, dogs[1].Pol);
Assert.Equal(sharik.Weight, dogs[2].Weight);
Assert.Equal(sharik.Pol, dogs[2].Pol);
}
}
}
30 changes: 30 additions & 0 deletions CourseApp.tests/CourseApp.tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<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>
25 changes: 25 additions & 0 deletions CourseApp.tests/CourseApp.tests.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2046
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.tests", "CourseApp.tests.csproj", "{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BA49A447-8DDA-4475-92B3-216B217CA049}
EndGlobalSection
EndGlobal
17 changes: 17 additions & 0 deletions CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>

<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>

</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>
9 changes: 9 additions & 0 deletions CourseApp/IStroke_dog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace CourseApp
{
public interface IStroke_dog
{
string Stroke_dog();
}
}
Loading