Skip to content
Open

dz #29

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

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<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.1.118" 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>
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why this file shown as changed?
configure you gitattributes to fit lineendings

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<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.1.118" 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>
13 changes: 0 additions & 13 deletions CourseApp.Tests/DemoTest.cs

This file was deleted.

69 changes: 69 additions & 0 deletions CourseApp.Tests/TestEmployee.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using Xunit;
using EmployeeClass;
using System.Threading;

namespace TestEmployee
{
public class TestEmployee
{
[Fact]
public void timeSpentFromGettingAJob_return2Seconds()
{
Employee emp = new Employee();

Thread.Sleep(2000);

TimeSpan totalSeconds = emp.timeSpentFromGettingJob();

double res = Math.Round(totalSeconds.TotalSeconds);

int seconds = 2;

Assert.Equal(seconds, res);
}

[Fact]
public void getJob_returns_Lvl1_2_3()
{
Employee emp = new Employee();

string res = emp.getJob();

if(res == "Lvl 1")
{
Assert.Equal(res, "Lvl 1");
}
else if(res == "Lvl 2")
{
Assert.Equal(res, "Lvl 2");
}
else
{
Assert.Equal(res, "Lvl 3");
}
}

[Fact]
public void getSalery_returns_1000_2000_3000()
{
Employee emp = new Employee();

int res = emp.getSalary();

if(emp.job == "Lvl 1")
{
Assert.Equal(1000, res);
}
else if(emp.job == "Lvl 2")
{
Assert.Equal(2000, res);
}
else
{
Assert.Equal(3000, res);
}

}
}
}
42 changes: 42 additions & 0 deletions CourseApp.Tests/TestFormula.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Xunit;
using Formula;

namespace TestFormula
{
public class TestFormula
{
[Theory]
[InlineData(1.2,5.2,0.8,4.1,2.7)]
public void TestFormulaA(double xb, double xe, double dx, double a, double b)
{
Formula13 f = new Formula13();

double[] f_res = new double[5] { -5.988041709469331, 1, 20.10917011949253, 13.56786626062469, 11.505040323579745 };

double[] res = f.countFormulaA(xb, xe, dx, a, b);

for (int i = 0; i < res.Length; i++)
{
Assert.Equal(res[i], f_res[i]);
}
}

[Theory]
[InlineData(4.1,2.7)]
public void TestFormulaB(double a, double b)
{
Formula13 f = new Formula13();

double[] x_nums = new double[5] { 1.9, 2.15, 2.34, 2.73, 3.16 };
double[] f_res = new double[5] { -99.97670497061331, 77.88791023801342, 38.122692372591594, 21.380274597107814, 16.020495497448806 };

double[] res = f.countFormulaB(x_nums, a, b);

for (int i = 0; i < res.Length; i++)
{
Assert.Equal(res[i], f_res[i]);
}
}
}
}
48 changes: 24 additions & 24 deletions CourseApp/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/CourseApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/CourseApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
82 changes: 41 additions & 41 deletions CourseApp/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CourseApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/CourseApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/CourseApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CourseApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/CourseApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/CourseApp.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
44 changes: 22 additions & 22 deletions CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet>
<GenerateFullPaths>true</GenerateFullPaths>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="../_stylecop/stylecop.json" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
<CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet>
<GenerateFullPaths>true</GenerateFullPaths>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="../_stylecop/stylecop.json" />
</ItemGroup>
</Project>
Loading