Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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>
64 changes: 64 additions & 0 deletions CourseApp.Tests/UnitTest3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class UnitTest3
{
[Fact]
public void Test12()
{
Cat murka = new Cat();

Assert.Equal(15, murka.Age);
Assert.Equal(15.0f, murka.Weight);
Assert.Equal("K", murka.Pol);
}

[Fact]
public void Test13()
{
Cat murka = new Cat("K");
Assert.Equal(9, murka.Age);
Assert.Equal(10.0f, murka.Weight);
}

[Fact]
public void Test14()
{
Cat murka = new Cat("Kisa");
Assert.Equal(11, murka.Age);
Assert.Equal(12.0f, murka.Weight);
}

[Fact]
public void Test15()
{
Cat murka = new Cat();
Assert.Equal(
@"
/\___/\
( o o )
/ * \
\__\_/__/ meow!
/ \
/ ___ \
\/___\/", murka.Picture());
}

[Fact]
public void Test16()
{
Cat murka = new Cat();
Assert.Equal($"��� �������� {15} ����� ����� ��� ", murka.Golos());
}

[Fact]
public void Test17()
{
Cat murka = new Cat();
Assert.Equal("��� �������� 15 � ����� K", murka.ToString());
}
}
}
22 changes: 22 additions & 0 deletions CourseApp.Tests/UnitTest4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class UnitTest4
{
[Fact]
public void Test18()
{
Pet[] pet = new Pet[2];
pet[0] = new Dog();
pet[1] = new Cat();
foreach (Pet i in pet)
{
Assert.Equal(15, i.Age);
Assert.Equal("K", i.Pol);
}
}
}
}
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.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>
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.28010.2046
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.tests", "CourseApp.tests.csproj", "{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C6DFAA2-D1B0-4FB1-9E13-D5BF17CC1FC8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BA49A447-8DDA-4475-92B3-216B217CA049}
EndGlobalSection
EndGlobal
44 changes: 44 additions & 0 deletions CourseApp.tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using CourseApp;
using Xunit;

namespace CourseApp.Tests
{
public class UnitTest1
Copy link
Contributor

Choose a reason for hiding this comment

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

Переименуйте и файли каждый тест - чтобы было понятно - что за метод тестируется и что ожидать

{
[Fact]
public void Test1()
{
var res = Program.Prgrm(0.0, 0.0f, 0.0f);
Assert.Equal(double.NaN, res, 3);
}

[Fact]
public void Test2()
{
var res = Program.Prgrm(0.0, 0.0f, 2.0f);
Assert.Equal(double.NaN, res, 3);
}

[Fact]
public void Test3()
{
var res = Program.Prgrm(1.0, 2.0f, 0.0f);
Assert.Equal(-0.898, res, 3);
}

[Fact]
public void Test4()
{
var res = Program.Prgrm(2.0, 0.0f, 0.0f);
Assert.Equal(double.NaN, res, 3);
}

[Fact]
public void Test5()
{
var res = Program.Prgrm(0.0, 0.0f, 1.5f);
Assert.Equal(double.NaN, res, 3);
}
}
}
60 changes: 60 additions & 0 deletions CourseApp.tests/UnitTest2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using Xunit;
using CourseApp;

namespace CourseApp.Tests
{
public class UnitTest2
{
[Fact]
public void Test6()
{
Dog snech = new Dog();

Assert.Equal(15, snech.Age);
Assert.Equal(50.0f, snech.Weight);
Assert.Equal("K", snech.Pol);
}

[Fact]
public void Test7()
{
Dog snech = new Dog("S");
Assert.Equal(12, snech.Age);
Assert.Equal(45.0f, snech.Weight);
}

[Fact]
public void Test8()
{
Dog snech = new Dog("K");
Assert.Equal(14, snech.Age);
Assert.Equal(50.0f, snech.Weight);
}

[Fact]
public void Test9()
{
Dog snech = new Dog();
Assert.Equal(
@" __ _
o'')}____//
`_/ )
(_(_/-(_/", snech.Picture());
}

[Fact]
public void Test10()
{
Dog snech = new Dog();
Assert.Equal($"������ �������� {15} ������ ����� ���-��� ", snech.Golos());
}

[Fact]
public void Test11()
{
Dog snech = new Dog();
Assert.Equal("������ �������� 15 � ����� K", snech.ToString());
}
}
}
17 changes: 17 additions & 0 deletions CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
<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>
45 changes: 32 additions & 13 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,58 @@ namespace CourseApp
{
public class Program
{
public static double prgrm(double x, float a, float b)

public static double Prgrm(double x, float a, float b)
{
return ((1 + Math.Pow(Math.Log(x / a), 2)) / (b - Math.Pow(Math.E, (x / a))));
return (1 + Math.Pow(Math.Log(x / a), 2)) / (b - Math.Pow(Math.E, x / a));
}
static void Main()

private static void Main()
{
float a = 2.0f;
float b = 0.95f;
float Xs = 1.25f;
float Xf = 2.75f;
float xs = 1.25f;
float xf = 2.75f;
float dX = 0.3f;

// задание а
// задание а
Console.WriteLine(" a)");
for (float x = Xs; x <= Xf; x += dX)
for (float x = xs; x <= xf; x += dX)
{

Console.WriteLine($" x={x} y={Math.Round(prgrm(x, a, b), 3)}");

Console.WriteLine($" x={x} y={Math.Round(Prgrm(x, a, b), 3)}");
}

Console.WriteLine();
//задание b

// задание b

Console.WriteLine(" b)");
double[] xb = new double[5] { 2.2, 3.78, 4.51, 6.58, 1.2 };
foreach (double i in xb)
{

Console.WriteLine($" X={i} y={Math.Round(prgrm(i, a, b), 3)}");
Console.WriteLine($" X={i} y={Math.Round(Prgrm(i, a, b), 3)}");
}

Dog snech = new Dog();
Cat murka = new Cat();
Console.WriteLine(snech);
Console.WriteLine(murka);
Pet[] pet = new Pet[2];
pet[0] = new Dog();
pet[1] = new Cat();
foreach (Pet i in pet)
{
i.GetInfo();
Console.WriteLine(i.Golos());
Console.WriteLine(i.Picture());
}


Console.ReadLine();
}



}
}
}
Loading