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

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

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

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</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.27428.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "CourseApp.Tests.csproj", "{7E3B2FC3-E500-42FE-8D27-865EA197567C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7E3B2FC3-E500-42FE-8D27-865EA197567C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E3B2FC3-E500-42FE-8D27-865EA197567C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E3B2FC3-E500-42FE-8D27-865EA197567C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E3B2FC3-E500-42FE-8D27-865EA197567C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C9D373F4-C8F4-4D88-8197-D96E561BE491}
EndGlobalSection
EndGlobal
86 changes: 86 additions & 0 deletions CourseApp.Tests/UnitTest2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using Xunit;
using System;
using CourseApp;

namespace CourseApp.Tests
{
public class UnitTest2
{
[Fact]
public void Test3()
{
Employee one = new Employee();
var name = one.Name;
var surname = one.Surname;
var title = one.Title;
var age = one.Age;
var height = one.Height;
var weight = one.Weight;
var hireDateTime = one.HireDateTime;
Assert.Equal("John", name);
Assert.Equal("Smith", surname);
Assert.Equal("Mr.", title);
Assert.Equal(30, age);
Assert.Equal(120, height);
Assert.Equal(120, weight);
Assert.Equal(new DateTime(2018, 9, 27, 0, 0, 0, 0), hireDateTime);
}

[Fact]
public void Test4()
{
Employee two = new Employee("Борис", "Годунов", 466, new DateTime(2018, 9, 27, 0, 0, 0, 0));
var name = two.Name;
var surname = two.Surname;
var title = two.Title;
var age = two.Age;
var height = two.Height;
var weight = two.Weight;
var hireDateTime = two.HireDateTime;
Assert.Equal("Борис", name);
Assert.Equal("Годунов", surname);
Assert.Equal("Mr.", title);
Assert.Equal(466, age);
Assert.Equal(150, height);
Assert.Equal(55, weight);
Assert.Equal(new DateTime(2018, 9, 27, 0, 0, 0, 0), hireDateTime);
}

[Fact]
public void Test5()
{
Employee three = new Employee("Лазарь", "Водянец", "Господин", 56, 170, 75, new DateTime(2018, 9, 27, 0, 0, 0, 0));
var name = three.Name;
var surname = three.Surname;
var title = three.Title;
var age = three.Age;
var height = three.Height;
var weight = three.Weight;
var hireDateTime = three.HireDateTime;
Assert.Equal("Лазарь", name);
Assert.Equal("Водянец", surname);
Assert.Equal("Господин", title);
Assert.Equal(56, age);
Assert.Equal(170, height);
Assert.Equal(75, weight);
Assert.Equal(new DateTime(2018, 9, 27, 0, 0, 0, 0), hireDateTime);
}

[Fact]
public void Test6()
{
Employee one = new Employee();
var age = one.Age;
one.Age = -1;
Assert.Equal(30, age);
}

[Fact]
public void Test7()
{
Employee one = new Employee();
Assert.Equal("Mr. Smith, John", one.ToString());

}
}
}
87 changes: 87 additions & 0 deletions CourseApp.Tests/UnitTest3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace CourseApp.Tests
{
public class UnitTest3
{
[Fact]
public void Test8()
{
Skateboarder one = new Skateboarder();
var name = one.Name;
var surname = one.Surname;
var title = one.Title;
var age = one.Age;
var height = one.Height;
var weight = one.Weight;
var stance = one.Stance;
Assert.Equal("John", name);
Assert.Equal("Smith", surname);
Assert.Equal("Mr.", title);
Assert.Equal(30, age);
Assert.Equal(120, height);
Assert.Equal(120, weight);
Assert.Equal("goofy", stance);
}

[Fact]
public void Test9()
{
Skateboarder two = new Skateboarder("Борис", "Годунов", 466, "regular");
var name = two.Name;
var surname = two.Surname;
var title = two.Title;
var age = two.Age;
var height = two.Height;
var weight = two.Weight;
var stance = two.Stance;
Assert.Equal("Борис", name);
Assert.Equal("Годунов", surname);
Assert.Equal("Mr.", title);
Assert.Equal(466, age);
Assert.Equal(150, height);
Assert.Equal(55, weight);
Assert.Equal("regular", stance);
}

[Fact]
public void Test10()
{
Skateboarder three = new Skateboarder("Лазарь", "Водянец", "Господин", 56, 170, 75, "mongo-goofy");
var name = three.Name;
var surname = three.Surname;
var title = three.Title;
var age = three.Age;
var height = three.Height;
var weight = three.Weight;
var stance = three.Stance;
Assert.Equal("Лазарь", name);
Assert.Equal("Водянец", surname);
Assert.Equal("Господин", title);
Assert.Equal(56, age);
Assert.Equal(170, height);
Assert.Equal(75, weight);
Assert.Equal("mongo-goofy", stance);
}

[Fact]
public void Test11()
{
Skateboarder one = new Skateboarder();
var age = one.Age;
one.Age = -1;
Assert.Equal(30, age);
}

[Fact]
public void Test12()
{
Skateboarder one = new Skateboarder();
Assert.Equal("John Smith", one.ToString());

}
}
}
44 changes: 44 additions & 0 deletions CourseApp.Tests/UnitTest4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace CourseApp.Tests
{
public class UnitTest4
{
[Fact]
public void Test13()
{
HumanBeing[] humanBeing = new HumanBeing[2];
humanBeing[0] = new Employee();
humanBeing[1] = new Skateboarder();
Assert.Equal("Mr. Smith, John", humanBeing[0].ToString());
Assert.Equal("John Smith", humanBeing[1].ToString());
}

[Fact]
public void Test14()
{
HumanBeing[] humanBeing = new HumanBeing[2];
humanBeing[0] = new Employee();
humanBeing[1] = new Skateboarder();
Assert.Equal("John", humanBeing[0].Name);
Assert.Equal("Smith", humanBeing[0].Surname);
Assert.Equal(30, humanBeing[0].Age);
Assert.Equal("John", humanBeing[1].Name);
Assert.Equal("Smith", humanBeing[1].Surname);
Assert.Equal(30, humanBeing[1].Age);
}

[Fact]
public void Test15()
{
HumanBeing[] humanBeing = new HumanBeing[2];
humanBeing[0] = new Employee();
humanBeing[1] = new Skateboarder();
Assert.Equal("Hired 27 сентября 2018", humanBeing[0].GetHireDate());
Assert.Equal("Skateboarders cannot be hired.", humanBeing[1].GetHireDate());
}
}
}
17 changes: 16 additions & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</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>
31 changes: 31 additions & 0 deletions CourseApp/CourseApp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{2CB77443-91EF-4269-943D-B5199FA7FF56}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{A1B712CE-343E-4D8E-9B2A-518B3FEA365C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2CB77443-91EF-4269-943D-B5199FA7FF56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CB77443-91EF-4269-943D-B5199FA7FF56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CB77443-91EF-4269-943D-B5199FA7FF56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CB77443-91EF-4269-943D-B5199FA7FF56}.Release|Any CPU.Build.0 = Release|Any CPU
{A1B712CE-343E-4D8E-9B2A-518B3FEA365C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1B712CE-343E-4D8E-9B2A-518B3FEA365C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1B712CE-343E-4D8E-9B2A-518B3FEA365C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1B712CE-343E-4D8E-9B2A-518B3FEA365C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C085A481-A16B-430C-8364-94626DDBF6C6}
EndGlobalSection
EndGlobal
58 changes: 58 additions & 0 deletions CourseApp/Employee.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CourseApp
{
public class Employee : HumanBeing
{
public Employee()
: base()
{
HireDateTime = new DateTime(2018, 9, 27, 0, 0, 0, 0);
} // 1 конструктор (перекрытый)

public Employee(string name, string surname, int age, DateTime hireDateTime)
: this(name, surname, "Mr.", age, 150, 55, hireDateTime) // 2 конструктор
{
}

public Employee(string name, string surname, string title, int age, int height, int weight, DateTime hireDateTime)
{
Name = name;
Surname = surname;
Title = title;
Age = age;
Height = height;
Weight = weight;
HireDateTime = hireDateTime;
} // 3 конструктор

public DateTime HireDateTime { get; set; }

public override void GetInfo()
{
Console.WriteLine($"{Title} {Surname}, {Name}. {Age} years old.");
Console.WriteLine($"Weight {Weight}, height {Height}.");
Console.WriteLine($"Hired {HireDateTime.ToString("dd MMMM yyyy")}");
Console.WriteLine();
}

public override void Injury()
{
Weight = (int)Math.Floor(Weight * 0.95);
Console.WriteLine($"Работник жутко травмирован.");
Console.WriteLine();
}

public override string GetHireDate()
{
return $"Hired {HireDateTime.ToString("dd MMMM yyyy")}";
}

public override string ToString()
{
return $"{Title} {Surname}, {Name}";
}
}
}
Loading