Skip to content
Open
Show file tree
Hide file tree
Changes from 22 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>
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);
}
}
}
58 changes: 58 additions & 0 deletions CourseApp.Tests/UnitTest1.cs
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);
}
}
}
}
82 changes: 82 additions & 0 deletions CourseApp.Tests/UnitTest2.cs
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

этот тест не проверяет ващ класс - он только проверяет что переменная N, объявленная в тесте = "momo"

}
[Fact]
public void Test2()
{
var krosh = new InfoRabbit();
var N ="momo";
var P1 = "mu";
var P2 = "nu";
krosh.RabbitInfo(N);
Assert.Equal("momo",N);
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
}
}
}
15 changes: 15 additions & 0 deletions CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
<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>
36 changes: 36 additions & 0 deletions CourseApp/Info.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;

namespace CourseApp
{
public class Info
{
public void PetInfo(string name, string pearent1, string pearent2, List<string> child, string vid)
{
Console.Write($"{vid} {name}, Родители: {pearent1} и {pearent2}, Дети: ");
foreach(var i in child)
{
Console.WriteLine($"{i} ");
}
}

public void PetInfo(string name, string pearent1, string pearent2, string vid)
{
Console.WriteLine($"{vid} {name}, Родители: {pearent1} и {pearent2}, Детей нет");
}

public void PetInfo(string name, string vid)
{
Console.WriteLine($"{vid} {name}, Родители: ??? и ???, Дети нет");
}

public void PetInfo(string name, List<string> child, string vid)
{
Console.Write($"{vid} {name}, Родители: ??? и ???, Дети: ");
foreach(var i in child)
{
Console.WriteLine($"{i} ");
}
}
}
}
38 changes: 38 additions & 0 deletions CourseApp/Krolik.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace CourseApp
{
public class Krolik : Pet
{
public void BuyKrolik()
{
Console.Write("Введите имя купленного кролика: ");
Name = Console.ReadLine();
Copy link
Contributor

Choose a reason for hiding this comment

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

не не - это - плохая идея - обработку пользовательского ввода вести в классахз, фактически представляюзих модели данных - уберите, а Name передавайте как параметр метода. И сразу подумайте - а как это протестировать?

Spisok.Add(Name, new NewPet(Vid));
}

public void NewKrolik()
{
Console.Write("Введите имя новорожденного кролика: ");
Copy link
Contributor

Choose a reason for hiding this comment

The 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, "кролик"));
foreach(string i in Spisok.Keys)
{
if(Pearent1 == i )
{
Spisok.Add(Pearent1, new NewPet(Name));
}

if(Pearent2 == i)
{
Spisok.Add(Pearent2, new NewPet(Name));
}
}
}
}
}
Loading