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
29 changes: 29 additions & 0 deletions CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</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>
72 changes: 72 additions & 0 deletions CourseApp.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using Xunit;
using Matan;

namespace CourseApp.Test
{
public class UnitTest1
{
[Fact]
public void Test1()
{
var res = Program.Y(0, 0, 0);
Assert.Equal(0, res);
}

[Fact]
public void Test2()
{
var res = Program.Y(1, 0, 0);
Assert.Equal(double.NaN, res);
}

[Fact]
public void Test3()
{
var res = Program.Y(1, 1, 0);
Assert.Equal(double.PositiveInfinity, res);
}

[Fact]
public void Test4()
{
var res = Program.Y(5, 1, -8);
Assert.Equal(10.96, res, 2);
}

[Fact]
public void Test5()
{
var res = Program.Y(2, 3, 0);
Assert.Equal(10.49, res, 2);
}

[Fact]
public void Test6()
{
var res = Program.Y(0, 4, -9);
Assert.Equal(0, res);
}

[Fact]
public void Test7()
{
var res = Program.Y(8, 2, 4);
Assert.Equal(6.38, res, 2);
}

[Fact]
public void Test9()
{
var res = Program.Y(0, 3, 2);
Assert.Equal(0, res);
}

[Fact]
public void Test10()
{
var res = Program.Y(0, 3, 3);
Assert.Equal(0, res);
}
}
}
63 changes: 63 additions & 0 deletions CourseApp.Tests/UnitTest2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using Xunit;
using Menu;

namespace CourseApp.Tests
{
public class UnitTest2
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()
{
Dish salad = new Dish("Cesar", 500, "Salad", 250);
Assert.Equal("Cesar", salad.Name);
Assert.Equal(500, salad.Price);
Assert.Equal("Salad", salad.Type);
Assert.Equal(250, salad.Weight);
}

[Fact]
public void Test2()
{
Dish soup = new Dish("chees", 250);
Assert.Equal("chees", soup.Name);
Assert.Equal(250, soup.Price);
}

[Fact]
public void Test3()
{
Dish soup = new Dish("chees", -3);
Assert.Equal("chees", soup.Name);
Assert.Equal(0, soup.Price);
}

[Fact]
public void Test4()
{
Dish soup = new Dish("Cesar", 20);
Assert.Equal("Cesar", soup.Name);
Assert.Equal(20, soup.Price);
}

[Fact]
public void Test5()
{
Dish salad = new Dish("Paprica", 500, "Salad", -3);
Assert.Equal("Paprica", salad.Name);
Assert.Equal(500, salad.Price);
Assert.Equal("Salad", salad.Type);
Assert.Equal(0, salad.Weight);
}

[Fact]
public void Test6()
{
Dish salad = new Dish("Cesar", -100, "rrrrrrrrr", 1000);
Assert.Equal("Cesar", salad.Name);
Assert.Equal(0, salad.Price);
Assert.Equal("NoType", salad.Type);
Copy link
Contributor

Choose a reason for hiding this comment

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

А почему будет noType?

Assert.Equal(1000, salad.Weight);
}
}
}
17 changes: 16 additions & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.0</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>
31 changes: 31 additions & 0 deletions CourseApp/CourseApp.sln
Original file line number Diff line number Diff line change
@@ -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", "{270747D2-1BE6-4FB6-AB36-C427275A74F3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{A8BE50E0-7D41-4C54-8B0E-1AA0AEE23645}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{270747D2-1BE6-4FB6-AB36-C427275A74F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{270747D2-1BE6-4FB6-AB36-C427275A74F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{270747D2-1BE6-4FB6-AB36-C427275A74F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{270747D2-1BE6-4FB6-AB36-C427275A74F3}.Release|Any CPU.Build.0 = Release|Any CPU
{A8BE50E0-7D41-4C54-8B0E-1AA0AEE23645}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8BE50E0-7D41-4C54-8B0E-1AA0AEE23645}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8BE50E0-7D41-4C54-8B0E-1AA0AEE23645}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8BE50E0-7D41-4C54-8B0E-1AA0AEE23645}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E01AD994-55CD-4736-AD2F-24B07F270089}
EndGlobalSection
EndGlobal
55 changes: 55 additions & 0 deletions CourseApp/Dish.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;

namespace Menu
{
public class Dish
{
private int price;
private string type;
private int weight;

public Dish(string name, int price, string type, int weight)
{
Name = name == string.Empty ? $"NoName" : name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Боюсь что вся лаба плагиат с лабы 147 группы, код, который совместно написан я вижу, но ок, есть что здесь улучшить

this.Price = price;
this.Type = type;
this.Weight = weight;
}

public Dish(string name, int price)
: this(name, price, string.Empty, 0)
{
}

public string Name { get; set; }

public int Price
{
get => price;
set
{
price = value > 0 ? value : 0;
}
}

public string Type
{
get => type;
set
{
type = value == $"Salad" ? value : $"NoType";
}
}

public int Weight
{
get => weight;
set
{
weight = value > 0 ? value : 0;
}
}

public void GetInfo() => Console.WriteLine($"��������: {Name} ����: {price} ���: {type} ���: {weight}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Поправьте кодировку

}
}
43 changes: 38 additions & 5 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
using System;
using Menu;

namespace CourseApp
namespace Matan
{
class Program
public class Program
{
static void Main(string[] args)
public static double Y(double x, double a, double b)
{
Console.WriteLine("Hello World!");
return Math.Sqrt(Math.Abs(a - (b * x)) / Math.Pow(Math.Log10(x), 3));
}

public static void Main(string[] args)
{
double a = 7.2;
double b = 4.2;
double xn = 1.81;
double xk = 5.31;
double dx = 0.7;

double[] x = new double[5] { 2.4, 2.8, 3.9, 4.7, 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}");
}

Dish salad = new Dish("Cesar", 500, "Salad", 250);
Dish soup = new Dish("chees", 250);
salad.GetInfo();
soup.GetInfo();

Console.ReadKey();
}
}
}
}
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
���� �������
Binary file added WebApplication (1).7z
Binary file not shown.
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>