From 4ac3cea425e0fe4fe52f007810fce1671bd2ad99 Mon Sep 17 00:00:00 2001 From: zatsve Date: Sun, 13 Jan 2019 17:34:18 +0300 Subject: [PATCH 1/5] Add Lab --- CourseApp/Program.cs | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index cf4382b..255f4cb 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,12 +1,38 @@ using System; - -namespace CourseApp +namespace ConsoleApp3 { class Program { + public static double y(double x, double a, double b) + { + return (Math.Sqrt(x) * a - (Math.Log(x, 5) * b) / Math.Log10(Math.Abs(x - 1))); + } + static void Main(string[] args) + { - Console.WriteLine("Елена Александровна"); + double a = 4.1; + double b = 2.7; + double xn = 1.2; + double xk = 5.2; + double dx = 0.8; + + double[] x = new double[5] { 1.9, 2.15, 2.34, 2.73, 3.16 }; + + Console.WriteLine("Задача A:"); + + for (double xl = xn; xl < xk; xl += dx) + { + Console.WriteLine($"Для x = {xl}\t y = {y(xl, a, b):f3}"); + } + + Console.WriteLine("Задача B:"); + + foreach (double i in x) + { + Console.WriteLine($"Для x = {i}\t y = {y(i, a, b):f3}"); + } + Console.ReadKey(); } } -} +} \ No newline at end of file From 56f6193889350f96b3ed809f5f3169e71e40b9a0 Mon Sep 17 00:00:00 2001 From: zatsve Date: Sun, 13 Jan 2019 22:25:17 +0300 Subject: [PATCH 2/5] Added new Lab --- CourseApp/CourseApp.csproj | 17 +- CourseApp/CourseApp.sln | 31 ++++ CourseApp/Employee.cs | 58 +++++++ CourseApp/HumanBeing.cs | 83 +++++++++ CourseApp/Program.cs | 55 +++--- CourseApp/Skateboarder.cs | 60 +++++++ README.md | 2 +- _gitignore | 316 ++++++++++++++++++++++++++++++++++ stylecop/stylecop.json | 15 ++ stylecop/stylecop.ruleset.xml | 22 +++ 10 files changed, 634 insertions(+), 25 deletions(-) create mode 100644 CourseApp/CourseApp.sln create mode 100644 CourseApp/Employee.cs create mode 100644 CourseApp/HumanBeing.cs create mode 100644 CourseApp/Skateboarder.cs create mode 100644 _gitignore create mode 100644 stylecop/stylecop.json create mode 100644 stylecop/stylecop.ruleset.xml diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index ce1697a..e0b928f 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -1,8 +1,23 @@ - + Exe netcoreapp2.0 + true + 1573,1591,1701;1702;1705 + + + + + + ../stylecop/stylecop.ruleset + true + + + + + + diff --git a/CourseApp/CourseApp.sln b/CourseApp/CourseApp.sln new file mode 100644 index 0000000..e0bd4d9 --- /dev/null +++ b/CourseApp/CourseApp.sln @@ -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 diff --git a/CourseApp/Employee.cs b/CourseApp/Employee.cs new file mode 100644 index 0000000..454c2b9 --- /dev/null +++ b/CourseApp/Employee.cs @@ -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}"; + } + } +} diff --git a/CourseApp/HumanBeing.cs b/CourseApp/HumanBeing.cs new file mode 100644 index 0000000..4678218 --- /dev/null +++ b/CourseApp/HumanBeing.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CourseApp +{ + public abstract class HumanBeing + { + private int age; // years + private int height; // cm + private int weight; // kg + + public HumanBeing() + { + Name = "John"; + Surname = "Smith"; + Title = "Mr."; + age = 30; + height = 120; + weight = 120; + } + + public string Name { get; set; } + + public string Surname { get; set; } + + public string Title { get; set; } + + public int Age + { + get + { + return age; + } + + set + { + if((value > 0) && (value < 600)) + { + age = value; + } + } + } + + public int Height + { + get + { + return height; + } + + set + { + if((value > 50) && (value < 250)) + { + height = value; + } + } + } + + public int Weight + { + get + { + return weight; + } + + set + { + if((value > 40) && (value < 180)) + { + weight = value; + } + } + } + + public abstract void GetInfo(); + + public abstract void Injury(); + + public abstract string GetHireDate(); + } +} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 255f4cb..d34e66c 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,38 +1,47 @@ -using System; -namespace ConsoleApp3 +namespace CourseApp { - class Program + using System; + + public class Program { - public static double y(double x, double a, double b) + private static void Main() { - return (Math.Sqrt(x) * a - (Math.Log(x, 5) * b) / Math.Log10(Math.Abs(x - 1))); - } + Console.WriteLine("13 вариант"); + Console.WriteLine(); - static void Main(string[] args) + Employee one = new Employee(); // создание 1-го + Employee two = new Employee("Nikita", "Singh", "Miss", 35, 153, 55, DateTime.Now); // создание 2-го - { - double a = 4.1; - double b = 2.7; - double xn = 1.2; - double xk = 5.2; - double dx = 0.8; + Skateboarder three = new Skateboarder("Candy", "Jacobs", "Ms", 28, 165, 64, "goofy"); // создание 3-го - double[] x = new double[5] { 1.9, 2.15, 2.34, 2.73, 3.16 }; + one.GetInfo(); + two.GetInfo(); + two.Injury(); + two.GetInfo(); - Console.WriteLine("Задача A:"); + three.GetInfo(); + three.Injury(); + three.GetInfo(); - for (double xl = xn; xl < xk; xl += dx) - { - Console.WriteLine($"Для x = {xl}\t y = {y(xl, a, b):f3}"); - } + Console.WriteLine(one.GetHireDate()); + Console.WriteLine(two.GetHireDate()); + Console.WriteLine(three.GetHireDate()); + Console.WriteLine(); - Console.WriteLine("Задача B:"); + Console.WriteLine(one.ToString()); + Console.WriteLine(two.ToString()); + Console.WriteLine(three.ToString()); + Console.WriteLine(); - foreach (double i in x) + HumanBeing[] humanBeings = new HumanBeing[2]; + humanBeings[0] = new Employee("Гога", "Воробьёв", 20, DateTime.Now); + humanBeings[1] = new Skateboarder("Жора", "Воробьёв-Насос", 20, "regular"); + foreach(HumanBeing i in humanBeings) { - Console.WriteLine($"Для x = {i}\t y = {y(i, a, b):f3}"); + i.GetInfo(); } - Console.ReadKey(); + + Console.Read(); } } } \ No newline at end of file diff --git a/CourseApp/Skateboarder.cs b/CourseApp/Skateboarder.cs new file mode 100644 index 0000000..c6b539e --- /dev/null +++ b/CourseApp/Skateboarder.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CourseApp +{ + public class Skateboarder : HumanBeing + { + public Skateboarder() + : base() + { + Stance = "goofy"; + } // 1 конструктор (перекрытый) + + public Skateboarder(string name, string surname, int age, string stance) + : this(name, surname, "Mr.", age, 150, 55, stance) // 2 конструктор + { + } + + public Skateboarder(string name, string surname, string title, int age, int height, int weight, string stance) + { + Name = name; + Surname = surname; + Title = Title; + Age = age; + Height = height; + Weight = weight; + Stance = stance; + } // 3 конструктор + + public string Stance { get; set; } + + public override void GetInfo() + { + Console.WriteLine($"{Name} {Surname}. {Age} years old."); + Console.WriteLine($"Weight {Weight}, height {Height}."); + Console.WriteLine($"Stance {Stance}."); + Console.WriteLine(); + } + + public override void Injury() + { + Weight = (int)Math.Floor(Weight * 0.9); + Height = (int)Math.Floor(Height * 0.9); + Stance = "none"; + Console.WriteLine($"Скейтер жутко травмирован."); + Console.WriteLine(); + } + + public override string GetHireDate() + { + return $"Skateboarders cannot be hired."; + } + + public override string ToString() + { + return $"{Name} {Surname}"; + } + } +} diff --git a/README.md b/README.md index 6c846aa..1cdfff2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Course of c# -Елена Дмитрюшкова Александровна \ No newline at end of file +Афанасьева Вера Павловна \ No newline at end of file diff --git a/_gitignore b/_gitignore new file mode 100644 index 0000000..33795ad --- /dev/null +++ b/_gitignore @@ -0,0 +1,316 @@ +# Download this file using PowerShell v3 under Windows with the following comand: +# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore +# or wget: +# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +**/[Bb]in/ +**/[Oo]bj/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# OS generated files # +.DS_Store* +Icon? + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +*.Cache +ClientBin/ +# [Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# svn +.svn + +# Remainings from resolvings conflicts in Source Control +*.orig + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide + +# Visual Studio temp something +.vs/ + +# VS 2015+ +*.vc.vc.opendb +*.vc.db + +# Rider +.idea/ + +**/node_modules/* + +# Added by Jskonst +.vscode/ +# Migrations/ +Properties/ + +##### +# End of core ignore list, below put you custom 'per project' settings (patterns or path) +##### +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# Executable programs +*.exe \ No newline at end of file diff --git a/stylecop/stylecop.json b/stylecop/stylecop.json new file mode 100644 index 0000000..643b8c1 --- /dev/null +++ b/stylecop/stylecop.json @@ -0,0 +1,15 @@ +{ + "$schema": + "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "documentExposedElements": false, + "documentInterfaces": false, + "companyName": "Test Company", + "copyrightText": + "This source code is Copyright © {companyName} and MAY NOT be copied, reproduced,\npublished, distributed or transmitted to or stored in any manner without prior\nwritten consent from {companyName} (www.yourcompany.com).", + "xmlHeader": false + } + }, + "additionalArguments": ["./stylecop.ruleset", "./stylecop.json"] +} diff --git a/stylecop/stylecop.ruleset.xml b/stylecop/stylecop.ruleset.xml new file mode 100644 index 0000000..3350d0e --- /dev/null +++ b/stylecop/stylecop.ruleset.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From dfbd0c2878ec8ed82fcbb9c2947ede35314abd2b Mon Sep 17 00:00:00 2001 From: zatsve <43569021+zatsve@users.noreply.github.com> Date: Sun, 13 Jan 2019 23:20:03 +0300 Subject: [PATCH 3/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cdfff2..bc23862 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Course of c# -Афанасьева Вера Павловна \ No newline at end of file +Елена Дмитрюшкова Александровна From a664df1e66e60f38abfe67eff3efaf6c89bc6d50 Mon Sep 17 00:00:00 2001 From: zatsve <43569021+zatsve@users.noreply.github.com> Date: Sun, 13 Jan 2019 23:22:52 +0300 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc23862..be10807 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Course of c# -Елена Дмитрюшкова Александровна +Елена Александровна Дмитрюшкова From 6cbfbc36af50b3180d0d4bbdd667880494fc1292 Mon Sep 17 00:00:00 2001 From: zatsve Date: Mon, 14 Jan 2019 00:05:56 +0300 Subject: [PATCH 5/5] Added Tests --- CourseApp.Tests/CourseApp.Tests.csproj | 23 +++++++ CourseApp.Tests/CourseApp.Tests.sln | 25 ++++++++ CourseApp.Tests/UnitTest2.cs | 86 +++++++++++++++++++++++++ CourseApp.Tests/UnitTest3.cs | 87 ++++++++++++++++++++++++++ CourseApp.Tests/UnitTest4.cs | 44 +++++++++++++ 5 files changed, 265 insertions(+) create mode 100644 CourseApp.Tests/CourseApp.Tests.csproj create mode 100644 CourseApp.Tests/CourseApp.Tests.sln create mode 100644 CourseApp.Tests/UnitTest2.cs create mode 100644 CourseApp.Tests/UnitTest3.cs create mode 100644 CourseApp.Tests/UnitTest4.cs diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj new file mode 100644 index 0000000..668d776 --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -0,0 +1,23 @@ + + + netcoreapp2.0 + + false + + + + + + + + + + + + + + + + + + diff --git a/CourseApp.Tests/CourseApp.Tests.sln b/CourseApp.Tests/CourseApp.Tests.sln new file mode 100644 index 0000000..0724241 --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.sln @@ -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 diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/UnitTest2.cs new file mode 100644 index 0000000..4e31f7f --- /dev/null +++ b/CourseApp.Tests/UnitTest2.cs @@ -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()); + + } + } +} diff --git a/CourseApp.Tests/UnitTest3.cs b/CourseApp.Tests/UnitTest3.cs new file mode 100644 index 0000000..ccdbf18 --- /dev/null +++ b/CourseApp.Tests/UnitTest3.cs @@ -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()); + + } + } +} diff --git a/CourseApp.Tests/UnitTest4.cs b/CourseApp.Tests/UnitTest4.cs new file mode 100644 index 0000000..e3a623f --- /dev/null +++ b/CourseApp.Tests/UnitTest4.cs @@ -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()); + } + } +} \ No newline at end of file