-
Notifications
You must be signed in to change notification settings - Fork 23
K voland #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: K-Voland
Are you sure you want to change the base?
K voland #48
Changes from all commits
47093d1
e42b7eb
88c17a6
3686c4a
1057aa6
0a6739a
297b5d6
addc7cc
e3d4d8e
75548ba
40078f8
2f38d04
e24d1da
9e27494
3390c59
9969670
c4a7f5d
a863fda
2cd9e2a
2a6774d
69539c1
09cd8ff
2056920
76833e2
2d2bd84
90f087e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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> |
| 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 DateTest | ||
| { | ||
| [Fact] | ||
| public void Test1() | ||
| { | ||
| DateTime dr = new DateTime(1990, 9, 17); | ||
| var time = Date.DateB(dr); | ||
| Assert.Equal("Год: 28 Месяц: 05 День: 20", Date.DateB(dr)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Test2() | ||
| { | ||
| DateTime dr = new DateTime(2010, 2, 2); | ||
| var time = Date.DateB(dr); | ||
| Assert.Equal("Год: 09 Месяц: 01 День: 04", Date.DateB(dr)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Test3() | ||
| { | ||
| DateTime dr = new DateTime(11, 11, 11); | ||
| var time = Date.DateB(dr); | ||
| Assert.Equal("Год: 07 Месяц: 03 День: 26", Date.DateB(dr)); | ||
| } | ||
| } | ||
| } |
| 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); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| using System; | ||
| using Xunit; | ||
| using CourseApp; | ||
|
|
||
| namespace CourseApp.Tests | ||
| { | ||
| public class UnitTest1 | ||
| { | ||
|
|
||
| [Fact] | ||
| public void Test1() | ||
| { | ||
| var res = Program.Fan(0.7,1.2,0.48); | ||
| Assert.Equal(0.326, res, 3); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Test2() | ||
| { | ||
| var res = Program.Fan(1.0,1.2,0.48); | ||
| Assert.Equal(0.584, res, 3); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Test3() | ||
| { | ||
| var res = Program.Fan(1.3,1.2,0.48); | ||
| Assert.Equal(0.968, res, 3); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Test4() | ||
| { | ||
| var res = Program.Fan(1.6,1.2,0.48); | ||
| Assert.Equal(Double.NaN, res, 3); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Test5() | ||
| { | ||
| var res = Program.Fan(1.9,1.2,0.48); | ||
| Assert.Equal(Double.NaN, res, 3); | ||
| } | ||
|
|
||
| double[] xx = {0.25, 0.36, 0.56, 0.94, 1.28}; | ||
|
|
||
| [Fact] | ||
| public void Test6() | ||
| { | ||
| double[] o = new double[5] {0.082,0.122,0.229,0.528,0.930}; | ||
| foreach (int i in xx) | ||
| { | ||
| var res = Program.Fan(xx[i],1.2,0.48); | ||
| Assert.Equal(o[i], res, 3); | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| using System; | ||
| using Xunit; | ||
| using CourseApp; | ||
| using System.Collections.Generic; | ||
| using System.Collections; | ||
|
|
||
| namespace CourseApp.Tests | ||
| { | ||
| public class UnitTest2 | ||
| { | ||
| [Fact] | ||
| public void Test1() | ||
| { | ||
| var krosh = new InfoRabbit(); | ||
| var N ="momo"; | ||
| krosh.RabbitInfo(N); | ||
| Assert.Equal("momo",N); | ||
| } | ||
| [Fact] | ||
| public void Test2() | ||
| { | ||
| var krosh = new InfoRabbit(); | ||
| var N ="momo"; | ||
| var P1 = "mu"; | ||
| var P2 = "nu"; | ||
| krosh.RabbitInfo(N); | ||
| Assert.Equal("momo",N); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Та же беда - вы проверяете не свойство класса, а проверяете значение переменных, которые объявлены в тесте |
||
| Assert.Equal("mu",P1); | ||
| Assert.Equal("nu",P2); | ||
| } | ||
| [Fact] | ||
| public void Test3() | ||
| { | ||
| var krosh = new InfoRabbit(); | ||
| var N ="momo"; | ||
| var P1 = "mu"; | ||
| var P2 = "nu"; | ||
| List<string> ch=new List<string> {"Mura","Gura","Fedya"}; | ||
| krosh.RabbitInfo(N,P1,P2,ch); | ||
| Assert.Equal("momo",N); | ||
| Assert.Equal("mu",P1); | ||
| Assert.Equal("nu",P2); | ||
| Assert.Equal("Mura",ch[0]); | ||
| Assert.Equal("Gura",ch[1]); | ||
| Assert.Equal("Fedya",ch[2]); | ||
| } | ||
| [Fact] | ||
| public void Test4() | ||
| { | ||
| Menu ferma = new Menu(); | ||
| ferma.Name = "Boo"; | ||
| Assert.Equal("Boo",ferma.Name); | ||
| } [Fact] | ||
| public void Test5() | ||
| { | ||
| Menu ferma = new Menu(); | ||
| ferma.klet.Add("Boo"); | ||
| Assert.Equal("Boo",ferma.klet[0]); | ||
| } | ||
| [Fact] | ||
| public void Test6() | ||
| { | ||
| Menu ferma = new Menu(); | ||
| ferma.menu("Stl"); | ||
| ferma.Name="Boo"; | ||
| ferma.Pearent1="Buu"; | ||
| ferma.Pearent2="Buuu"; | ||
| Assert.Equal("Boo",ferma.klet[0]); | ||
| Assert.Equal("Buu",ferma.klet[0]); | ||
| Assert.Equal("Buuu",ferma.klet[0]); | ||
| } | ||
| [Fact] | ||
| public void Test7() | ||
| { | ||
| Menu ferma = new Menu(); | ||
| var go="heip"; | ||
| var osh="Такой команды не существует. help - узнать список команд."; | ||
| ferma.menu(go); | ||
| Assert.Equal(osh); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using System; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace CourseApp | ||
| { | ||
| public class Cavy : Pet | ||
| { | ||
| public override void NewPet() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Опять же это теперь делает базовый класс, можно убирать |
||
| { | ||
| Console.Write("Введите имя новорожденной морской свинки: "); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Осуществлять пользовательский ввод тоже не надо в классах, которые представляют сущности |
||
| Name = Console.ReadLine(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Вот для всего этого есть порождающий паттерн фабрика. или фабричный метод - как раз для реализации вашей идеи |
||
| Console.WriteLine("Введите имена родителй морской свинки: "); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А саму логику создания и внесения родителей следует унести в конструктор класса |
||
| Pearent1 = Console.ReadLine(); | ||
| Pearent2 = Console.ReadLine(); | ||
| Spisok.Add(Name, new NewPet(Pearent1, Pearent2, "cavy")); | ||
| foreach(string i in Spisok.Keys) | ||
| { | ||
| if(Pearent1 == i ) | ||
| { | ||
| Spisok.Add(Pearent1, new NewPet(Name, "cavy")); | ||
| } | ||
|
|
||
| if(Pearent2 == i) | ||
| { | ||
| Spisok.Add(Pearent2, new NewPet(Name, "cavy")); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public override string GetInfo() | ||
| { | ||
| return $"Морская свинка: {Name} "; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using System; | ||
|
|
||
| namespace CourseApp | ||
| { | ||
| public class Date | ||
| { | ||
| public static string DateB(DateTime dr) | ||
| { | ||
| return DateTime.Today.AddYears(-dr.Year).AddMonths(-dr.Month).AddDays(-dr.Day).ToString("Год: yy Месяц: MM День: dd"); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| using System; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace CourseApp | ||
| { | ||
| public class Krolik : Pet | ||
| { | ||
|
|
||
| public override void NewPet() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это теперь делает базовый класс, только передавайте |
||
| { | ||
| Console.Write("Введите имя новорожденного кролика: "); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. то же самое - вынесите в основную программу получение параметров, а здесь, только их проверьте |
||
| Name = Console.ReadLine(); | ||
| Console.WriteLine("Введите имена родителй кролика: "); | ||
| Pearent1 = Console.ReadLine(); | ||
| Pearent2 = Console.ReadLine(); | ||
| Spisok.Add(Name, new NewPet(Pearent1, Pearent2, "rabbit")); | ||
| foreach(string i in Spisok.Keys) | ||
| { | ||
| if(Pearent1 == i ) | ||
| { | ||
| Spisok.Add(Pearent1, new NewPet(Name, "rabbit")); | ||
| } | ||
|
|
||
| if(Pearent2 == i) | ||
| { | ||
| Spisok.Add(Pearent2, new NewPet(Name, "rabbit")); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public override string GetInfo() | ||
| { | ||
| return $"Кролик: {Name} "; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
этот тест не проверяет ващ класс - он только проверяет что переменная N, объявленная в тесте = "momo"