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
2 changes: 1 addition & 1 deletion CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
<AdditionalFiles Include="../_stylecop/stylecop.json" />
</ItemGroup>

</Project>
</Project>
44 changes: 44 additions & 0 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,58 @@
using System;
using System.Collections.Generic;
using Xunit;

namespace CourseApp.Tests
{
public class DemoTest
{
[Theory]
[InlineData(2, 4, 0.01682)]
[InlineData(10, -5, 0.0195424)]
public void TestMyFunction(double a, double x, double exp)
{
Assert.Equal(Program.Function(a, x), exp, 3);
}

[Fact]

public void TestTaskA()
{
double a = 2.0;
double xn = 1.2;
double xk = 4.2;
double dx = 0.6;
List<double> res = Program.TaskA(a, xn, xk, dx);
List<double> expy = new List<double> { 0.024919580136386867, 0.02327901792977313, 0.02138591667754329, 0.019542362678459768, 0.01785029731362981 };
for (int i = 0; i < 5; i++)
{
Assert.Equal(expy[i], res[i], 3);
}
}

[Fact]
public void Test1()
{
Assert.True(true);
}

[Fact]
public void TestZeroFunction()
{
var res = Program.Function(0.0, 0.0);
Assert.Equal(double.PositiveInfinity, res);
}

[Fact]
public void TestTaskB()
{
List<double> x = new List<double> { 1.16, 1.32, 1.47, 1.65, 1.93 };
List<double> res = Program.TaskB(2.0, x);
List<double> expy = new List<double> { 0.025004724857363752, 0.024639361870982292, 0.024247019851321865, 0.023732277381772752, 0.022875026963062515 };
for (int i = 0; i < 5; i++)
{
Assert.Equal(expy[i], res[i], 3);
}
}
}
}
64 changes: 64 additions & 0 deletions CourseApp.Tests/DogTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using Xunit;

namespace CourseApp.Tests
{
public class DogTest
{
[Fact]
public void TestConstructor()
{
var item = new Dog();
Assert.Equal(1, item.Age);
Assert.Equal("Test", item.Name);
Assert.Equal("male", item.Sex);
}

[Fact]
public void TestSetAge()
{
var item = new Dog();
item.Age = 3;
Assert.Equal(3, item.Age);
}

[Fact]
public void TestWrongAge()
{
var item = new Dog();
try
{
item.Age = 0;
}
catch (System.Exception)
{
Console.WriteLine("ERROR! Rewrite Age!");
Assert.True(true);
}
}

[Fact]
public void TestWrongSex()
{
var item = new Dog();
try
{
item.Sex = "lemonade";
}
catch (System.Exception)
{
Console.WriteLine("ERROR! Rewrite Sex!");
Assert.True(true);
}
}

[Fact]
public void FullTest()
{
var item = new Dog("Doberman", 3, "male");
Assert.Equal("Doberman", item.Name);
Assert.Equal("male", item.Sex);
Assert.Equal(3, item.Age);
}
}
}
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"
}
]
}
2 changes: 1 addition & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
<AdditionalFiles Include="../_stylecop/stylecop.json" />
</ItemGroup>

</Project>
</Project>
80 changes: 80 additions & 0 deletions CourseApp/Dog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;

namespace CourseApp
{
public class Dog
{
private int age;
private string sex;

public Dog()
Comment thread
jskonst marked this conversation as resolved.
: this("Test")
{
}

public Dog(string name, int age, string sex)
{
Name = name;
Age = age;
Sex = sex;
}

public Dog(string name)
: this(name, 1, "male")
{
}

public string Name { get; set; }

public string Sex
{
get
{
return this.sex;
}

set
{
if (value == "male")
{
this.sex = value;
}
else
{
throw new System.Exception();
}
}
}

public int Age
{
get
{
return this.age;
}

set
{
if (value >= 1 && value < 10)
{
this.age = value;
}
else
{
throw new System.Exception();
}
}
}

public override string ToString()
{
return $"Имя:{Name},Возраст:{Age},Пол:{Sex}";
}

public void AgeUp()
{
this.Age++;
}
}
}
58 changes: 56 additions & 2 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
using System;
using System.Collections.Generic;

namespace CourseApp
{
public class Program
{
public static double Function(double a, double x)
{
var y = Math.Pow(Math.Log10(a + x), 2) / Math.Pow(a + x, 2);

return y;
}

public static List<double> TaskA(double a, double xn, double xk, double dx)
{
int k = 0;
List<double> y = new List<double>(5);
for (var i = xn; i < xk; i += dx)
{
y.Add(Function(a, i));
k++;
}

return y;
}

public static List<double> TaskB(double a, List<double> x)
{
List<double> y = new List<double>(5);
for (var i = 0; i < x.Count; i++)
{
y.Add(Function(a, x[i]));
}

return y;
}

public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.ReadLine();
double a = 2.0;
double xn = 1.2;
double xk = 4.2;
double dx = 0.6;
var resA = TaskA(a, xn, xk, dx);
Console.WriteLine("==========");
Console.WriteLine("Задание А:");
Console.WriteLine("==========");
foreach (var item in resA)
{
Console.WriteLine($"y = {item}");
}

Console.WriteLine("==========");
List<double> x = new List<double> { 1.16, 1.32, 1.47, 1.65, 1.93 };
var taskBRes = TaskB(a, x);
Console.WriteLine("Задание В:");
Console.WriteLine("==========");
foreach (var item in taskBRes)
{
Console.WriteLine($"y1 = {item}");
}

Console.WriteLine("==========");
}
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Vladislav_Savchenko
Vladislav_Savchenko
# Tprogramming_147_2019