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

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<TargetFramework>netcoreapp2.0</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>
</Project>

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

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

</Project>
14 changes: 14 additions & 0 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Xunit;

namespace CourseApp.Tests
{
public class DemoTest
{
[Fact]
public void Test1()
{
Assert.True(true);
}
}
}
30 changes: 30 additions & 0 deletions CourseApp.Tests/TestofDate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestofDate
{
[Fact]
public void EqualDates()
{
string schetvozrasta = Date.SchetVozrasta(new DateTime(1999, 9, 30), new DateTime(1999, 9, 30));
Assert.Equal("��� �������: 0 ���, 0 �������, 0 ����", schetvozrasta);
}

[Fact]
public void BirthdayBeforeToday()
{
string schetvozrasta = Date.SchetVozrasta(new DateTime(1999, 9, 30), new DateTime(2019, 4, 14));
Assert.Equal("��� �������: 19 ���, 6 �������, 14 ����", schetvozrasta);
}

[Fact]
public void BirthdayAfterToday()
{
string schetvozrasta = Date.SchetVozrasta(new DateTime(2029, 9, 30), new DateTime(2019, 4, 14));
Assert.Equal("��� �� �������!", schetvozrasta);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,57 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using CourseApp;

namespace CourseApp.Test
namespace CourseApp.Tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переименуйте файлы тестов - чтобы было ясно кого ои тестируют

{
public class UnitTest1
public class TestofFunction
{
[Fact]
public void Test1()
{
var res = Program.Func(0.0, 0.8, 0.4);
Assert.Equal(0.283, res, 3);
}

[Fact]
public void Test2()
{
var res = Program.Func(0.0, 1.1, 0.1);
Assert.Equal(0.639, res, 3);
}

[Fact]
public void Test3()
{
var res = Program.Func(0.1, 0.4, 0.3);
Assert.Equal(0.063, res, 3);
}

[Fact]
public void Test4()
{
var res = Program.Func(2.2, 1.8, 3.4);
Assert.Equal(203.09, res, 3);
}

[Fact]
public void Test5()
{
var res = Program.Func(0.09, 0.71, 0.2);
Assert.Equal(0.224, res, 3);
}

[Fact]
public void Test6()
{
var res = Program.Func(0.0, 0.01, 0.33);
Assert.Equal(0.0, res, 3);
}

[Fact]
public void Test7()
{
var res = Program.Func(0.9, 0.8, 0.7);
Assert.Equal(1.266, res, 3);
}

[Fact]
public void Test8()
{
Expand Down
25 changes: 25 additions & 0 deletions CourseApp.Tests/TestofIComparable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestofIComparable
{
[Fact]
public void Testcomparable()
{
string icomparable = @"Admiral - 200 - 100
Duty - 75 - 300
Lucky - 90 - 100";
Ship admiral = new Ship();
Ship lucky = new Ship(90);
Ship duty = new Ship("Duty", 75, 300);
Ship[] araryOfShip = new Ship[] { admiral, lucky, duty };
Assert.Equal(
@"Admiral - 200 - 100
Duty - 75 - 300
Lucky - 90 - 100", icomparable);
}
}
}
51 changes: 51 additions & 0 deletions CourseApp.Tests/TestofKater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestofKater
{
[Fact]
public void TestofPicture()
{
Kater carter = new Kater();
Assert.Equal(
@"

░░░░░░░░░░░░░█▀▀▀█████████▄▄▄░░░░░░░░░░░
░░░░░░░░░░░▄█▀░░░░░█▀░░░░░█▀░░░░░░░░░░░░
███████▄▄▄██▄▄▄▄░░░█░░░░░░█░░▀████▄▄▄▄▄▄
░▄░░░▀▀▀▀▀▀▀▀███████████████▄▄▄█▄▄▄█░░██
░▀█████████▄▄▄▄▄▄▄▄▄░░▀▀▀▀▀▀▀▀▀████████░
░░░▀█████████████████████████▄▄▄▄▄▄▄▄▄░░
░░░░░▀▀███████████████████████████████░░
░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀░░░
", carter.Picture());
}

[Fact]
public void Testofznacheniya()
{
Kater carter = new Kater();
Assert.Equal("Carter", carter.Name);
Assert.Equal(10, carter.Dlina);
Assert.Equal(50, carter.Maxspeed);
}

[Fact]
public void Testofpredlojeniya()
{
Kater carter = new Kater();
Assert.Equal($"Катер {carter.Name} поплыл вдоль реки", carter.Predlojenie());
}

[Fact]
public void CarterISwim()
{
Kater carter = new Kater();
string iswim = carter.Swim(carter);
Assert.Equal($"{carter.Name} плывет по течению", iswim);
}
}
}
88 changes: 88 additions & 0 deletions CourseApp.Tests/TestofShip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class TestofShip
{
[Fact]
public void TestofRis()
{
Ship admiral = new Ship();
Assert.Equal(
@"_���
_____________________�
_____________________�������������
_____________________���___�__�_����
_____________________���___����___��
_____________________���__�����___��
_____________________���__�����___�
_____________________������__��___�
_____________________�_________����
_____________�������������
_____________��___________��
______________�____________�
______________�_____________�
_______________�____________�
_______________�____________�_��
_______________�__���������������
_____��������������______________�
_____�____________��_____________��____�
_____��____________�_____����������������
______�______��������������______________�
______��_____��___________�______________��
_______�______�____________�______________�
_______�______��___________�_____________��
_______�_______�___________�_____________��
______��_______�___________��____________�
______�����������__________��___________��
___________�_�_��________���_____��������_____���
___________�_�_�����������_�������_______�����__��
������_____�_�______��_�_______�_���������___�����
��___���������______��_�____�������________��
__��________������������������____��______�
____�____________________________��_�____�
_____�_____���_____��_____���_____���___��
______�___��_��___��_�____�_��__________�
______��____��_____���_____��__________��
_______��_____________________________��
________��___________________________��
_________��________________________���
___________�������������������������
", admiral.Ris());
}

[Fact]
public void Testofznacheniya()
{
Ship admiral = new Ship();
Assert.Equal("Admiral", admiral.Name);
Assert.Equal(55, admiral.Dlina);
Assert.Equal(100, admiral.Vodoizmeschenie);
}

[Fact]
public void Testofpredlojenia()
{
Ship admiral = new Ship();
Assert.Equal($"������� {admiral.Name} ����� � �������� ����", admiral.Predlojenie());
}

[Fact]
public void AdmiralISwim()
{
Ship admiral = new Ship();
string iswim = admiral.Swim(admiral);
Assert.Equal($"������� Admiral ����������� � �������", iswim);
}

[Fact]
public void LuckyISwim()
{
Ship lucky = new Ship(90);
string iswim = lucky.Swim(lucky);
Assert.Equal($"������� Lucky ����������� � �������", iswim);
}
}
}
18 changes: 17 additions & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
</PropertyGroup>

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

namespace CourseApp
{
public class Date
{
public static string SchetVozrasta(DateTime bornday, DateTime today)
{
DateTime todaydate = today;
if (today.Day == bornday.Day)
{
return "Ваш возраст: 0 лет, 0 месяцев, 0 дней";
}

if (today < bornday)
{
return $"Еще не родился!";
}

todaydate = todaydate.AddYears(-bornday.Year);
todaydate = todaydate.AddMonths(-bornday.Month);
todaydate = todaydate.AddDays(-bornday.Day);
return $"Ваш возраст: {todaydate.Year} лет, {todaydate.Month} месяцев, {todaydate.Day} дней";
}
}
}
9 changes: 9 additions & 0 deletions CourseApp/ISwim.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace CourseApp
{
public interface ISwim
{
string Swim(object o);
}
}
Loading