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
85 changes: 9 additions & 76 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,20 @@ namespace CourseApp.Tests
{
public class DemoTest
{
[Theory]
[InlineData(7.2, 3.8, 1, 0)]
[InlineData(12.2, 4.5, 1, 0)]
[InlineData(20.2, 2.7, 1, 0)]

public void TestForFunctionValues(double a, double b, double x, double exp)
{
var res = Program.MyFunction(a, b, x);
Assert.Equal(res, exp);
}

[Fact]
public void TestFunctionZeroVal()
public void Test1()
{
var res = Program.MyFunction(0, 0, 0);
Assert.Equal(0, res, 3);
Assert.True(true);
}

[Theory]
[InlineData(7.2, 4.2, 1.81, 5.31, 0.7)]
[InlineData(3.2, 3.2, 1.5, 6.1, 0.5)]
[InlineData(4.1, 1.1, 0.3, 6.5, 1.0)]

public void TestTaskAElements(double a, double b, double xn, double xk, double dx)
{
try
{
var res = Program.TaskA(a, b, xn, xk, dx);
double massElemExpected = (xk - xn) / dx;
Assert.Equal(expected: massElemExpected, actual: res.Count);
}
catch (IndexOutOfRangeException)
{
Console.WriteLine("Out Of Bounds");
Assert.True(true);
}
}

[Theory]
[InlineData(7.2, 4.2, 1.81, 5.31, 0.7)]
[InlineData(3.2, 3.2, 1.5, 6.1, 0.5)]

public void TestATaskAllMoreThenZero(double a, double b, double xn, double xk, double dx)
[InlineData(0, 0, 0, 0)]
[InlineData(0, 2, 1, 2)]
[InlineData(1, 2, 1, 3)]
public void TestFunctionCalculationVal(double a, double b, double x, double exp)
{
try
{
var res = Program.TaskA(a, b, xn, xk, dx);

double massElemExpected = (xk - xn) / dx;

Assert.Equal(expected: massElemExpected, actual: res.Count);
}
catch (IndexOutOfRangeException)
{
Console.WriteLine("Out Of Bounds");
Assert.True(true);
}
catch (ArgumentOutOfRangeException)
{
Console.WriteLine("Argument Out Of Range");
Assert.True(true);
}
}

[Fact]
public void TestATaskTooLargeSteps()
{
var res = Program.TaskA(7.2, 4.2, 1.81, 5.31, 5);
int count = res.Count;
Assert.Equal(1, count);
}

[Theory]
[InlineData(4.1, 2.7)]
[InlineData(5.2, 3.5)]
[InlineData(6.3, 1.3)]
public void TestTaskB(double a, double b)
{
double[] e = new double[0];
var res = Program.TaskB(a, b, e);
Assert.Equal(res, new double[0]);
var res = Program.MyFunction(a, b, x);
Assert.Equal(exp, res, 3);
}
}
}
}
115 changes: 0 additions & 115 deletions CourseApp.Tests/DishTest.cs

This file was deleted.

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

namespace CourseApp.Tests
{
public class PlatypusTest
{
[Fact]
public void TestEmptyConstructor()
{
var item = new Platypus();
Assert.Equal(0, item.Age);
Assert.Equal("Untitled", item.Name);
Assert.True(item.IsMale);
}

[Fact]
public void TestView()
{
var item = new Platypus();
var view = @"
_.-^~~^^^`~-,_,,~''''''```~,''``~'``~,
______,' -o :. _ . ; ,'`, `.
( -\.._,.;;'._ ,( } _`_-_,, `, `,
``~~~~~~' ((/'((((____/~~~~~~'(,(,___> `~'
";
Assert.Equal(view, item.View());
}

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

[Fact]
public void TestIncorrectSetAge()
{
var item = new Platypus();
item.Age = -5;
Assert.Equal(0, item.Age);
}

[Fact]
public void TestCorrectIncorrectSetAge()
{
var item = new Platypus();
item.Age = 10;
item.Age = -5;
Assert.Equal(10, item.Age);
}
}
}
73 changes: 73 additions & 0 deletions CourseApp/Class/Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CourseApp
{
public class Player
{
private List<string> sampleNames = new List<string>() { "John", "James", "Arthur", "Samplename", "Nick", "Victor" };

public Player()
{
Name = SetName();
Active = new List<ISpell>();
Passive = new List<ISpell>();
}

public int PlayerMaxHp { get; set; }

public string Name { get; set; }

public string ClassName { get; set; }

public int Strength { get; set; }

public int Agility { get; set; }

public int Intelligence { get; set; }

public int CurrentHp { get; set; }

public bool IsStunned { get; set; }

public List<ISpell> Active { get; set; }

public List<ISpell> Passive { get; set; }

public int MaxHp
{
get { return this.PlayerMaxHp; }
set { this.PlayerMaxHp = 100 + (this.Strength / 2); }
}

public string SetName()
{
Random rnd = new Random();

return sampleNames[rnd.Next(0, 5)];
}

public void Attack(Player target)
{
Random rnd = new Random();
ISpell choise = this.Active[rnd.Next(0, this.Active.Count)];
choise.Use(this, target);
}

public void SetFullHp()
{
this.CurrentHp = 5 + (this.Strength / 2);
}

public void SetClassName(string name)
{
this.ClassName = name;
}

public void GetDamage(int dmg)
{
this.CurrentHp = this.CurrentHp - dmg;
}
}
}
50 changes: 50 additions & 0 deletions CourseApp/Class/ReturnFuncs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CourseApp
{
public static class ReturnFuncs
{
public static List<ISpell> GetHunterSpells()
{
BaseAttack baseAttack = new BaseAttack { Name = "hand gun shot" };

Bandage bandage = new Bandage { Name = "Bandages" };

BullsEye bullsEye = new BullsEye { Name = "BullsEye" };

DaggerThrow daggerThrow = new DaggerThrow { Name = "Dagger throw" };
List<ISpell> spells = new List<ISpell>() { baseAttack, bandage, bullsEye, daggerThrow };
return spells;
}

public static List<ISpell> GetTitanSpells()
{
BaseAttack baseAttack = new BaseAttack { Name = "Rifle shot" };

FirstAidKit firstAidKit = new FirstAidKit { Name = "first aid kit" };

FistPunch fistPunch = new FistPunch { Name = "Fist punch" };

GrenadeThrow grenadeThrow = new GrenadeThrow { Name = "Grenade throw" };

List<ISpell> spells = new List<ISpell>() { baseAttack, firstAidKit, fistPunch, grenadeThrow };
return spells;
}

public static List<ISpell> GetWarlockSpells()
{
BaseAttack baseAttack = new BaseAttack { Name = "hand gun shot" };

HealingRift healingRift = new HealingRift { Name = "Healing rift" };

VoidBlast voidBlast = new VoidBlast { Name = "Void blast" };

VoidSlash voidSlash = new VoidSlash { Name = "Void slash" };

List<ISpell> spells = new List<ISpell>() { baseAttack, healingRift, voidBlast, voidSlash };
return spells;
}
}
}
Loading