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: 17 additions & 6 deletions CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<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.8.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<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>

</Project>
<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);
}
}
}
56 changes: 56 additions & 0 deletions CourseApp.Tests/PigTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using Xunit;
using ConsoleApp2;

namespace CourseApp.Tests
{
public class UnitTest2
{
[Fact]
public void CheckSecondKonstruktor1()
{
Pig pig1 = new Pig(15, 150);
Assert.Equal(6, pig1.Weight);
Assert.Equal("Noname", pig1.Name);
Assert.Equal(15, pig1.Age);
Assert.Equal(150, pig1.Weight);
}
[Fact]

public void CheckSecondKonstruktor2()
{
Pig Pig2 = new pig(21, 215);
Assert.Equal(9, Pig2.Name.weight);
Assert.Equal("Toto", Pig2.Name);
Assert.Equal(21, Pig2.age);
Assert.Equal(215, Pig2.weight);
}
[Fact]
public void CheckSecondKonstruktor3()
{
Pig Pig3 = new pig(20, 210);
Assert.Equal(4, Pig3.Name.weight);
Assert.Equal("Okta", Pig10.Name);
Assert.Equal(21, Pig10.age);
Assert.Equal(215, Pig10.weight);
}
[Fact]
public void CheckSecondKonstruktor4()
{
Pig Pig4 = new pig(25, 350);
Assert.Equal(5, Pig4.Name.weight);
Assert.Equal("Fufa", Pig4.Name);
Assert.Equal(25, Pig4.age);
Assert.Equal(350, Pig4.weight);
}
[Fact]
public void CheckSecondKonstruktor5()
{
Pig Pig5 = new pig(25, 350);
Assert.Equal(8, Pig5.Name.weight);
Assert.Equal("Tufa", Pig5.Name);
Assert.Equal(25, Pig5.age);
Assert.Equal(350, Pig5.weight);
}
}
}
12 changes: 6 additions & 6 deletions CourseApp.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ public class UnitTest1
[Fact]
public void Test1()
{
var res = Program.y(0, 0, 1);
var res = Program.Y(0, 0, 1);
Assert.Equal(Double.NaN, res);
}
[Fact]
public void Test2()
{
var res = Program.y(2, 0, 1);
var res = Program.Y(2, 0, 1);
Assert.Equal(2.39014261372843, res);
}
[Fact]
public void Test3()
{
var res = Program.y(0, 0, 0);
var res = Program.Y(0, 0, 0);
Assert.Equal(Double.PositiveInfinity, res);
}
[Fact]
public void Test4()
{
var res = Program.y(1, 0, 0);
var res = Program.Y(1, 0, 0);
Assert.Equal(2, res);
}
[Fact]
public void Test5()
{
var res = Program.y(1, 2, 1);
var res = Program.Y(1, 2, 1);
Assert.Equal(Double.NaN, res);
}
[Fact]
public void Test6()
{
var res = Program.y(0, 1, 1);
var res = Program.Y(0, 1, 1);
Assert.Equal(Double.NaN, res);
}
}
Expand Down
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>
60 changes: 60 additions & 0 deletions CourseApp/Pig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;

namespace ConsoleApp2
{
public class Pig
{
private string name;
private int age;
private int weight;

public Pig(string name, int age, int weight)
{
this.name = name;
this.age = age;
this.weight = weight;
}

public Pig(int age, int weight)
{
this.name = "Noname";
this.age = age;
this.weight = weight;
}

public string Name
{
get => name;
set => name = value;
}

public int Age
{
get => age;
set
{
if (value > 10)
{
age = value;
}
}
}

public int Weight
{
get => weight;
set
{
if (value > 70)
{
weight = value;
}
}
}

public string GetInfo()
{
return $"Имя: {Name} возраст: {age} вес: {weight}";
}
}
}
26 changes: 14 additions & 12 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,33 @@ namespace CourseApp
{
public class Program
{
public static double y(double x, double a, double b)
{
return ((Math.Pow((Math.Pow((x - a), 2)), 1/3.0))) + ((((Math.Pow((Math.Abs(x + b)),1 / 5))) / ((Math.Pow(Math.Pow(x,2) - Math.Pow((a+b),2), 1/5.0)))));
public static double Y(double x, double a, double b)
{
return (Math.Pow(Math.Pow(x - a, 2), 1 / 3.0) + Math.Pow(Math.Abs(x + b), 1 / 5)) / Math.Pow(Math.Pow(x, 2) - Math.Pow(a + b, 2), 1 / 5.0);
}
static void Main(string[] args)

public static void Main(string[] args)
{
double a = 0.8;
double b = 0.4;
double xn = 1.23;
double xk = 7.23;
double dx = 1.2;
double[] x = new double[5] {1.88, 2.26, 3.84, 4.55, -6.21 };

double[] x = new double[5] { 1.88, 2.26, 3.84, 4.55, -6.21 };

Console.WriteLine("Задача A:");

for (double xl = xn; xl < xk; xl+=dx)
for (double xl = xn; xl < xk; xl += dx)
{
Console.WriteLine($"Для x = {xl}\t y = {y(xl, a, b)}");
Console.WriteLine($"Для x = {xl}\t y = {Y(xl, a, b)}");
}
Console.WriteLine("Задача B:");

foreach (double i in x)
Console.WriteLine("Задача B:");

foreach (double i in x)
{
Console.WriteLine($"Для x = {i}\t y = {y(i, a, b)}");
Console.WriteLine($"Для x = {i}\t y = {Y(i, a, b)}");
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Course of c#

Please write your name and surname here
Dmitrij_Shmelev
15 changes: 15 additions & 0 deletions stylecop/stylecop.json
Original file line number Diff line number Diff line change
@@ -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"]
}
22 changes: 22 additions & 0 deletions stylecop/stylecop.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="StyleCopeRules" Description="StyleCopeRules custom ruleset" ToolsVersion="14.0">
<IncludeAll Action="None" />
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1101" Action="None" />
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1210" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="AD0001" Action="None" />
<Rule Id="CA2234" Action="None" />
<Rule Id="SA1200" Action="None" />
<Rule Id="SA1000" Action="None" />
<Rule Id="SA1012" Action="None" />
<Rule Id="SA1012" Action="None" />
<Rule Id="SA1009" Action="None" />
<Rule Id="SA1012" Action="None" />
<Rule Id="SA1652" Action="None" />
<Rule Id="CA1305" Action="None" />
<Rule Id="CA1056" Action="None" />
</Rules>
</RuleSet>