Skip to content
Merged
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: 23 additions & 0 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: .NET Core

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.802
- name: Build with dotnet
run: |
cd CourseApp
dotnet build --configuration Release
- name: Run tests
run: |
cd CourseApp.Tests
dotnet test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ $RECYCLE.BIN/
**/node_modules/*

# Added by Jskonst
.vscode/
Properties/

#####
Expand Down
14 changes: 0 additions & 14 deletions CourseApp.Tests/DemoTest.cs

This file was deleted.

49 changes: 49 additions & 0 deletions CourseApp.Tests/FunctionTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using Xunit;

namespace CourseApp.Tests
{
public class FunctionTest
{
[Theory]
[InlineData(0, double.NegativeInfinity)]
[InlineData(2, 0.2)]
[InlineData(1, 0)]
public void TestCalc(double x, double exp)
{
var res = Function.MyFunction(x);
Assert.Equal(exp, res, 1);
}

[Fact]
public void TestNormalA()
{
List<double> action = Function.TaskA(0.11, 0.36, 0.05);
List<double> s = new List<double>() { -0.942599174573112, -0.768989662415832, -0.640224062047432, -0.537938691770828, -0.453755045309719 };
for (var i = 0; i < 5; i++)
{
Assert.Equal(action[i], s[i], 3);
}
}

[Fact]
public void TestNormalB()
{
List<double> x = new List<double> { 0.2, 0.3, 0.38, 0.43, 0.57 };
var actial = Function.TaskB(x);
List<double> exp = new List<double> { -0.663479953941618, -0.469395196867133, -0.357994574230452, -0.301819984896032, -0.184040925422074 };
for (var i = 0; i < 5; i++)
{
Assert.Equal(exp[i], actial[i], 3);
}
}

[Fact]
public void TestZeroLengthB()
{
var res = Function.TaskB(new List<double>());
Assert.Empty(res);
}
}
}
56 changes: 56 additions & 0 deletions CourseApp.Tests/PistolTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using Xunit;

namespace CourseApp.Tests
{
public class PistolTest
{
[Fact]
public void TestEmptyConstructor()
{
var item = new Pistol();
Assert.Equal(0, item.Kalibr);
Assert.Equal("No model", item.Model);
Assert.True(item.Fire);
}

[Fact]
public void TestSetAge()
{
var item = new Pistol();
item.Kalibr = 5;
Assert.Equal(5, item.Kalibr);
}

[Fact]
public void TestShoot()
{
var item = new Pistol("Glock", 10, true);
var act = item.Shoot(true);
Assert.Equal($"Pistol Glock and 10 made the shot!", act);
}

[Fact]
public void TestNumShoot()
{
var item = new Pistol("Glock", 10, true);
var act = item.NumShoot(15);
Assert.Equal($"Glock made of 15 shots", act);
}

[Fact]
public void TestCorrectIncorrectSetKalibr()
{
var item = new Pistol();
try
{
item.Kalibr = -5;
Assert.Equal(-5, item.Kalibr);
}
catch (System.Exception)
{
Assert.True(true);
}
}
}
}
25 changes: 25 additions & 0 deletions CourseApp/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +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}"
}
]
}
42 changes: 42 additions & 0 deletions CourseApp/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +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"
}
]
}
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.28307.852
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{17CB0273-34D3-4D23-965F-FC4AD0A83D0F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{E0133767-62A2-4B4A-87A2-BD09BC775E0A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Release|Any CPU.Build.0 = Release|Any CPU
{E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1849B280-B447-4D18-9764-F412B7768C4F}
EndGlobalSection
EndGlobal
69 changes: 69 additions & 0 deletions CourseApp/Function.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace CourseApp
{
public class Function
{
public static double MyFunction(double x)
{
var c = (Math.Pow(Math.Sin(x), 3) + Math.Pow(Math.Cos(x), 3)) * Math.Log10(x);
Console.WriteLine(c);
return c;
}

public static List<double> TaskA(
double xn,
double xk,
double dx)
{
List<double> y = new List<double>();
for (var x = xn; x < xk; x += dx)
{
y.Add(MyFunction(x));
}

return y;
}

public static List<double> TaskB (
List<double> x)
{
List<double> y = new List<double>(5);
foreach (double i in x)
{
y.Add(MyFunction(i));
}

return y;
}

public static void Main(string[] args)
{
MyFunction(0);
Console.WriteLine("Hello World!");
List<double> taskA = TaskA(0.11, 0.36, 0.05);
Console.WriteLine(taskA);

foreach (var item in taskA)
{
Console.WriteLine($"y={item}");
}

List<double> xB = new List<double>() { 0.2, 0.3, 0.38, 0.43, 0.57 };
List<double> taskB = TaskB(xB);
for (int i = 0; i < 5; i++)
{
Console.WriteLine($"x={xB[i]}");
}

foreach (var item in taskB)
{
Console.WriteLine($"y={item}");
}

Console.ReadLine();
}
}
}
Loading