mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 12:26:07 +01:00
Rendrakás
This commit is contained in:
@@ -1,11 +1,6 @@
|
|||||||
using OE.ALGA.Paradigmak;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
namespace OE.ALGA.Adatszerkezetek
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
[*.cs]
|
|
||||||
|
|
||||||
dotnet_diagnostic.IDE1006.severity = none
|
|
||||||
dotnet_diagnostic.IDE0090.severity = none
|
|
||||||
dotnet_diagnostic.IDE0290.severity = none
|
|
||||||
dotnet_diagnostic.CA1859.severity = none
|
|
||||||
63
ALGA_heti_feladatok/.gitattributes
vendored
63
ALGA_heti_feladatok/.gitattributes
vendored
@@ -1,63 +0,0 @@
|
|||||||
###############################################################################
|
|
||||||
# Set default behavior to automatically normalize line endings.
|
|
||||||
###############################################################################
|
|
||||||
* text=auto
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Set default behavior for command prompt diff.
|
|
||||||
#
|
|
||||||
# This is need for earlier builds of msysgit that does not have it on by
|
|
||||||
# default for csharp files.
|
|
||||||
# Note: This is only used by command line
|
|
||||||
###############################################################################
|
|
||||||
#*.cs diff=csharp
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Set the merge driver for project and solution files
|
|
||||||
#
|
|
||||||
# Merging from the command prompt will add diff markers to the files if there
|
|
||||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
|
||||||
# the diff markers are never inserted). Diff markers may cause the following
|
|
||||||
# file extensions to fail to load in VS. An alternative would be to treat
|
|
||||||
# these files as binary and thus will always conflict and require user
|
|
||||||
# intervention with every merge. To do so, just uncomment the entries below
|
|
||||||
###############################################################################
|
|
||||||
#*.sln merge=binary
|
|
||||||
#*.csproj merge=binary
|
|
||||||
#*.vbproj merge=binary
|
|
||||||
#*.vcxproj merge=binary
|
|
||||||
#*.vcproj merge=binary
|
|
||||||
#*.dbproj merge=binary
|
|
||||||
#*.fsproj merge=binary
|
|
||||||
#*.lsproj merge=binary
|
|
||||||
#*.wixproj merge=binary
|
|
||||||
#*.modelproj merge=binary
|
|
||||||
#*.sqlproj merge=binary
|
|
||||||
#*.wwaproj merge=binary
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# behavior for image files
|
|
||||||
#
|
|
||||||
# image files are treated as binary by default.
|
|
||||||
###############################################################################
|
|
||||||
#*.jpg binary
|
|
||||||
#*.png binary
|
|
||||||
#*.gif binary
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# diff behavior for common document formats
|
|
||||||
#
|
|
||||||
# Convert binary document formats to text before diffing them. This feature
|
|
||||||
# is only available from the command line. Turn it on by uncommenting the
|
|
||||||
# entries below.
|
|
||||||
###############################################################################
|
|
||||||
#*.doc diff=astextplain
|
|
||||||
#*.DOC diff=astextplain
|
|
||||||
#*.docx diff=astextplain
|
|
||||||
#*.DOCX diff=astextplain
|
|
||||||
#*.dot diff=astextplain
|
|
||||||
#*.DOT diff=astextplain
|
|
||||||
#*.pdf diff=astextplain
|
|
||||||
#*.PDF diff=astextplain
|
|
||||||
#*.rtf diff=astextplain
|
|
||||||
#*.RTF diff=astextplain
|
|
||||||
363
ALGA_heti_feladatok/.gitignore
vendored
363
ALGA_heti_feladatok/.gitignore
vendored
@@ -1,363 +0,0 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
|
||||||
## files generated by popular Visual Studio add-ons.
|
|
||||||
##
|
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
|
||||||
|
|
||||||
# User-specific files
|
|
||||||
*.rsuser
|
|
||||||
*.suo
|
|
||||||
*.user
|
|
||||||
*.userosscache
|
|
||||||
*.sln.docstates
|
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
|
||||||
*.userprefs
|
|
||||||
|
|
||||||
# Mono auto generated files
|
|
||||||
mono_crash.*
|
|
||||||
|
|
||||||
# Build results
|
|
||||||
[Dd]ebug/
|
|
||||||
[Dd]ebugPublic/
|
|
||||||
[Rr]elease/
|
|
||||||
[Rr]eleases/
|
|
||||||
x64/
|
|
||||||
x86/
|
|
||||||
[Ww][Ii][Nn]32/
|
|
||||||
[Aa][Rr][Mm]/
|
|
||||||
[Aa][Rr][Mm]64/
|
|
||||||
bld/
|
|
||||||
[Bb]in/
|
|
||||||
[Oo]bj/
|
|
||||||
[Oo]ut/
|
|
||||||
[Ll]og/
|
|
||||||
[Ll]ogs/
|
|
||||||
|
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
|
||||||
.vs/
|
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
|
||||||
#wwwroot/
|
|
||||||
|
|
||||||
# Visual Studio 2017 auto generated files
|
|
||||||
Generated\ Files/
|
|
||||||
|
|
||||||
# MSTest test Results
|
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
|
||||||
|
|
||||||
# NUnit
|
|
||||||
*.VisualState.xml
|
|
||||||
TestResult.xml
|
|
||||||
nunit-*.xml
|
|
||||||
|
|
||||||
# Build Results of an ATL Project
|
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
|
||||||
dlldata.c
|
|
||||||
|
|
||||||
# Benchmark Results
|
|
||||||
BenchmarkDotNet.Artifacts/
|
|
||||||
|
|
||||||
# .NET Core
|
|
||||||
project.lock.json
|
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
|
||||||
|
|
||||||
# ASP.NET Scaffolding
|
|
||||||
ScaffoldingReadMe.txt
|
|
||||||
|
|
||||||
# StyleCop
|
|
||||||
StyleCopReport.xml
|
|
||||||
|
|
||||||
# Files built by Visual Studio
|
|
||||||
*_i.c
|
|
||||||
*_p.c
|
|
||||||
*_h.h
|
|
||||||
*.ilk
|
|
||||||
*.meta
|
|
||||||
*.obj
|
|
||||||
*.iobj
|
|
||||||
*.pch
|
|
||||||
*.pdb
|
|
||||||
*.ipdb
|
|
||||||
*.pgc
|
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*_wpftmp.csproj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# Visual Studio Trace Files
|
|
||||||
*.e2e
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# AxoCover is a Code Coverage Tool
|
|
||||||
.axoCover/*
|
|
||||||
!.axoCover/settings.json
|
|
||||||
|
|
||||||
# Coverlet is a free, cross platform Code Coverage Tool
|
|
||||||
coverage*.json
|
|
||||||
coverage*.xml
|
|
||||||
coverage*.info
|
|
||||||
|
|
||||||
# Visual Studio code coverage results
|
|
||||||
*.coverage
|
|
||||||
*.coveragexml
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# NuGet Symbol Packages
|
|
||||||
*.snupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/[Pp]ackages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/[Pp]ackages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/[Pp]ackages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignorable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
*.appx
|
|
||||||
*.appxbundle
|
|
||||||
*.appxupload
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!?*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Including strong name files can present a security risk
|
|
||||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
|
||||||
#*.snk
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
ServiceFabricBackup/
|
|
||||||
*.rptproj.bak
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
*.ndf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
*.rptproj.rsuser
|
|
||||||
*- [Bb]ackup.rdl
|
|
||||||
*- [Bb]ackup ([0-9]).rdl
|
|
||||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
node_modules/
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
|
||||||
*.vbw
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# CodeRush personal settings
|
|
||||||
.cr/personal
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# Cake - Uncomment if you are using it
|
|
||||||
# tools/**
|
|
||||||
# !tools/packages.config
|
|
||||||
|
|
||||||
# Tabs Studio
|
|
||||||
*.tss
|
|
||||||
|
|
||||||
# Telerik's JustMock configuration file
|
|
||||||
*.jmconfig
|
|
||||||
|
|
||||||
# BizTalk build output
|
|
||||||
*.btp.cs
|
|
||||||
*.btm.cs
|
|
||||||
*.odx.cs
|
|
||||||
*.xsd.cs
|
|
||||||
|
|
||||||
# OpenCover UI analysis results
|
|
||||||
OpenCover/
|
|
||||||
|
|
||||||
# Azure Stream Analytics local run output
|
|
||||||
ASALocalRun/
|
|
||||||
|
|
||||||
# MSBuild Binary and Structured Log
|
|
||||||
*.binlog
|
|
||||||
|
|
||||||
# NVidia Nsight GPU debugger configuration file
|
|
||||||
*.nvuser
|
|
||||||
|
|
||||||
# MFractors (Xamarin productivity tool) working folder
|
|
||||||
.mfractor/
|
|
||||||
|
|
||||||
# Local History for Visual Studio
|
|
||||||
.localhistory/
|
|
||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
|
||||||
healthchecksdb
|
|
||||||
|
|
||||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
|
||||||
MigrationBackup/
|
|
||||||
|
|
||||||
# Ionide (cross platform F# VS Code tools) working folder
|
|
||||||
.ionide/
|
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
|
||||||
FodyWeavers.xsd
|
|
||||||
@@ -1,274 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
public class TombVerem<T> : Verem<T>
|
|
||||||
{
|
|
||||||
T[] tomb;
|
|
||||||
int n = 0;
|
|
||||||
public TombVerem(int l)
|
|
||||||
{
|
|
||||||
tomb = new T[l];
|
|
||||||
}
|
|
||||||
public bool Ures
|
|
||||||
{
|
|
||||||
get { return n == 0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Felso()
|
|
||||||
{
|
|
||||||
return tomb[n - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Verembe(T ertek)
|
|
||||||
{
|
|
||||||
if (n < tomb.Length)
|
|
||||||
{
|
|
||||||
tomb[n] = ertek;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NincsHelyKivetel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Verembol()
|
|
||||||
{
|
|
||||||
if (Ures)
|
|
||||||
{
|
|
||||||
throw new NincsElemKivetel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
T ertek = tomb[n - 1];
|
|
||||||
n--;
|
|
||||||
return ertek;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class TombSor<T> : Sor<T>
|
|
||||||
{
|
|
||||||
T[] tomb;
|
|
||||||
int n = 0;
|
|
||||||
public TombSor(int l)
|
|
||||||
{
|
|
||||||
tomb = new T[l];
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Ures
|
|
||||||
{
|
|
||||||
get { return n == 0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Elso()
|
|
||||||
{
|
|
||||||
return tomb[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Sorba(T ertek)
|
|
||||||
{
|
|
||||||
if (n < tomb.Length)
|
|
||||||
{
|
|
||||||
tomb[n] = ertek;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NincsHelyKivetel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Sorbol()
|
|
||||||
{
|
|
||||||
if (Ures)
|
|
||||||
{
|
|
||||||
throw new NincsElemKivetel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
T ertek = tomb[0];
|
|
||||||
T[] tmp = new T[tomb.Length];
|
|
||||||
n--;
|
|
||||||
for (int i = 1; i < tomb.Length; i++)
|
|
||||||
{
|
|
||||||
tmp[i - 1] = tomb[i];
|
|
||||||
}
|
|
||||||
tomb = tmp;
|
|
||||||
return ertek;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class TombLista<T> : Lista<T>, IEnumerable<T>
|
|
||||||
{
|
|
||||||
T[] tomb;
|
|
||||||
int n = 0;
|
|
||||||
|
|
||||||
public bool Ures
|
|
||||||
{
|
|
||||||
get { return n <= 0; }
|
|
||||||
}
|
|
||||||
public TombLista()
|
|
||||||
{
|
|
||||||
tomb = new T[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Elemszam
|
|
||||||
{
|
|
||||||
get { return n; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Bejar(Action<T> muvelet)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
muvelet?.Invoke(tomb[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Beszur(int index, T ertek)
|
|
||||||
{
|
|
||||||
if (index < 0)
|
|
||||||
{
|
|
||||||
throw new HibasIndexKivetel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
T[] tmp = new T[tomb.Length * 2];
|
|
||||||
for (int i = 0; i < index; i++)
|
|
||||||
{
|
|
||||||
tmp[i] = tomb[i];
|
|
||||||
}
|
|
||||||
tmp[index] = ertek;
|
|
||||||
for (int i = index + 1; i < tomb.Length; i++)
|
|
||||||
{
|
|
||||||
tmp[i] = tomb[i - 1];
|
|
||||||
}
|
|
||||||
tomb = tmp;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator<T> GetEnumerator()
|
|
||||||
{
|
|
||||||
foreach (T t in tomb)
|
|
||||||
{
|
|
||||||
if (t != null)
|
|
||||||
{
|
|
||||||
yield return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Hozzafuz(T ertek)
|
|
||||||
{
|
|
||||||
if (n < tomb.Length)
|
|
||||||
{
|
|
||||||
tomb[n] = ertek;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
T[] tmp = new T[tomb.Length * 2];
|
|
||||||
for (int i = 0; i < tomb.Length; i++)
|
|
||||||
{
|
|
||||||
tmp[i] = tomb[i];
|
|
||||||
}
|
|
||||||
tmp[n] = ertek;
|
|
||||||
tomb = tmp;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Kiolvas(int index)
|
|
||||||
{
|
|
||||||
if (index < 0 || index >= tomb.Length)
|
|
||||||
{
|
|
||||||
throw new HibasIndexKivetel();
|
|
||||||
}
|
|
||||||
return tomb[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Modosit(int index, T ertek)
|
|
||||||
{
|
|
||||||
if (index < 0 && index < tomb.Length)
|
|
||||||
{
|
|
||||||
throw new HibasIndexKivetel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tomb[index] = ertek;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Torol(T ertek)
|
|
||||||
{
|
|
||||||
int m = n;
|
|
||||||
T[] tmp = new T[tomb.Length];
|
|
||||||
int index = 0;
|
|
||||||
for (int i = 0; i < m; i++)
|
|
||||||
{
|
|
||||||
if (ertek.Equals(tomb[i]))
|
|
||||||
{
|
|
||||||
n--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tmp[index] = tomb[i];
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
tomb = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
{
|
|
||||||
TombListaBejaro<T> bejaro = new TombListaBejaro<T>(tomb, n);
|
|
||||||
return bejaro;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class TombListaBejaro<T> : IEnumerator<T>
|
|
||||||
{
|
|
||||||
T[] e;
|
|
||||||
int n;
|
|
||||||
int aktualisindex;
|
|
||||||
T current;
|
|
||||||
public T Current
|
|
||||||
{
|
|
||||||
get { return current; }
|
|
||||||
}
|
|
||||||
public TombListaBejaro(T[] e, int n)
|
|
||||||
{
|
|
||||||
this.n = n;
|
|
||||||
this.e = e;
|
|
||||||
aktualisindex = 0;
|
|
||||||
current = e[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
object IEnumerator.Current => Current;
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
if (aktualisindex < n - 1)
|
|
||||||
{
|
|
||||||
aktualisindex++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
aktualisindex = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA
|
|
||||||
{
|
|
||||||
public interface Lista<T>
|
|
||||||
{
|
|
||||||
public int Elemszam { get; }
|
|
||||||
|
|
||||||
public T Kiolvas(int index);
|
|
||||||
public void Modosit(int index, T ertek);
|
|
||||||
public void Hozzafuz(T ertek);
|
|
||||||
public void Beszur(int index, T ertek);
|
|
||||||
public void Torol(T ertek);
|
|
||||||
public void Bejar(Action<T> muvelet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Halmaz<T>
|
|
||||||
{
|
|
||||||
public void Beszur(T ertek);
|
|
||||||
public bool Eleme(T ertek);
|
|
||||||
public void Torol(T ertek);
|
|
||||||
public void Bejar(Action<T> muvelet);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Verem<T>
|
|
||||||
{
|
|
||||||
bool Ures { get; }
|
|
||||||
void Verembe(T ertek);
|
|
||||||
T Verembol();
|
|
||||||
T Felso();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Sor<T>
|
|
||||||
{
|
|
||||||
bool Ures { get; }
|
|
||||||
void Sorba(T ertek);
|
|
||||||
T Sorbol();
|
|
||||||
T Elso();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface PrioritasosSor<T>
|
|
||||||
{
|
|
||||||
bool Ures { get; }
|
|
||||||
void Sorba(T ertek);
|
|
||||||
T Sorbol();
|
|
||||||
T Elso();
|
|
||||||
void Frissit(T elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface GrafEl<V>
|
|
||||||
{
|
|
||||||
V Honnan { get; }
|
|
||||||
V Hova { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Graf<V, E>
|
|
||||||
{
|
|
||||||
int CsucsokSzama { get; }
|
|
||||||
int ElekSzama { get; }
|
|
||||||
Halmaz<V> Csucsok { get; }
|
|
||||||
Halmaz<E> Elek { get; }
|
|
||||||
bool VezetEl(V honnan, V hova);
|
|
||||||
Halmaz<V> Szomszedai(V csucs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SulyozatlanGraf<V, E> : Graf<V, E>
|
|
||||||
{
|
|
||||||
void UjEl(V honnan, V hova);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SulyozottGrafEl<V> : GrafEl<V>
|
|
||||||
{
|
|
||||||
float Suly { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SulyozottGraf<V, E> : Graf<V, E>
|
|
||||||
{
|
|
||||||
void UjEl(V honnan, V hova, float suly);
|
|
||||||
float Suly(V honnan, V hova);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Szotar<K, T>
|
|
||||||
{
|
|
||||||
public void Beir(K kulcs, T ertek);
|
|
||||||
public T Kiolvas(K kulcs);
|
|
||||||
public void Torol(K kulcs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HibasKulcsKivetel : Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HibasIndexKivetel : Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NincsElemKivetel : Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NincsHelyKivetel : Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NincsElKivetel : Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NemOsszehasonlithatoKivetel : Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<RootNamespace>OE.ALGA</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
// 3. heti labor feladat - Tesztek: 03_TombImplementacioTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
// 4. heti labor feladat - Tesztek: 04_LancoltImplementacioTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
// 5. heti labor feladat - Tesztek: 05_BinarisKeresoFaTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
// 6. heti labor feladat - Tesztek: 06_SzotarTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
// 10. heti labor feladat - Tesztek: 10_SulyozatlanGrafTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
// 11. heti labor feladat - Tesztek: 11_KupacTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Adatszerkezetek
|
|
||||||
{
|
|
||||||
// 12. heti labor feladat - Tesztek: 12_SulyozottGrafTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace OE.ALGA;
|
|
||||||
|
|
||||||
public class Student
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string NeptunCode { get; set; }
|
|
||||||
|
|
||||||
public Student(string name, string neptun)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
NeptunCode = neptun;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void NotifyExamRegistration(Exam exam)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public void NotyfyExamDeregistration(Exam exam)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public delegate void Registration(Student student, Exam exam);
|
|
||||||
public class Exam
|
|
||||||
{
|
|
||||||
public string Subject { get; set; }
|
|
||||||
DateTime Date { get; set; }
|
|
||||||
int MaxSeats { get; set; }
|
|
||||||
List<Student> Students { get; set; }
|
|
||||||
Func<Student, bool> Condition { get; set; }
|
|
||||||
|
|
||||||
public Exam(string subject, DateTime date, int maxseats, List<Student> students, Func<Student, bool> condition)
|
|
||||||
{
|
|
||||||
Subject = subject;
|
|
||||||
MaxSeats = maxseats;
|
|
||||||
Students = students;
|
|
||||||
Condition = condition;
|
|
||||||
Date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public event Registration OnStudentRegistration;
|
|
||||||
public event Registration OnStudentDeregistration;
|
|
||||||
|
|
||||||
public void RegisterStudent(Student student)
|
|
||||||
{
|
|
||||||
if (Students.Count < MaxSeats && Condition(student))
|
|
||||||
{
|
|
||||||
Students.Add(student);
|
|
||||||
student.NotifyExamRegistration(this);
|
|
||||||
OnStudentRegistration?.Invoke(student, this); //lol de ennek így a faszom értelme van? Rimcsii
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void DeregisterStudent(Student student)
|
|
||||||
{
|
|
||||||
Students.Remove(student);
|
|
||||||
student.NotyfyExamDeregistration(this);
|
|
||||||
OnStudentDeregistration?.Invoke(student, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class ExamNotifier
|
|
||||||
{
|
|
||||||
List<string> logs;
|
|
||||||
|
|
||||||
public ExamNotifier(string date)
|
|
||||||
{
|
|
||||||
logs = new List<string>();
|
|
||||||
logs.Add(date);
|
|
||||||
}
|
|
||||||
public void LogRegistration(Student student, Exam exam)
|
|
||||||
{
|
|
||||||
string message = "{student.Name} ({student.NeptunCode}) successfully regsitered to {exam.Subject} exam";
|
|
||||||
Console.WriteLine(message);
|
|
||||||
logs.Add(message); }
|
|
||||||
public void LogDeregistration(Student student, Exam exam)
|
|
||||||
{
|
|
||||||
string message = "{student.Name} ({student.NeptunCode}) successfully deregsitered to {exam.Subject} exam";
|
|
||||||
Console.WriteLine(message);
|
|
||||||
logs.Add(message);
|
|
||||||
}
|
|
||||||
public void DisplayLogsToFile(string filename)
|
|
||||||
{
|
|
||||||
File.WriteAllLines(filename, logs);
|
|
||||||
foreach (var log in logs)
|
|
||||||
{
|
|
||||||
Console.WriteLine(log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics.Tracing;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace OE.ALGA;
|
|
||||||
|
|
||||||
public delegate void Service(string name, string path);
|
|
||||||
public class ToDoService
|
|
||||||
{
|
|
||||||
string rootdirectory;
|
|
||||||
|
|
||||||
string[] days = { "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sun" };
|
|
||||||
public ToDoService(string rootdirectory)
|
|
||||||
{
|
|
||||||
this.rootdirectory = rootdirectory;
|
|
||||||
Directory.CreateDirectory(this.rootdirectory);
|
|
||||||
foreach (string day in days)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Path.Combine(rootdirectory, day));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public event Service? OnTodoAdded;
|
|
||||||
public void NewTask(string name, string description, int day)
|
|
||||||
{
|
|
||||||
string path = Path.Combine(rootdirectory, days[day], (name += ".txt"));
|
|
||||||
StreamWriter sw = new StreamWriter(path, true);
|
|
||||||
sw.WriteLine(name);
|
|
||||||
sw.WriteLine(description);
|
|
||||||
sw.WriteLine(DateTime.Now);
|
|
||||||
OnTodoAdded?.Invoke(name, path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class User
|
|
||||||
{
|
|
||||||
List<string> evets;
|
|
||||||
int key;
|
|
||||||
ToDoService todos;
|
|
||||||
public User(int key)
|
|
||||||
{
|
|
||||||
evets = new List<string>();
|
|
||||||
todos = new ToDoService(Convert.ToString(DateTime.Now.Year));
|
|
||||||
Console.WriteLine("Press:\n1 for new todo\n2 for summary");
|
|
||||||
this.key = key;
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
string? name = Console.ReadLine();
|
|
||||||
string? description = Console.ReadLine();
|
|
||||||
int day = Convert.ToInt16(Console.ReadLine());
|
|
||||||
todos.NewTask(name, description, day);
|
|
||||||
evets.Add(name);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
this.CreateSummary();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void CreateSummary()
|
|
||||||
{
|
|
||||||
File.WriteAllLines("TodoSummary.txt", evets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OE.ALGA;
|
|
||||||
|
|
||||||
public class Cars
|
|
||||||
{
|
|
||||||
List<Car> cars = new List<Car>
|
|
||||||
{
|
|
||||||
new Car(2020, "BMW", "Sedan", 190, 30000m, "Germany"),
|
|
||||||
new Car(2022, "Toyota", "SUV", 210, 35000m, "Japan"),
|
|
||||||
new Car(2019, "Ford", "Truck", 250, 28000m, "USA"),
|
|
||||||
new Car(2021, "Mercedes", "Coupe", 320, 55000m, "Germany"),
|
|
||||||
new Car(2018, "Honda", "Hatchback", 150, 18000m, "Japan"),
|
|
||||||
new Car(2023, "Tesla", "Sedan", 450, 60000m, "USA"),
|
|
||||||
};
|
|
||||||
|
|
||||||
public Cars()
|
|
||||||
{
|
|
||||||
Car.OnCarsLoaded += ByBrand;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<string, int> bybrand = new Dictionary<string, int>();
|
|
||||||
public void ByBrand(string brand)
|
|
||||||
{
|
|
||||||
if (!bybrand.ContainsKey(brand))
|
|
||||||
{
|
|
||||||
bybrand.Add(brand, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bybrand[brand]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void Ize()
|
|
||||||
{
|
|
||||||
cars.OrderByDescending(x => x.Price);
|
|
||||||
cars.Min(x => x.Price);
|
|
||||||
cars.Max(X => X.Price);
|
|
||||||
var asd = from car in cars
|
|
||||||
select new
|
|
||||||
{
|
|
||||||
Brand = car.Brand,
|
|
||||||
Model = car.Type,
|
|
||||||
Year = car.Year
|
|
||||||
};
|
|
||||||
|
|
||||||
var brandCounts = cars
|
|
||||||
.GroupBy(c => c.Brand)
|
|
||||||
.Select(g => new { Brand = g.Key, Count = g.Count() })
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public delegate void EventHandler(string brand);
|
|
||||||
public class Car
|
|
||||||
{
|
|
||||||
public int Year { get; set; }
|
|
||||||
public string Brand { get; set; }
|
|
||||||
public string Type { get; set; }
|
|
||||||
public int HorsePower { get; set; }
|
|
||||||
public decimal Price { get; set; }
|
|
||||||
public string Origin { get; set; }
|
|
||||||
public static event EventHandler? OnCarsLoaded;
|
|
||||||
|
|
||||||
public Car(int year, string brand, string type, int horsepower, decimal price, string origin)
|
|
||||||
{
|
|
||||||
Year = year;
|
|
||||||
Brand = brand;
|
|
||||||
Type = type;
|
|
||||||
HorsePower = horsepower;
|
|
||||||
Price = price;
|
|
||||||
Origin = origin;
|
|
||||||
OnCarsLoaded?.Invoke(brand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public delegate decimal Asdd(Car car);
|
|
||||||
public class CarFinancial
|
|
||||||
{
|
|
||||||
public int Year { get; set; }
|
|
||||||
int asd;
|
|
||||||
|
|
||||||
public CarFinancial(int year)
|
|
||||||
{
|
|
||||||
this.Year = year;
|
|
||||||
Asdd Operator = new Asdd(Fuck);
|
|
||||||
}
|
|
||||||
public decimal Analyze(Func<Car, decimal> operation, Car[] cars)
|
|
||||||
{
|
|
||||||
decimal ertek = 0;
|
|
||||||
foreach (Car car in cars)
|
|
||||||
{
|
|
||||||
ertek += operation(car);
|
|
||||||
}
|
|
||||||
return ertek;
|
|
||||||
}
|
|
||||||
|
|
||||||
public decimal Fuck(Car car)
|
|
||||||
{
|
|
||||||
if (car.Year == this.Year)
|
|
||||||
{
|
|
||||||
return car.Price;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Optimalizalas
|
|
||||||
{
|
|
||||||
// 7. heti labor feladat - Tesztek: 07_NyersEroTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
namespace OE.ALGA.Optimalizalas
|
|
||||||
{
|
|
||||||
// 8. heti labor feladat - Tesztek: 08_DinamikusProgramozasTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Optimalizalas
|
|
||||||
{
|
|
||||||
// 9. heti labor feladat - Tesztek: 09VisszalepesesKeresesTesztek.cs
|
|
||||||
}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Paradigmak
|
|
||||||
{
|
|
||||||
public interface IVegrehajthato
|
|
||||||
{
|
|
||||||
void Vegrehajtas();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IFuggo
|
|
||||||
{
|
|
||||||
public bool FuggosegTeljesul
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TaroloMegteltKivetel : Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FeladatTarolo<T> : IEnumerable<T> where T : IVegrehajthato
|
|
||||||
{
|
|
||||||
internal T[] tarolo;
|
|
||||||
internal int n;
|
|
||||||
|
|
||||||
public FeladatTarolo(int l)
|
|
||||||
{
|
|
||||||
tarolo = new T[l];
|
|
||||||
n = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Felvesz(T t)
|
|
||||||
{
|
|
||||||
if (tarolo.Length == 0)
|
|
||||||
{
|
|
||||||
throw new TaroloMegteltKivetel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (n < tarolo.Length)
|
|
||||||
{
|
|
||||||
tarolo[n] = t;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new TaroloMegteltKivetel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
foreach (T t in tarolo)
|
|
||||||
{
|
|
||||||
if (t != null)
|
|
||||||
{
|
|
||||||
yield return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual public void MindentVegrehajt()
|
|
||||||
{
|
|
||||||
foreach (T t in tarolo)
|
|
||||||
{
|
|
||||||
if (t != null)
|
|
||||||
{
|
|
||||||
t.Vegrehajtas();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator<T> IEnumerable<T>.GetEnumerator()
|
|
||||||
{
|
|
||||||
FeladatTaroloBejaro<T> bejaro = new FeladatTaroloBejaro<T>(tarolo, n);
|
|
||||||
return bejaro;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FuggoFeladatTarolo<T> : FeladatTarolo<T>, IEnumerable<T> where T : IVegrehajthato, IFuggo
|
|
||||||
{
|
|
||||||
public FuggoFeladatTarolo(int l) : base(l)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
override public void MindentVegrehajt()
|
|
||||||
{
|
|
||||||
foreach (T t in tarolo)
|
|
||||||
{
|
|
||||||
if (t != null)
|
|
||||||
{
|
|
||||||
if (t.FuggosegTeljesul)
|
|
||||||
{
|
|
||||||
t.Vegrehajtas();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class FeladatTaroloBejaro<T> : IEnumerator<T>
|
|
||||||
{
|
|
||||||
T[] tarolo;
|
|
||||||
int n;
|
|
||||||
int aktualisindex;
|
|
||||||
|
|
||||||
public FeladatTaroloBejaro(T[] tarolo, int n)
|
|
||||||
{
|
|
||||||
this.tarolo = tarolo;
|
|
||||||
this.n = n;
|
|
||||||
aktualisindex = 0;
|
|
||||||
}
|
|
||||||
public T Current
|
|
||||||
{
|
|
||||||
get { return tarolo[aktualisindex]; }
|
|
||||||
}
|
|
||||||
|
|
||||||
object IEnumerator.Current => throw new NotImplementedException();
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
if (aktualisindex < n-1)
|
|
||||||
{
|
|
||||||
aktualisindex++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
aktualisindex = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Paradigmak
|
|
||||||
{
|
|
||||||
public class FeltetelesFeladatTarolo<T> : FeladatTarolo<T>, IEnumerable<T> where T : IVegrehajthato
|
|
||||||
{
|
|
||||||
public Func<T, bool> BejaroFeltetel
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
public bool Igaz(T t)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public FeltetelesFeladatTarolo(int l) : base(l)
|
|
||||||
{
|
|
||||||
BejaroFeltetel = Igaz;
|
|
||||||
}
|
|
||||||
public void FeltetelesVegrehajtas(Func<T, bool> feltetel)
|
|
||||||
{
|
|
||||||
foreach (T t in tarolo)
|
|
||||||
{
|
|
||||||
if (t != null && feltetel(t))
|
|
||||||
{
|
|
||||||
t.Vegrehajtas();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new public IEnumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTaroloBejaro<T> bejaro = new FeltetelesFeladatTaroloBejaro<T>(tarolo, n, BejaroFeltetel);
|
|
||||||
return bejaro.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public class FeltetelesFeladatTaroloBejaro<T> : IEnumerator<T> where T : IVegrehajthato
|
|
||||||
{
|
|
||||||
T[] tarolo;
|
|
||||||
int n;
|
|
||||||
int aktualisindex;
|
|
||||||
public Func<T, bool> Feltetel
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
}
|
|
||||||
public T Current
|
|
||||||
{
|
|
||||||
get { return tarolo[aktualisindex]; }
|
|
||||||
}
|
|
||||||
public FeltetelesFeladatTaroloBejaro(T[] tarolo, int n, Func<T, bool> feltetel)
|
|
||||||
{
|
|
||||||
this.tarolo = tarolo;
|
|
||||||
this.n = n;
|
|
||||||
aktualisindex = 0;
|
|
||||||
Feltetel = feltetel;
|
|
||||||
}
|
|
||||||
object IEnumerator.Current => throw new NotImplementedException();
|
|
||||||
|
|
||||||
public IEnumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
foreach (T t in tarolo)
|
|
||||||
{
|
|
||||||
if (t != null && Feltetel(t))
|
|
||||||
{
|
|
||||||
yield return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
if (aktualisindex < n - 1)
|
|
||||||
{
|
|
||||||
aktualisindex++;
|
|
||||||
if (Feltetel(tarolo[aktualisindex]))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return MoveNext();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
aktualisindex = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# Tudnivalók a projekttel kapcsolatban
|
|
||||||
- A félév során elkészítendő feladatokhoz tartozó fájlok a megadott mappában létre vannak hozva.
|
|
||||||
- A megoldást minden esetben a fájlon belül lévő névtérbe kell elkészíteni.
|
|
||||||
- A fejlesztés során az adott feladathoz tartozó teszt fájl (például: *Tesztek/01_ImperativParadigmaTesztek.cs*) tartalma legyen futtatható (*Ctrl+A*, majd *Ctrl+K+U*).
|
|
||||||
- Későbbi hetek feladatai felhasználhatják egy korábbi hét feladatának megoldását, így érdemes a korábbi teszteket is folyamatosan figyelemmel kísérni, mivel azoknak továbbra is hibátlanul le kell futniuk.
|
|
||||||
- A teszteknél hiányzó *IVegrehajthato* és *IFuggo* interfészek elkészítése az első hét feladata.
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.8.34330.188
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ALGAme", "ALGAme\ALGAme.csproj", "{E879C59F-BD64-4DE0-A54F-C632395E62B2}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729} = {F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Engine", "Engine\Engine.csproj", "{15A07E98-65CB-4894-B600-8CAF16AEBA75}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ALGA", "ALGA\ALGA.csproj", "{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sandbox", "Sandbox\Sandbox.csproj", "{2517350C-751A-4876-AEDE-D6AE9D6815C7}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tesztek", "Tesztek\Tesztek.csproj", "{AFE58A8F-D9BA-4EBF-810D-F7E07E5A296C}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{E879C59F-BD64-4DE0-A54F-C632395E62B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{15A07E98-65CB-4894-B600-8CAF16AEBA75}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F1EF1714-78CB-4FDC-9CE2-B9A7D9F94729}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2517350C-751A-4876-AEDE-D6AE9D6815C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{AFE58A8F-D9BA-4EBF-810D-F7E07E5A296C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{AFE58A8F-D9BA-4EBF-810D-F7E07E5A296C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{AFE58A8F-D9BA-4EBF-810D-F7E07E5A296C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{AFE58A8F-D9BA-4EBF-810D-F7E07E5A296C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {AD85FE57-DF45-4952-926D-B1F4A0316100}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<RootNamespace>OE.ALGA.ALGAme</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\ALGA\ALGA.csproj" />
|
|
||||||
<ProjectReference Include="..\Engine\Engine.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using OE.ALGA.Engine;
|
|
||||||
|
|
||||||
namespace OE.ALGA.ALGAme
|
|
||||||
{
|
|
||||||
public class Jatek
|
|
||||||
{
|
|
||||||
readonly Terkep terkep;
|
|
||||||
public Terkep Terkep { get { return terkep; } }
|
|
||||||
|
|
||||||
readonly Backend backend;
|
|
||||||
public Backend Backend { get { return backend; } }
|
|
||||||
|
|
||||||
public Jatek()
|
|
||||||
{
|
|
||||||
backend = new Backend();
|
|
||||||
terkep = new Terkep(Param.TERKEP_SZELESSEG, Param.TERKEP_MAGASSAG);
|
|
||||||
|
|
||||||
PalyaGeneralas();
|
|
||||||
NezopontokLetrehozasa();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
backend.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
backend.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PalyaGeneralas()
|
|
||||||
{
|
|
||||||
terkep.LabirintusGeneralas();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void NezopontokLetrehozasa()
|
|
||||||
{
|
|
||||||
backend.Megjelenites.NezopontFelvetele(terkep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
using OE.ALGA.ALGAme;
|
|
||||||
|
|
||||||
Jatek jatek = new Jatek();
|
|
||||||
jatek.Start();
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public class KetElemuVektor : IComparable
|
|
||||||
{
|
|
||||||
readonly int x;
|
|
||||||
readonly int y;
|
|
||||||
|
|
||||||
public int X { get { return x; } }
|
|
||||||
public int Y { get { return y; } }
|
|
||||||
|
|
||||||
public KetElemuVektor(int x, int y)
|
|
||||||
{
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
|
||||||
{
|
|
||||||
if (obj != null && obj is KetElemuVektor b)
|
|
||||||
{
|
|
||||||
return X == b.X && Y == b.Y;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return X.GetHashCode() ^ Y.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int CompareTo(object? obj)
|
|
||||||
{
|
|
||||||
if (obj != null && obj is KetElemuVektor b)
|
|
||||||
{
|
|
||||||
if (x != b.x)
|
|
||||||
return x.CompareTo(b.x);
|
|
||||||
else
|
|
||||||
return y.CompareTo(b.y);
|
|
||||||
}
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(KetElemuVektor a, KetElemuVektor b) => a.Equals(b);
|
|
||||||
public static bool operator !=(KetElemuVektor a, KetElemuVektor b) => !a.Equals(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Pozicio : KetElemuVektor
|
|
||||||
{
|
|
||||||
public Pozicio(int x, int y) : base(x, y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Pozicio operator +(Pozicio p, Irany m) => new Pozicio(p.X + m.X, p.Y + m.Y);
|
|
||||||
public static double Tavolsag(Pozicio a, Pozicio b) => Math.Sqrt(Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Irany : KetElemuVektor
|
|
||||||
{
|
|
||||||
public static readonly Irany[] FoIranyok = new Irany[4] { new Irany(0, -1), new Irany(-1, 0), new Irany(0, 1), new Irany(1, 0) };
|
|
||||||
|
|
||||||
public static int Balra(int iranyIndex)
|
|
||||||
{
|
|
||||||
return (iranyIndex - 1 + 4) % 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int Jobbra(int iranyIndex)
|
|
||||||
{
|
|
||||||
return (iranyIndex + 1) % 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Irany(int x, int y) : base(x, y)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Irany operator *(Irany i, int s) => new Irany(i.X * s, i.Y * s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Meret
|
|
||||||
{
|
|
||||||
public int Szelesseg { get; set; }
|
|
||||||
public int Magassag { get; set; }
|
|
||||||
|
|
||||||
public Meret(int szelesseg, int magassag)
|
|
||||||
{
|
|
||||||
this.Szelesseg = szelesseg;
|
|
||||||
this.Magassag = magassag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public class Backend
|
|
||||||
{
|
|
||||||
public Kepernyo Megjelenites { get; } = new Kepernyo();
|
|
||||||
public BillentyuzetKezelo Bemenet { get; } = new BillentyuzetKezelo();
|
|
||||||
public OrajelGenerator Orajel { get; } = new OrajelGenerator();
|
|
||||||
|
|
||||||
public Backend()
|
|
||||||
{
|
|
||||||
Orajel.OrajelFogadoFelvetele(Bemenet);
|
|
||||||
Orajel.OrajelFogadoFelvetele(Megjelenites);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool kilepes = false;
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
Orajel.Start();
|
|
||||||
while (!kilepes)
|
|
||||||
{
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
Orajel.Stop();
|
|
||||||
kilepes = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public interface IBillentyuLenyomasKezelo
|
|
||||||
{
|
|
||||||
void BillentyuLenyomas(ConsoleKey billentyu);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BillentyuzetKezelo : IOrajelFogado
|
|
||||||
{
|
|
||||||
private readonly List<IBillentyuLenyomasKezelo> billentyuLenyomasKezelok = new List<IBillentyuLenyomasKezelo>();
|
|
||||||
|
|
||||||
public void BillentyuLenyomasKezeloFelvetele(IBillentyuLenyomasKezelo kezelo)
|
|
||||||
{
|
|
||||||
billentyuLenyomasKezelok.Add(kezelo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BillentyuLenyomasKezeloEltavolitasa(IBillentyuLenyomasKezelo kezelo)
|
|
||||||
{
|
|
||||||
billentyuLenyomasKezelok.Remove(kezelo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly Dictionary<ConsoleKey, Action> billentyuAkciok = new Dictionary<ConsoleKey, Action>();
|
|
||||||
|
|
||||||
public void BillentyuAkcioFelvetele(ConsoleKey billentyu, Action akcio)
|
|
||||||
{
|
|
||||||
billentyuAkciok.Add(billentyu, akcio);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Orajel(int ido)
|
|
||||||
{
|
|
||||||
while (Console.KeyAvailable)
|
|
||||||
{
|
|
||||||
ConsoleKey billentyu = Console.ReadKey(true).Key;
|
|
||||||
foreach (IBillentyuLenyomasKezelo kezelo in billentyuLenyomasKezelok)
|
|
||||||
{
|
|
||||||
kezelo.BillentyuLenyomas(billentyu);
|
|
||||||
}
|
|
||||||
if (billentyuAkciok.TryGetValue(billentyu, out Action? value))
|
|
||||||
value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<RootNamespace>OE.ALGA.Engine</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
// This file is used by Code Analysis to maintain SuppressMessage
|
|
||||||
// attributes that are applied to this project.
|
|
||||||
// Project-level suppressions either have no target or are given
|
|
||||||
// a specific target and scoped to a namespace, type, member, etc.
|
|
||||||
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
|
|
||||||
[assembly: SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "<Pending>", Scope = "module")]
|
|
||||||
[assembly: SuppressMessage("Style", "IDE0300:Simplify collection initialization", Justification = "<Pending>", Scope = "module")]
|
|
||||||
[assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "<Pending>", Scope = "module")]
|
|
||||||
[assembly: SuppressMessage("Style", "IDE0028:Simplify collection initialization", Justification = "<Pending>", Scope = "module")]
|
|
||||||
[assembly: SuppressMessage("Style", "IDE0305:Simplify collection initialization", Justification = "<Pending>", Scope = "module")]
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public class UtkozesKivetel : Exception
|
|
||||||
{
|
|
||||||
public TerkepElem Forras { get; set; }
|
|
||||||
public TerkepElem Utkozes { get; set; }
|
|
||||||
|
|
||||||
public UtkozesKivetel(TerkepElem forras, TerkepElem utkozes)
|
|
||||||
{
|
|
||||||
this.Forras = forras;
|
|
||||||
this.Utkozes = utkozes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NemLehetIdeLepniKivetel : UtkozesKivetel
|
|
||||||
{
|
|
||||||
public NemLehetIdeLepniKivetel(TerkepElem forras, TerkepElem utkozes) : base(forras, utkozes)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public interface IMegjelenitheto
|
|
||||||
{
|
|
||||||
public Pozicio Pozicio { get; }
|
|
||||||
public Jel Jel { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FixJel : IMegjelenitheto
|
|
||||||
{
|
|
||||||
public Pozicio Pozicio { get; private set; }
|
|
||||||
|
|
||||||
public Jel Jel { get; private set; }
|
|
||||||
|
|
||||||
public FixJel(Pozicio pozicio, Jel jel)
|
|
||||||
{
|
|
||||||
this.Pozicio = pozicio;
|
|
||||||
this.Jel = jel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FixJel(IMegjelenitheto eredeti)
|
|
||||||
{
|
|
||||||
this.Pozicio = eredeti.Pozicio;
|
|
||||||
this.Jel = eredeti.Jel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FixJel[] SzovegbolJelsor(string szoveg, Pozicio hely, ConsoleColor szin)
|
|
||||||
{
|
|
||||||
FixJel[] jelsor = new FixJel[szoveg.Length];
|
|
||||||
for (int i = 0; i < szoveg.Length; i++)
|
|
||||||
jelsor[i] = new FixJel(new Pozicio(hely.X + i, hely.Y), new Jel(szoveg[i], szin));
|
|
||||||
return jelsor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Jel
|
|
||||||
{
|
|
||||||
readonly char karakter;
|
|
||||||
readonly ConsoleColor szin;
|
|
||||||
|
|
||||||
public char Karakter { get { return karakter; } }
|
|
||||||
public ConsoleColor Szin { get { return szin; } }
|
|
||||||
|
|
||||||
public Jel(char karakter, ConsoleColor szin)
|
|
||||||
{
|
|
||||||
this.karakter = karakter;
|
|
||||||
this.szin = szin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
|
||||||
{
|
|
||||||
if (obj != null && obj is Jel b)
|
|
||||||
{
|
|
||||||
return this.Karakter == b.Karakter && this.Szin == b.Szin;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return karakter.GetHashCode() ^ szin.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Jel a, Jel b) => a is not null && a.Equals(b);
|
|
||||||
public static bool operator !=(Jel a, Jel b) => a is null || !a.Equals(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface INezopont
|
|
||||||
{
|
|
||||||
string Fejlec { get; }
|
|
||||||
Meret Meret { get; }
|
|
||||||
IMegjelenitheto[] MegjelenitendoElemek();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Kepernyo : IOrajelFogado
|
|
||||||
{
|
|
||||||
readonly Meret meret;
|
|
||||||
readonly Jel[,] puffer;
|
|
||||||
readonly Jel[,] utolso;
|
|
||||||
|
|
||||||
public Kepernyo(int szelesseg, int magassag)
|
|
||||||
{
|
|
||||||
meret = new Meret(szelesseg, magassag);
|
|
||||||
|
|
||||||
Console.CursorVisible = false;
|
|
||||||
Console.OutputEncoding = Encoding.Unicode;
|
|
||||||
|
|
||||||
puffer = new Jel[szelesseg, magassag];
|
|
||||||
utolso = new Jel[szelesseg, magassag];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Kepernyo() : this(Console.WindowWidth, Console.WindowHeight)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly List<Func<string>> HUDmegjelenitok = new List<Func<string>>();
|
|
||||||
|
|
||||||
public void HUDAdatFelvetele(Func<string> hudMegjelenito)
|
|
||||||
{
|
|
||||||
HUDmegjelenitok.Add(hudMegjelenito);
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly List<INezopont> nezopontok = new List<INezopont>();
|
|
||||||
|
|
||||||
public void NezopontFelvetele(INezopont nezopont)
|
|
||||||
{
|
|
||||||
nezopontok.Add(nezopont);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void NezopontEltavolitasa(INezopont nezopont)
|
|
||||||
{
|
|
||||||
nezopontok.Remove(nezopont);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Kirajzolas()
|
|
||||||
{
|
|
||||||
PufferTorles();
|
|
||||||
|
|
||||||
int eltolasX = 0;
|
|
||||||
foreach (INezopont nezopont in nezopontok)
|
|
||||||
{
|
|
||||||
KeretRajzolas(eltolasX, 0, nezopont.Meret, nezopont.Fejlec);
|
|
||||||
ElemekRajzolasa(eltolasX, 0, nezopont);
|
|
||||||
eltolasX += nezopont.Meret.Szelesseg + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
eltolasX = 0;
|
|
||||||
foreach (Func<string> hudMegjelenito in HUDmegjelenitok)
|
|
||||||
{
|
|
||||||
string adat = hudMegjelenito();
|
|
||||||
for (int i = 0; i < adat.Length; i++)
|
|
||||||
puffer[eltolasX + i, meret.Magassag - 1] = new Jel(adat[i], ConsoleColor.White);
|
|
||||||
puffer[eltolasX + adat.Length, meret.Magassag - 1] = new Jel('|', ConsoleColor.Red);
|
|
||||||
eltolasX += adat.Length + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
PufferKirajzolas();
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly Jel ures = new Jel(' ', ConsoleColor.Black);
|
|
||||||
|
|
||||||
private void PufferTorles()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < meret.Szelesseg; i++)
|
|
||||||
for (int j = 0; j < meret.Magassag; j++)
|
|
||||||
{
|
|
||||||
puffer[i, j] = ures;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void KeretRajzolas(int eltolasX, int eltolasY, Meret meret, string fejlec)
|
|
||||||
{
|
|
||||||
for (int i = 1; i <= meret.Szelesseg; i++)
|
|
||||||
{
|
|
||||||
puffer[eltolasX + i, eltolasY] = new Jel('\u2550', ConsoleColor.Gray);
|
|
||||||
puffer[eltolasX + i, eltolasY + meret.Magassag + 1] = new Jel('\u2550', ConsoleColor.Gray);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 1; i <= meret.Magassag; i++)
|
|
||||||
{
|
|
||||||
puffer[eltolasX, eltolasY + i] = new Jel('\u2551', ConsoleColor.Gray);
|
|
||||||
puffer[eltolasX + meret.Szelesseg + 1, eltolasY + i] = new Jel('\u2551', ConsoleColor.Gray);
|
|
||||||
}
|
|
||||||
|
|
||||||
puffer[eltolasX, eltolasY] = new Jel('\u2554', ConsoleColor.Gray);
|
|
||||||
puffer[eltolasX + meret.Szelesseg + 1, eltolasY] = new Jel('\u2557', ConsoleColor.Gray);
|
|
||||||
puffer[eltolasX, eltolasY + meret.Magassag + 1] = new Jel('\u255a', ConsoleColor.Gray);
|
|
||||||
puffer[eltolasX + meret.Szelesseg + 1, eltolasY + meret.Magassag + 1] = new Jel('\u255d', ConsoleColor.Gray);
|
|
||||||
|
|
||||||
for (int i = 0; i < fejlec.Length; i++)
|
|
||||||
puffer[eltolasX + 2 + i, eltolasY] = new Jel(fejlec[i], ConsoleColor.Gray);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ElemekRajzolasa(int eltolasX, int eltolasY, INezopont nezopont)
|
|
||||||
{
|
|
||||||
foreach (IMegjelenitheto elem in nezopont.MegjelenitendoElemek())
|
|
||||||
{
|
|
||||||
puffer[eltolasX + 1 + elem.Pozicio.X, eltolasY + 1 + elem.Pozicio.Y] = elem.Jel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PufferKirajzolas()
|
|
||||||
{
|
|
||||||
for (int j = 0; j < meret.Magassag; j++)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < meret.Szelesseg; i++)
|
|
||||||
{
|
|
||||||
if (utolso[i, j] != puffer[i, j])
|
|
||||||
{
|
|
||||||
Console.SetCursorPosition(i, j);
|
|
||||||
Console.ForegroundColor = puffer[i, j].Szin;
|
|
||||||
Console.Write(puffer[i, j].Karakter);
|
|
||||||
utolso[i, j] = puffer[i, j];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Orajel(int ido)
|
|
||||||
{
|
|
||||||
Kirajzolas();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public interface IOrajelFogado
|
|
||||||
{
|
|
||||||
void Orajel(int ido);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class OrajelGenerator
|
|
||||||
{
|
|
||||||
Timer? timer;
|
|
||||||
|
|
||||||
public int Ido { get; private set; } = 0;
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
timer = new Timer(FoCiklus, null, 0, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
timer?.Change(Timeout.Infinite, Timeout.Infinite);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool foglalt = false;
|
|
||||||
private void FoCiklus(object? state)
|
|
||||||
{
|
|
||||||
if (!foglalt) // ha nem végzett az előző ciklus, akkor kihagyja a következőt
|
|
||||||
{
|
|
||||||
foglalt = true;
|
|
||||||
Ido++;
|
|
||||||
|
|
||||||
List<IOrajelFogado> aktivOrajelFogadok = new List<IOrajelFogado>(orajelFogadok); // azért kell a másolat, mert valamelyik órajel kezelés módosíthatja az orajelFogadok listát
|
|
||||||
foreach (IOrajelFogado fogado in aktivOrajelFogadok)
|
|
||||||
{
|
|
||||||
fogado.Orajel(Ido);
|
|
||||||
}
|
|
||||||
|
|
||||||
foglalt = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly List<IOrajelFogado> orajelFogadok = new List<IOrajelFogado>();
|
|
||||||
|
|
||||||
public void OrajelFogadoFelvetele(IOrajelFogado fogado)
|
|
||||||
{
|
|
||||||
orajelFogadok.Add(fogado);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OrajelFogadoEltavolitasa(IOrajelFogado fogado)
|
|
||||||
{
|
|
||||||
orajelFogadok.Remove(fogado);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public static class Param
|
|
||||||
{
|
|
||||||
public const int TERKEP_SZELESSEG = 15;
|
|
||||||
public const int TERKEP_MAGASSAG = 19;
|
|
||||||
|
|
||||||
public const char NYIL_FEL = '\u02c4';
|
|
||||||
public const char NYIL_BAL = '\u02c2';
|
|
||||||
public const char NYIL_LE = '\u02c5';
|
|
||||||
public const char NYIL_JOBB = '\u02c3';
|
|
||||||
public const char HALOTT = '+';
|
|
||||||
|
|
||||||
public const char FAL = '\u2593';
|
|
||||||
public const char LOVEDEK_VIZSZINTES = '-';
|
|
||||||
public const char LOVEDEK_FUGGOLEGES = '-';
|
|
||||||
|
|
||||||
public const int JATEKVEGE_IDO = 500;
|
|
||||||
public const int HIRTELENHALAL_KEZDO_IDO = 100;
|
|
||||||
public const int HIRTELENHALAL_FOKOZAS_IDO = 10;
|
|
||||||
public const int HIRTELENHALAL_BUNTETES = 1;
|
|
||||||
|
|
||||||
public const int LOVEDEK_MAX_SEBZES = 10;
|
|
||||||
|
|
||||||
public const int JATEKOS_LATOTAVOLSAG = 2;
|
|
||||||
public const int JATEKOS_MEMORIAMERET = 30;
|
|
||||||
|
|
||||||
public const int KINCSEK_SZAMA = 5;
|
|
||||||
public const int KINCSEK_MAX_MERETE = 8;
|
|
||||||
public const int HATIZSAK_MAX_MERETE = 10;
|
|
||||||
|
|
||||||
public const double GEP_VISSZARAK_ESELY = 0.1;
|
|
||||||
|
|
||||||
// optimalizalas
|
|
||||||
public const double MIN_KINCS_TAVOLSAG = 4;
|
|
||||||
|
|
||||||
// kupac
|
|
||||||
public const int LOVEDEKEK_SZAMA = 10;
|
|
||||||
|
|
||||||
// szélességi bejárás
|
|
||||||
public const int TERKEP_BEJARAS_LEPESKORLAT = 30;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,277 +0,0 @@
|
|||||||
namespace OE.ALGA.Engine
|
|
||||||
{
|
|
||||||
public class Terkep : INezopont
|
|
||||||
{
|
|
||||||
readonly Random rnd = new Random();
|
|
||||||
|
|
||||||
public string Fejlec { get { return "Térkép"; } }
|
|
||||||
|
|
||||||
readonly Meret meret;
|
|
||||||
public Meret Meret { get { return meret; } }
|
|
||||||
|
|
||||||
readonly List<TerkepElem> elemek = new List<TerkepElem>();
|
|
||||||
|
|
||||||
public void Felvesz(TerkepElem elem)
|
|
||||||
{
|
|
||||||
elemek.Add(elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Eltavolit(TerkepElem elem)
|
|
||||||
{
|
|
||||||
elemek.Remove(elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Mozgat(TerkepElem elem, Irany irany)
|
|
||||||
{
|
|
||||||
Pozicio ujPoz = elem.Pozicio + irany;
|
|
||||||
|
|
||||||
bool odaLephet = true;
|
|
||||||
|
|
||||||
foreach (TerkepElem ottvan in AdottHelyen(ujPoz))
|
|
||||||
{
|
|
||||||
ottvan.Utkozes?.Invoke(elem);
|
|
||||||
elem.Utkozes?.Invoke(ottvan);
|
|
||||||
}
|
|
||||||
|
|
||||||
elem.Athelyez(ujPoz);
|
|
||||||
|
|
||||||
return odaLephet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TerkepElem> AdottHelyen(Pozicio pozicio)
|
|
||||||
{
|
|
||||||
return elemek.FindAll(x => x.Pozicio == pozicio);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TerkepElem[] Kornyezet(Pozicio pozicio, int tavolsag)
|
|
||||||
{
|
|
||||||
List<TerkepElem> elemek = new List<TerkepElem>();
|
|
||||||
for (int x = -tavolsag; x <= tavolsag; x++)
|
|
||||||
for (int y = -tavolsag; y <= tavolsag; y++)
|
|
||||||
elemek.AddRange(AdottHelyen(new Pozicio(pozicio.X + x, pozicio.Y + y)));
|
|
||||||
return elemek.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMegjelenitheto[] MegjelenitendoElemek()
|
|
||||||
{
|
|
||||||
return elemek.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Terkep(int szelesseg, int magassag)
|
|
||||||
{
|
|
||||||
this.meret = new Meret(szelesseg, magassag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LabirintusGeneralas()
|
|
||||||
{
|
|
||||||
List<Fal> falak = new List<Fal>();
|
|
||||||
List<Pozicio> bovitheto = new List<Pozicio>();
|
|
||||||
|
|
||||||
// korbe falak letrehozasa
|
|
||||||
for (int x = 0; x < meret.Szelesseg; x++)
|
|
||||||
{
|
|
||||||
falak.Add(new Fal(this, new Pozicio(x, 0)));
|
|
||||||
falak.Add(new Fal(this, new Pozicio(x, meret.Magassag - 1)));
|
|
||||||
}
|
|
||||||
for (int y = 0; y < meret.Magassag; y++)
|
|
||||||
{
|
|
||||||
falak.Add(new Fal(this, new Pozicio(0, y)));
|
|
||||||
falak.Add(new Fal(this, new Pozicio(meret.Szelesseg - 1, y)));
|
|
||||||
}
|
|
||||||
falak.Add(new Fal(this, new Pozicio(1, 2)));
|
|
||||||
|
|
||||||
// belso szerkezet letrehozasa
|
|
||||||
Pozicio kezdoPozicio = new Pozicio(2, 2);
|
|
||||||
falak.Add(new Fal(this, kezdoPozicio));
|
|
||||||
bovitheto.Add(kezdoPozicio);
|
|
||||||
|
|
||||||
int falProba;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
int falRnd = rnd.Next(bovitheto.Count); // melyik falnal probaljon eloszor tovabb boviteni
|
|
||||||
falProba = 0; // az elso fal valasztas random, de utana szisztematikusan tovabbnezi a mogotte levoket
|
|
||||||
bool ok = false;
|
|
||||||
while (falProba < bovitheto.Count && !ok) // ha nem nezte meg at az osszes falat es nem sikerult boviteni
|
|
||||||
{
|
|
||||||
Pozicio vizsgalt = bovitheto[(falRnd + falProba) % bovitheto.Count]; // ezt a falat vizsgaljuk
|
|
||||||
|
|
||||||
int iranyRnd = rnd.Next(4); // ebbe az iranyba probal eloszor boviteni
|
|
||||||
int iranyProba = 0; // az elso irany valasztas random, de utana szisztematikusan nezi a tobbi iranyt
|
|
||||||
while (iranyProba < 4 && !ok) // meg nem nezte azt az osszes iranyt es nem sikerult boviteni
|
|
||||||
{
|
|
||||||
Irany irany = Irany.FoIranyok[(iranyRnd + iranyProba) % 4];
|
|
||||||
Pozicio uj = vizsgalt + irany * 2;
|
|
||||||
if (TerkepenBelulVan(uj) && !falak.Exists(x => x.Pozicio == uj)) // ha itt nincs meg fal
|
|
||||||
{
|
|
||||||
falak.Add(new Fal(this, uj)); // uj 2. tavolsagra levo fal letrehozasa, ebbol indulhat bovites is
|
|
||||||
falak.Add(new Fal(this, vizsgalt + irany)); // uj koztes fal letrehozasa
|
|
||||||
bovitheto.Add(uj);
|
|
||||||
ok = true; // sikerult boviteni
|
|
||||||
}
|
|
||||||
iranyProba++; // uj iranyt probalunk
|
|
||||||
}
|
|
||||||
falProba++; // uj falat probalunk
|
|
||||||
}
|
|
||||||
} while (falProba < bovitheto.Count); // minden fal minden iranyt vegigneztunk es nincs bovites
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TerkepenBelulVan(Pozicio pozicio)
|
|
||||||
{
|
|
||||||
return pozicio.X > 0 && pozicio.X < meret.Szelesseg - 1 && pozicio.Y > 0 && pozicio.Y < meret.Magassag - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool NincsFal(Pozicio pozicio)
|
|
||||||
{
|
|
||||||
return !AdottHelyen(pozicio).Exists(x => x is Fal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract public class TerkepElem : IMegjelenitheto, IComparable
|
|
||||||
{
|
|
||||||
readonly private Terkep terkep;
|
|
||||||
public Terkep Terkep { get { return terkep; } }
|
|
||||||
|
|
||||||
protected Pozicio pozicio;
|
|
||||||
public Pozicio Pozicio { get { return pozicio; } }
|
|
||||||
|
|
||||||
abstract public Jel Jel { get; }
|
|
||||||
|
|
||||||
public Action<TerkepElem>? Utkozes { get; set; }
|
|
||||||
|
|
||||||
public virtual void Athelyez(Pozicio ujPozicio)
|
|
||||||
{
|
|
||||||
if (terkep.TerkepenBelulVan(ujPozicio))
|
|
||||||
pozicio = ujPozicio;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TerkepElem(Terkep terkep, Pozicio pozicio)
|
|
||||||
{
|
|
||||||
this.terkep = terkep;
|
|
||||||
terkep.Felvesz(this);
|
|
||||||
this.pozicio = pozicio;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Megszunik()
|
|
||||||
{
|
|
||||||
terkep.Eltavolit(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int idSzamlalo = 0;
|
|
||||||
readonly int id = idSzamlalo++;
|
|
||||||
|
|
||||||
public int CompareTo(object? obj)
|
|
||||||
{
|
|
||||||
if (obj is TerkepElem o)
|
|
||||||
return id.CompareTo(o.id);
|
|
||||||
else
|
|
||||||
throw new ArgumentException("Hibás összehasonlítás");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FixTerkepElem : TerkepElem
|
|
||||||
{
|
|
||||||
protected Jel jel;
|
|
||||||
|
|
||||||
public override Jel Jel
|
|
||||||
{
|
|
||||||
get { return jel; }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FixTerkepElem(Terkep terkep, Pozicio pozicio, Jel jel) : base(terkep, pozicio)
|
|
||||||
{
|
|
||||||
this.pozicio = pozicio;
|
|
||||||
this.jel = jel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Fal : FixTerkepElem
|
|
||||||
{
|
|
||||||
static readonly Jel FAL_KARAKTER = new Jel(Param.FAL, ConsoleColor.DarkRed);
|
|
||||||
|
|
||||||
public Fal(Terkep terkep, Pozicio pozicio) : base(terkep, pozicio, FAL_KARAKTER)
|
|
||||||
{
|
|
||||||
Utkozes = elem => throw new NemLehetIdeLepniKivetel(this, elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Kincs : TerkepElem
|
|
||||||
{
|
|
||||||
readonly ConsoleColor[] szinek = new ConsoleColor[] { ConsoleColor.DarkRed, ConsoleColor.Red, ConsoleColor.DarkYellow, ConsoleColor.Yellow,
|
|
||||||
ConsoleColor.DarkYellow, ConsoleColor.Red };
|
|
||||||
|
|
||||||
public char Azonosito { get; private set; }
|
|
||||||
public float Ertek { get; private set; }
|
|
||||||
public int Suly { get; private set; }
|
|
||||||
|
|
||||||
int villogasSzamlalo = 0;
|
|
||||||
public override Jel Jel
|
|
||||||
{
|
|
||||||
get { return new Jel(Azonosito, szinek[villogasSzamlalo++ % szinek.Length]); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Kincs(Terkep terkep, Pozicio pozicio, char azonosito, float ertek, int suly) : base(terkep, pozicio)
|
|
||||||
{
|
|
||||||
this.Azonosito = azonosito;
|
|
||||||
this.Ertek = ertek;
|
|
||||||
this.Suly = suly;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class KincsKezelo : INezopont
|
|
||||||
{
|
|
||||||
readonly protected Kincs[] kincsek = new Kincs[Param.KINCSEK_SZAMA];
|
|
||||||
readonly protected Terkep terkep;
|
|
||||||
|
|
||||||
public KincsKezelo(Terkep terkep)
|
|
||||||
{
|
|
||||||
this.terkep = terkep;
|
|
||||||
megjelenithetoKincsAdatok = Array.Empty<FixJel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void KincsekGeneralasa()
|
|
||||||
{
|
|
||||||
Random rnd = new Random();
|
|
||||||
for (int i = 0; i < Param.KINCSEK_SZAMA; i++)
|
|
||||||
kincsek[i] = new Kincs(terkep, new Pozicio(0, 0), (char)(i + 97), rnd.Next(1, 100 / Param.KINCSEK_SZAMA), rnd.Next(1, Param.KINCSEK_MAX_MERETE));
|
|
||||||
KincsekElhelyezese();
|
|
||||||
MegjelenitesRendereles();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void KincsekElhelyezese()
|
|
||||||
{
|
|
||||||
Random rnd = new Random();
|
|
||||||
int i = 0;
|
|
||||||
while (i < Param.KINCSEK_SZAMA)
|
|
||||||
{
|
|
||||||
Pozicio rndPozicio = new Pozicio(rnd.Next(terkep.Meret.Szelesseg), rnd.Next(terkep.Meret.Magassag));
|
|
||||||
if (terkep.AdottHelyen(rndPozicio).Count == 0)
|
|
||||||
{
|
|
||||||
kincsek[i].Athelyez(rndPozicio);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMegjelenitheto[] megjelenithetoKincsAdatok;
|
|
||||||
private void MegjelenitesRendereles()
|
|
||||||
{
|
|
||||||
List<FixJel> elemek = new List<FixJel>();
|
|
||||||
for (int i = 0; i < kincsek.Length; i++)
|
|
||||||
{
|
|
||||||
string szoveg = kincsek[i].Jel.Karakter + " " + kincsek[i].Ertek + "/" + kincsek[i].Suly;
|
|
||||||
elemek.AddRange(FixJel.SzovegbolJelsor(szoveg, new Pozicio(1, i), ConsoleColor.White));
|
|
||||||
}
|
|
||||||
megjelenithetoKincsAdatok = elemek.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Fejlec => "Kincsek";
|
|
||||||
|
|
||||||
public Meret Meret => new Meret(9, Param.KINCSEK_SZAMA);
|
|
||||||
|
|
||||||
public IMegjelenitheto[] MegjelenitendoElemek()
|
|
||||||
{
|
|
||||||
return megjelenithetoKincsAdatok;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
namespace OE.ALGA.Sandbox
|
|
||||||
{
|
|
||||||
internal class Program
|
|
||||||
{
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
using OE.ALGA.Paradigmak;
|
|
||||||
|
|
||||||
namespace Guardian
|
|
||||||
{
|
|
||||||
public static class Recursion
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This method is injected into every method and property call to check the current state
|
|
||||||
/// of the stack. If the number of calls on the stack exceeds 500, infinite recursion is
|
|
||||||
/// assumed and an exception is thrown, avoiding a complete program crash.
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="System.StackOverflowException"></exception>
|
|
||||||
public static void CheckStackTrace()
|
|
||||||
{
|
|
||||||
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
|
|
||||||
if (st.FrameCount > 500)
|
|
||||||
throw new System.StackOverflowException($"A stack overflow has occurred! Method call depth has reached the limit (500<=): {st.FrameCount}!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace OE.ALGA.Tesztek
|
|
||||||
{
|
|
||||||
#region Paradigmak
|
|
||||||
class TesztFeladat : IVegrehajthato
|
|
||||||
{
|
|
||||||
public string Azonosito { get; set; }
|
|
||||||
public bool Vegrehajtott { get; set; }
|
|
||||||
|
|
||||||
public void Vegrehajtas() => Vegrehajtott = true;
|
|
||||||
public TesztFeladat(string nev) => Azonosito = nev;
|
|
||||||
}
|
|
||||||
class TesztFuggoFeladat : TesztFeladat, IFuggo
|
|
||||||
{
|
|
||||||
public bool Vegrehajthato { get; set; }
|
|
||||||
|
|
||||||
public virtual bool FuggosegTeljesul => Vegrehajthato;
|
|
||||||
|
|
||||||
public TesztFuggoFeladat(string nev) : base(nev) { }
|
|
||||||
}
|
|
||||||
class TesztElokovetelmenytolFuggoFeladat : TesztFuggoFeladat
|
|
||||||
{
|
|
||||||
readonly TesztFeladat elokovetelmeny;
|
|
||||||
|
|
||||||
public override bool FuggosegTeljesul => base.FuggosegTeljesul && elokovetelmeny.Vegrehajtott;
|
|
||||||
public TesztElokovetelmenytolFuggoFeladat(string nev, TesztFeladat elokovetelmeny) : base(nev) { this.elokovetelmeny = elokovetelmeny; }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Optimalizalas
|
|
||||||
public class PakolasTesztEsetek
|
|
||||||
{
|
|
||||||
public static readonly bool[] uresPakolas = [false, false, false, false, false, false];
|
|
||||||
public static readonly bool[] feligPakolas = [false, true, false, true, false, false];
|
|
||||||
public static readonly bool[] teljesPakolas = [true, true, true, true, true, true];
|
|
||||||
|
|
||||||
public static readonly int[] jegyzet_w = [2, 1, 1, 1, 3, 2];
|
|
||||||
public static readonly float[] jegyzet_p = [4, 3, 2, 8, 7, 5];
|
|
||||||
public static readonly int jegyzet_n = jegyzet_w.Length;
|
|
||||||
public static readonly int jegyzet_Wmax = 4;
|
|
||||||
public static readonly float jegyzet_optimalis_ertek = 16;
|
|
||||||
public static readonly bool[] jegyzet_optimalis_pakolas = [false, true, false, true, false, true];
|
|
||||||
|
|
||||||
public static readonly int[] nagy_w = [21, 41, 26, 11, 37, 25, 25, 44, 33, 29, 32, 52, 41, 62, 56, 81, 43];
|
|
||||||
public static readonly float[] nagy_p = [4, 3, 2, 8, 7, 5, 4, 3, 2, 5, 3, 9, 5, 1, 7, 9, 4];
|
|
||||||
public static readonly int nagy_n = nagy_w.Length;
|
|
||||||
public static readonly int nagy_Wmax = 100;
|
|
||||||
public static readonly float nagy_optimalis_ertek = 24;
|
|
||||||
public static readonly bool[] nagy_optimalis_pakolas = [true, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false];
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
using NUnit.Framework;
|
|
||||||
using OE.ALGA.Paradigmak;
|
|
||||||
|
|
||||||
|
|
||||||
namespace OE.ALGA.Tesztek.Paradigmak
|
|
||||||
{
|
|
||||||
[TestFixture(Category = "Paradigmák", TestName = "01 - Feladat Tároló Tesztek")]
|
|
||||||
public class FeladatTaroloTesztek
|
|
||||||
{
|
|
||||||
[TestCase]
|
|
||||||
public void Ures()
|
|
||||||
{
|
|
||||||
FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(0);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
Assert.Throws<TaroloMegteltKivetel>(() => tarolo.Felvesz(a));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Felvesz()
|
|
||||||
{
|
|
||||||
FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(5);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase]
|
|
||||||
public void TulsokatFelvesz()
|
|
||||||
{
|
|
||||||
FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(3);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
Assert.Throws<TaroloMegteltKivetel>(() => tarolo.Felvesz(a));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void NincsMitVegrehajtani()
|
|
||||||
{
|
|
||||||
FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(2);
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void MindentVegrehajt()
|
|
||||||
{
|
|
||||||
FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(2);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
TesztFeladat b = new TesztFeladat("b");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void FelvettetVegrehajt()
|
|
||||||
{
|
|
||||||
FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(10);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
TesztFeladat b = new TesztFeladat("b");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestFixture(Category = "Paradigmák", TestName = "01 - Függő Feladat Tároló Tesztek")]
|
|
||||||
public class FuggoFeladatTaroloTesztek
|
|
||||||
{
|
|
||||||
[TestCase]
|
|
||||||
public void Felvesz()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void TulsokatFelvesz()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(3);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
Assert.Throws<TaroloMegteltKivetel>(() => tarolo.Felvesz(a));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void NincsMitVegrehajtani()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(2);
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void MindentVegrehajt()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(2);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
|
||||||
TesztFuggoFeladat b = new TesztFuggoFeladat("b") { Vegrehajthato = true };
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void VegrehajtasAmikorNemVegrehajthatok()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
|
||||||
TesztFuggoFeladat b = new TesztFuggoFeladat("b");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void VegrehajtasAmikorVegrehajthatok()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
|
||||||
TesztFuggoFeladat b = new TesztFuggoFeladat("b");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
b.Vegrehajthato = true;
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[TestFixture(Category = "Paradigmák", TestName = "01 - Feltételes Feladat Tároló Előkövetelményekkel Tesztek")]
|
|
||||||
public class FuggoFeladatTaroloElokovetelmenyekkelTesztek
|
|
||||||
{
|
|
||||||
[TestCase]
|
|
||||||
public void Elokovetelmenyes()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
|
||||||
TesztElokovetelmenytolFuggoFeladat b = new TesztElokovetelmenytolFuggoFeladat("b", a) { Vegrehajthato = true };
|
|
||||||
// a->b
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
a.Vegrehajthato = true;
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void TobbKorosElokovetelmenyes()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
|
||||||
TesztElokovetelmenytolFuggoFeladat b = new TesztElokovetelmenytolFuggoFeladat("b", a) { Vegrehajthato = true };
|
|
||||||
TesztElokovetelmenytolFuggoFeladat c = new TesztElokovetelmenytolFuggoFeladat("c", a) { Vegrehajthato = true };
|
|
||||||
TesztElokovetelmenytolFuggoFeladat d = new TesztElokovetelmenytolFuggoFeladat("d", b) { Vegrehajthato = true };
|
|
||||||
// a->b->d
|
|
||||||
// ->c
|
|
||||||
tarolo.Felvesz(d);
|
|
||||||
tarolo.Felvesz(c);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.False); //a 'b' kiértékelése az 'a' végrehajtása előtt volt, ezért az még nem lett feldolgozva
|
|
||||||
Assert.That(c.Vegrehajtott, Is.False); //a 'c' kiértékelése az 'a' végrehajtása előtt volt, ezért az még nem lett feldolgozva
|
|
||||||
Assert.That(d.Vegrehajtott, Is.False);
|
|
||||||
});
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(c.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(d.Vegrehajtott, Is.False); //a 'd' kiértékelése a 'b' végrehajtása előtt volt, ezért az még nem lett feldolgozva
|
|
||||||
});
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(c.Vegrehajtott, Is.True);
|
|
||||||
Assert.That(d.Vegrehajtott, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[TestFixture(Category = "Paradigmák", TestName = "01 - Bejáró Tesztek")]
|
|
||||||
class BejarasokTesztek
|
|
||||||
{
|
|
||||||
[TestCase]
|
|
||||||
public void FeladatTaroloBejaro()
|
|
||||||
{
|
|
||||||
FeladatTarolo<TesztFeladat> tarolo = new FeladatTarolo<TesztFeladat>(10);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
TesztFeladat b = new TesztFeladat("b");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
string nevek = "";
|
|
||||||
foreach (TesztFeladat u in tarolo)
|
|
||||||
nevek += u.Azonosito;
|
|
||||||
Assert.That(nevek, Is.EqualTo("ab"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase]
|
|
||||||
public void FuggoFeladatTaroloBejaro()
|
|
||||||
{
|
|
||||||
FuggoFeladatTarolo<TesztFuggoFeladat> tarolo = new FuggoFeladatTarolo<TesztFuggoFeladat>(5);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a");
|
|
||||||
TesztFuggoFeladat b = new TesztFuggoFeladat("b") { Vegrehajthato = true };
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
string nevek = "";
|
|
||||||
foreach (TesztFuggoFeladat u in tarolo)
|
|
||||||
if (u.Vegrehajtott)
|
|
||||||
nevek += u.Azonosito;
|
|
||||||
Assert.That(nevek, Is.EqualTo("b"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using OE.ALGA.Paradigmak;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Tesztek
|
|
||||||
{
|
|
||||||
[TestClass()]
|
|
||||||
public class FeltetelesFeladatTaroloTesztek
|
|
||||||
{
|
|
||||||
[TestMethod()]
|
|
||||||
public void FelveszTeszt() //F1.(a)
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
[ExpectedException(typeof(TaroloMegteltKivetel))]
|
|
||||||
public void TulsokatFelveszTeszt() //F1.(a)
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(5);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void MindenVegrehajtasTeszt() //F1.(a)
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
TesztFeladat b = new TesztFeladat("b");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(a.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(b.Vegrehajtott);
|
|
||||||
tarolo.MindentVegrehajt();
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(b.Vegrehajtott);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void BejaroTeszt() //F1.(a)
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
|
||||||
TesztFeladat a = new TesztFeladat("a");
|
|
||||||
TesztFeladat b = new TesztFeladat("b");
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
string nevek = "";
|
|
||||||
foreach (TesztFeladat u in tarolo)
|
|
||||||
{
|
|
||||||
nevek += u.Azonosito;
|
|
||||||
}
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("ab", nevek);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void FeltetelesVegrehajtasTeszt() //F1.(b)
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
|
||||||
TesztFeladat a1 = new TesztFeladat("a1");
|
|
||||||
TesztFeladat b1 = new TesztFeladat("b1");
|
|
||||||
TesztFeladat a2 = new TesztFeladat("a2");
|
|
||||||
tarolo.Felvesz(a1);
|
|
||||||
tarolo.Felvesz(b1);
|
|
||||||
tarolo.Felvesz(a2);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(a1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(b1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(a2.Vegrehajtott);
|
|
||||||
tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'a'); // csak 'a' kezdetűek végrehajtása
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(b1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a2.Vegrehajtott);
|
|
||||||
tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'b'); // csak 'b' kezdetűek végrehajtása
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(b1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a2.Vegrehajtott);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void FeltetelesFuggosegesVegrehajtasTeszt() //F1.(b)
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTarolo<TesztFuggoFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFuggoFeladat>(10);
|
|
||||||
TesztFuggoFeladat a1 = new TesztFuggoFeladat("a1") { Vegrehajthato = true };
|
|
||||||
TesztFuggoFeladat b1 = new TesztFuggoFeladat("b1") { Vegrehajthato = true };
|
|
||||||
TesztFuggoFeladat a2 = new TesztFuggoFeladat("a2") { Vegrehajthato = false };
|
|
||||||
tarolo.Felvesz(a1);
|
|
||||||
tarolo.Felvesz(b1);
|
|
||||||
tarolo.Felvesz(a2);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(a1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(b1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(a2.Vegrehajtott);
|
|
||||||
tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'a' && x.FuggosegTeljesul); // csak 'a' kezdetű és végrehajtható
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(b1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(a2.Vegrehajtott);
|
|
||||||
tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'b' && x.FuggosegTeljesul); // csak 'b' kezdetű és végrehajtható
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(b1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsFalse(a2.Vegrehajtott);
|
|
||||||
a2.Vegrehajthato = true;
|
|
||||||
tarolo.FeltetelesVegrehajtas(x => x.Azonosito[0] == 'a' && x.FuggosegTeljesul); // csak 'a' kezdetű és végrehajtható
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(b1.Vegrehajtott);
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(a2.Vegrehajtott);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void FeltetelesBejaroTeszt() //F3.(b)
|
|
||||||
{
|
|
||||||
FeltetelesFeladatTarolo<TesztFuggoFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFuggoFeladat>(10);
|
|
||||||
tarolo.BejaroFeltetel = (x => x.FuggosegTeljesul);
|
|
||||||
TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
|
||||||
TesztFuggoFeladat b = new TesztFuggoFeladat("b") { Vegrehajthato = false };
|
|
||||||
TesztFuggoFeladat c = new TesztFuggoFeladat("c") { Vegrehajthato = true };
|
|
||||||
tarolo.Felvesz(a);
|
|
||||||
tarolo.Felvesz(b);
|
|
||||||
tarolo.Felvesz(c);
|
|
||||||
string nevek = "";
|
|
||||||
foreach (TesztFeladat u in tarolo)
|
|
||||||
{
|
|
||||||
nevek += u.Azonosito;
|
|
||||||
}
|
|
||||||
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("ac", nevek);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using OE.ALGA.Paradigmak;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Paradigmak
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Paradigmák", TestName = "02 - Feltételes Feladat Tároló Tesztek")]
|
|
||||||
// public class FeltetelesFeladatTaroloTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void Felvesz()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(5);
|
|
||||||
// TesztFeladat a = new TesztFeladat("a");
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TulsokatFelvesz()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(3);
|
|
||||||
// TesztFeladat a = new TesztFeladat("a");
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// Assert.Throws<TaroloMegteltKivetel>(() => tarolo.Felvesz(a));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NincsMitVegrehajtani()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(2);
|
|
||||||
// tarolo.MindentVegrehajt();
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void MindenVegrehajtas()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(2);
|
|
||||||
// TesztFeladat a = new TesztFeladat("a");
|
|
||||||
// TesztFeladat b = new TesztFeladat("b");
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// tarolo.Felvesz(b);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a.Vegrehajtott, Is.False);
|
|
||||||
// Assert.That(b.Vegrehajtott, Is.False);
|
|
||||||
// });
|
|
||||||
// tarolo.MindentVegrehajt();
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(b.Vegrehajtott, Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void FeltetelesVegrehajtas()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
|
||||||
// TesztFeladat a1 = new TesztFeladat("a1");
|
|
||||||
// TesztFeladat b1 = new TesztFeladat("b1");
|
|
||||||
// TesztFeladat a2 = new TesztFeladat("a2");
|
|
||||||
// tarolo.Felvesz(a1);
|
|
||||||
// tarolo.Felvesz(b1);
|
|
||||||
// tarolo.Felvesz(a2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a1.Vegrehajtott, Is.False);
|
|
||||||
// Assert.That(b1.Vegrehajtott, Is.False);
|
|
||||||
// Assert.That(a2.Vegrehajtott, Is.False);
|
|
||||||
// });
|
|
||||||
// tarolo.FeltetelesVegrehajtas(x => { Guardian.Recursion.CheckStackTrace(); return x.Azonosito[0] == 'a'; }); // csak 'a' kezdetűek végrehajtása
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(b1.Vegrehajtott, Is.False);
|
|
||||||
// Assert.That(a2.Vegrehajtott, Is.True);
|
|
||||||
// });
|
|
||||||
// tarolo.FeltetelesVegrehajtas(x => { Guardian.Recursion.CheckStackTrace(); return x.Azonosito[0] == 'b'; }); // csak 'b' kezdetűek végrehajtása
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(b1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(a2.Vegrehajtott, Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void FeltetelesFuggosegesVegrehajtas()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFuggoFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFuggoFeladat>(10);
|
|
||||||
// TesztFuggoFeladat a1 = new TesztFuggoFeladat("a1") { Vegrehajthato = true };
|
|
||||||
// TesztFuggoFeladat b1 = new TesztFuggoFeladat("b1") { Vegrehajthato = true };
|
|
||||||
// TesztFuggoFeladat a2 = new TesztFuggoFeladat("a2") { Vegrehajthato = false };
|
|
||||||
// tarolo.Felvesz(a1);
|
|
||||||
// tarolo.Felvesz(b1);
|
|
||||||
// tarolo.Felvesz(a2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a1.Vegrehajtott, Is.False);
|
|
||||||
// Assert.That(b1.Vegrehajtott, Is.False);
|
|
||||||
// Assert.That(a2.Vegrehajtott, Is.False);
|
|
||||||
// });
|
|
||||||
// tarolo.FeltetelesVegrehajtas(x => { Guardian.Recursion.CheckStackTrace(); return x.Azonosito[0] == 'a' && x.FuggosegTeljesul; }); // csak 'a' kezdetű és végrehajtható
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(b1.Vegrehajtott, Is.False);
|
|
||||||
// Assert.That(a2.Vegrehajtott, Is.False);
|
|
||||||
// });
|
|
||||||
// tarolo.FeltetelesVegrehajtas(x => { Guardian.Recursion.CheckStackTrace(); return x.Azonosito[0] == 'b' && x.FuggosegTeljesul; }); // csak 'b' kezdetű és végrehajtható
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(b1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(a2.Vegrehajtott, Is.False);
|
|
||||||
// });
|
|
||||||
// a2.Vegrehajthato = true;
|
|
||||||
// tarolo.FeltetelesVegrehajtas(x => { Guardian.Recursion.CheckStackTrace(); return x.Azonosito[0] == 'a' && x.FuggosegTeljesul; }); // csak 'a' kezdetű és végrehajtható
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(b1.Vegrehajtott, Is.True);
|
|
||||||
// Assert.That(a2.Vegrehajtott, Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Bejaro()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFeladat>(10);
|
|
||||||
// TesztFeladat a = new TesztFeladat("a");
|
|
||||||
// TesztFeladat b = new TesztFeladat("b");
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// tarolo.Felvesz(b);
|
|
||||||
// string nevek = "";
|
|
||||||
// foreach (TesztFeladat u in tarolo)
|
|
||||||
// nevek += u.Azonosito;
|
|
||||||
// Assert.That(nevek, Is.EqualTo("ab"));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void FeltetelesBejaro()
|
|
||||||
// {
|
|
||||||
// FeltetelesFeladatTarolo<TesztFuggoFeladat> tarolo = new FeltetelesFeladatTarolo<TesztFuggoFeladat>(10);
|
|
||||||
// tarolo.BejaroFeltetel = (x => { Guardian.Recursion.CheckStackTrace(); return x.FuggosegTeljesul; });
|
|
||||||
// TesztFuggoFeladat a = new TesztFuggoFeladat("a") { Vegrehajthato = true };
|
|
||||||
// TesztFuggoFeladat b = new TesztFuggoFeladat("b") { Vegrehajthato = false };
|
|
||||||
// TesztFuggoFeladat c = new TesztFuggoFeladat("c") { Vegrehajthato = true };
|
|
||||||
// tarolo.Felvesz(a);
|
|
||||||
// tarolo.Felvesz(b);
|
|
||||||
// tarolo.Felvesz(c);
|
|
||||||
// string nevek = "";
|
|
||||||
// foreach (TesztFeladat u in tarolo)
|
|
||||||
// nevek += u.Azonosito;
|
|
||||||
// Assert.That(nevek, Is.EqualTo("ac"));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,399 +0,0 @@
|
|||||||
using NUnit.Framework;
|
|
||||||
using OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Tesztek.Adatszerkezetek
|
|
||||||
{
|
|
||||||
[TestFixture(Category = "Adatszerkezetek", TestName = "03 - Tömb Lista Tesztek")]
|
|
||||||
public class TombListaTesztek
|
|
||||||
{
|
|
||||||
[TestCase]
|
|
||||||
public void Elemszam()
|
|
||||||
{
|
|
||||||
Lista<string> l = new TombLista<string>();
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(0));
|
|
||||||
l.Hozzafuz("A");
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(1));
|
|
||||||
l.Hozzafuz("B");
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(2));
|
|
||||||
l.Torol("A");
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(1));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Bejaras()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
string s = "";
|
|
||||||
l.Bejar(x => { Guardian.Recursion.CheckStackTrace(); s += x.ToString(); });
|
|
||||||
Assert.That(s, Is.EqualTo("132"));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Beszuras()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
l.Beszur(0, 1);
|
|
||||||
l.Beszur(0, 2);
|
|
||||||
l.Beszur(1, 3);
|
|
||||||
l.Beszur(3, 4);
|
|
||||||
l.Beszur(2, 5);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo(2));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo(3));
|
|
||||||
Assert.That(l.Kiolvas(2), Is.EqualTo(5));
|
|
||||||
Assert.That(l.Kiolvas(3), Is.EqualTo(1));
|
|
||||||
Assert.That(l.Kiolvas(4), Is.EqualTo(4));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void BeszurasUres()
|
|
||||||
{
|
|
||||||
Lista<string> l = new TombLista<string>();
|
|
||||||
l.Beszur(0, "1");
|
|
||||||
l.Beszur(0, "2");
|
|
||||||
l.Beszur(1, "");
|
|
||||||
l.Beszur(3, "");
|
|
||||||
l.Beszur(2, "5");
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo("2"));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo(""));
|
|
||||||
Assert.That(l.Kiolvas(2), Is.EqualTo("5"));
|
|
||||||
Assert.That(l.Kiolvas(3), Is.EqualTo("1"));
|
|
||||||
Assert.That(l.Kiolvas(4), Is.EqualTo(""));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void HozzaFuzes()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo(1));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo(3));
|
|
||||||
Assert.That(l.Kiolvas(2), Is.EqualTo(2));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void HozzaFuzesUres()
|
|
||||||
{
|
|
||||||
Lista<string> l = new TombLista<string>();
|
|
||||||
l.Hozzafuz("1");
|
|
||||||
l.Hozzafuz("");
|
|
||||||
l.Hozzafuz("");
|
|
||||||
l.Hozzafuz("1");
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo("1"));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo(""));
|
|
||||||
Assert.That(l.Kiolvas(2), Is.EqualTo(""));
|
|
||||||
Assert.That(l.Kiolvas(3), Is.EqualTo("1"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Novekedes()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
l.Hozzafuz(i * i);
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(1000));
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
Assert.That(l.Kiolvas(i), Is.EqualTo(i * i));
|
|
||||||
});
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(1000));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Torles()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(4);
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(5));
|
|
||||||
l.Torol(3);
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(3));
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo(1));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo(2));
|
|
||||||
Assert.That(l.Kiolvas(2), Is.EqualTo(4));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void TorlesNincsElem()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(0));
|
|
||||||
l.Torol(0);
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(0));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void TorlesUres()
|
|
||||||
{
|
|
||||||
Lista<string> l = new TombLista<string>();
|
|
||||||
l.Hozzafuz("1");
|
|
||||||
l.Hozzafuz("");
|
|
||||||
l.Hozzafuz("");
|
|
||||||
l.Hozzafuz("");
|
|
||||||
l.Hozzafuz("1");
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(5));
|
|
||||||
l.Torol("");
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(2));
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo("1"));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo("1"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void NemletezoTorles()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(3));
|
|
||||||
l.Torol(0);
|
|
||||||
Assert.That(l.Elemszam, Is.EqualTo(3));
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo(1));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo(2));
|
|
||||||
Assert.That(l.Kiolvas(2), Is.EqualTo(3));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Modositas()
|
|
||||||
{
|
|
||||||
Lista<int> l = new TombLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
l.Modosit(1, 5);
|
|
||||||
l.Modosit(0, 4);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(l.Kiolvas(0), Is.EqualTo(4));
|
|
||||||
Assert.That(l.Kiolvas(1), Is.EqualTo(5));
|
|
||||||
Assert.That(l.Kiolvas(2), Is.EqualTo(2));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void ForeachBejaras()
|
|
||||||
{
|
|
||||||
TombLista<string> l = new TombLista<string>();
|
|
||||||
l.Hozzafuz("a");
|
|
||||||
l.Hozzafuz("c");
|
|
||||||
l.Hozzafuz("d");
|
|
||||||
l.Hozzafuz("b");
|
|
||||||
string osszefuzo = "";
|
|
||||||
foreach (string x in l)
|
|
||||||
{
|
|
||||||
osszefuzo += x;
|
|
||||||
}
|
|
||||||
Assert.That(osszefuzo, Is.EqualTo("acdb"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestFixture(Category = "Adatszerkezetek", TestName = "03 - Tömb Sor Tesztek")]
|
|
||||||
public class TombSorTesztek
|
|
||||||
{
|
|
||||||
[TestCase]
|
|
||||||
public void Ures()
|
|
||||||
{
|
|
||||||
Sor<int> s = new TombSor<int>(0);
|
|
||||||
Assert.That(s.Ures, Is.True);
|
|
||||||
Assert.Throws<NincsHelyKivetel>(() => s.Sorba(1));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void AlapMukodes()
|
|
||||||
{
|
|
||||||
Sor<int> s = new TombSor<int>(3);
|
|
||||||
Assert.That(s.Ures, Is.True);
|
|
||||||
s.Sorba(1);
|
|
||||||
Assert.That(s.Ures, Is.False);
|
|
||||||
s.Sorba(3);
|
|
||||||
Assert.That(s.Ures, Is.False);
|
|
||||||
s.Sorba(2);
|
|
||||||
Assert.That(s.Ures, Is.False);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(1));
|
|
||||||
Assert.That(s.Ures, Is.False);
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(3));
|
|
||||||
Assert.That(s.Ures, Is.False);
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(2));
|
|
||||||
Assert.That(s.Ures, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void UresElem()
|
|
||||||
{
|
|
||||||
Sor<string> s = new TombSor<string>(3);
|
|
||||||
s.Sorba("");
|
|
||||||
s.Sorba("1");
|
|
||||||
s.Sorba("");
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(""));
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo("1"));
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(""));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Korbeeres()
|
|
||||||
{
|
|
||||||
Sor<int> s = new TombSor<int>(3);
|
|
||||||
s.Sorba(1);
|
|
||||||
s.Sorba(3);
|
|
||||||
s.Sorba(2);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(1));
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(3));
|
|
||||||
});
|
|
||||||
s.Sorba(4);
|
|
||||||
s.Sorba(5);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(2));
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(4));
|
|
||||||
Assert.That(s.Sorbol(), Is.EqualTo(5));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void TulSokElem()
|
|
||||||
{
|
|
||||||
Sor<int> s = new TombSor<int>(3);
|
|
||||||
s.Sorba(1);
|
|
||||||
s.Sorba(3);
|
|
||||||
s.Sorba(2);
|
|
||||||
Assert.Throws<NincsHelyKivetel>(() => s.Sorba(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestCase]
|
|
||||||
public void TulKevesElem()
|
|
||||||
{
|
|
||||||
Sor<int> s = new TombSor<int>(3);
|
|
||||||
s.Sorba(1);
|
|
||||||
s.Sorba(3);
|
|
||||||
s.Sorba(2);
|
|
||||||
s.Sorbol();
|
|
||||||
s.Sorbol();
|
|
||||||
s.Sorbol();
|
|
||||||
Assert.Throws<NincsElemKivetel>(() => s.Sorbol());
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Elso()
|
|
||||||
{
|
|
||||||
Sor<int> s = new TombSor<int>(3);
|
|
||||||
s.Sorba(1);
|
|
||||||
s.Sorba(3);
|
|
||||||
s.Sorba(2);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(s.Elso(), Is.EqualTo(1));
|
|
||||||
Assert.That(s.Elso(), Is.EqualTo(1));
|
|
||||||
});
|
|
||||||
s.Sorbol();
|
|
||||||
Assert.That(s.Elso(), Is.EqualTo(3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestFixture(Category = "Adatszerkezetek", TestName = "03 - Tömb Verem Tesztek")]
|
|
||||||
public class TombVeremTesztek
|
|
||||||
{
|
|
||||||
[TestCase]
|
|
||||||
public void Ures()
|
|
||||||
{
|
|
||||||
Verem<int> v = new TombVerem<int>(0);
|
|
||||||
Assert.That(v.Ures, Is.True);
|
|
||||||
Assert.Throws<NincsHelyKivetel>(() => v.Verembe(1));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void AlapMukodes()
|
|
||||||
{
|
|
||||||
Verem<int> v = new TombVerem<int>(3);
|
|
||||||
Assert.That(v.Ures, Is.True);
|
|
||||||
v.Verembe(1);
|
|
||||||
Assert.That(v.Ures, Is.False);
|
|
||||||
v.Verembe(3);
|
|
||||||
Assert.That(v.Ures, Is.False);
|
|
||||||
v.Verembe(2);
|
|
||||||
Assert.That(v.Ures, Is.False);
|
|
||||||
Assert.That(v.Verembol(), Is.EqualTo(2));
|
|
||||||
Assert.That(v.Ures, Is.False);
|
|
||||||
v.Verembe(4);
|
|
||||||
Assert.That(v.Ures, Is.False);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(v.Verembol(), Is.EqualTo(4));
|
|
||||||
Assert.That(v.Ures, Is.False);
|
|
||||||
Assert.That(v.Verembol(), Is.EqualTo(3));
|
|
||||||
Assert.That(v.Ures, Is.False);
|
|
||||||
Assert.That(v.Verembol(), Is.EqualTo(1));
|
|
||||||
Assert.That(v.Ures, Is.True);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void UresElem()
|
|
||||||
{
|
|
||||||
Verem<string> v = new TombVerem<string>(3);
|
|
||||||
v.Verembe("");
|
|
||||||
v.Verembe("1");
|
|
||||||
v.Verembe("");
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(v.Verembol(), Is.EqualTo(""));
|
|
||||||
Assert.That(v.Verembol(), Is.EqualTo("1"));
|
|
||||||
Assert.That(v.Verembol(), Is.EqualTo(""));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void TulSokElem()
|
|
||||||
{
|
|
||||||
Verem<int> v = new TombVerem<int>(3);
|
|
||||||
v.Verembe(1);
|
|
||||||
v.Verembe(3);
|
|
||||||
v.Verembe(2);
|
|
||||||
Assert.Throws<NincsHelyKivetel>(() => v.Verembe(4));
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void TulKevesElem()
|
|
||||||
{
|
|
||||||
Verem<int> v = new TombVerem<int>(3);
|
|
||||||
v.Verembe(1);
|
|
||||||
v.Verembe(3);
|
|
||||||
v.Verembe(2);
|
|
||||||
v.Verembol();
|
|
||||||
v.Verembol();
|
|
||||||
v.Verembol();
|
|
||||||
Assert.Throws<NincsElemKivetel>(() => v.Verembol());
|
|
||||||
}
|
|
||||||
[TestCase]
|
|
||||||
public void Felso()
|
|
||||||
{
|
|
||||||
Verem<int> v = new TombVerem<int>(3);
|
|
||||||
v.Verembe(1);
|
|
||||||
v.Verembe(3);
|
|
||||||
v.Verembe(2);
|
|
||||||
Assert.Multiple(() =>
|
|
||||||
{
|
|
||||||
Assert.That(v.Felso(), Is.EqualTo(2));
|
|
||||||
Assert.That(v.Felso(), Is.EqualTo(2));
|
|
||||||
});
|
|
||||||
v.Verembol();
|
|
||||||
Assert.That(v.Felso(), Is.EqualTo(3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,226 +0,0 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using OE.ALGA.Adatszerkezetek;
|
|
||||||
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
|
|
||||||
|
|
||||||
namespace OE.ALGA.Tesztek
|
|
||||||
{
|
|
||||||
[TestClass()]
|
|
||||||
public class LancoltVeremTesztek
|
|
||||||
{
|
|
||||||
[TestMethod()]
|
|
||||||
public void MindenJolMukodik() //F2.
|
|
||||||
{
|
|
||||||
Verem<int> v = new LancoltVerem<int>();
|
|
||||||
v.Verembe(1);
|
|
||||||
v.Verembe(3);
|
|
||||||
v.Verembe(2);
|
|
||||||
Assert.AreEqual(2, v.Verembol());
|
|
||||||
v.Verembe(4);
|
|
||||||
Assert.AreEqual(4, v.Verembol());
|
|
||||||
Assert.AreEqual(3, v.Verembol());
|
|
||||||
Assert.AreEqual(1, v.Verembol());
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
[ExpectedException(typeof(NincsElemKivetel))]
|
|
||||||
public void TulKevesElem() //F2.
|
|
||||||
{
|
|
||||||
Verem<int> v = new LancoltVerem<int>();
|
|
||||||
v.Verembe(1);
|
|
||||||
v.Verembe(3);
|
|
||||||
v.Verembe(2);
|
|
||||||
v.Verembol();
|
|
||||||
v.Verembol();
|
|
||||||
v.Verembol();
|
|
||||||
v.Verembol();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void Felso() //F2.
|
|
||||||
{
|
|
||||||
Verem<int> v = new LancoltVerem<int>();
|
|
||||||
v.Verembe(1);
|
|
||||||
v.Verembe(3);
|
|
||||||
v.Verembe(2);
|
|
||||||
Assert.AreEqual(2, v.Felso());
|
|
||||||
Assert.AreEqual(2, v.Felso());
|
|
||||||
v.Verembol();
|
|
||||||
Assert.AreEqual(3, v.Felso());
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void Ures() //F2.
|
|
||||||
{
|
|
||||||
Verem<int> v = new LancoltVerem<int>();
|
|
||||||
Assert.IsTrue(v.Ures);
|
|
||||||
v.Verembe(1);
|
|
||||||
Assert.IsFalse(v.Ures);
|
|
||||||
v.Verembol();
|
|
||||||
Assert.IsTrue(v.Ures);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestClass()]
|
|
||||||
public class LancoltSorTesztek
|
|
||||||
{
|
|
||||||
[TestMethod()]
|
|
||||||
public void AlapMukodes() //F3.
|
|
||||||
{
|
|
||||||
Sor<int> s = new LancoltSor<int>();
|
|
||||||
s.Sorba(1);
|
|
||||||
s.Sorba(3);
|
|
||||||
s.Sorba(2);
|
|
||||||
Assert.AreEqual(1, s.Sorbol());
|
|
||||||
Assert.AreEqual(3, s.Sorbol());
|
|
||||||
Assert.AreEqual(2, s.Sorbol());
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
[ExpectedException(typeof(NincsElemKivetel))]
|
|
||||||
public void TulKevesElem() //F3.
|
|
||||||
{
|
|
||||||
Sor<int> s = new LancoltSor<int>();
|
|
||||||
s.Sorba(1);
|
|
||||||
s.Sorba(3);
|
|
||||||
s.Sorba(2);
|
|
||||||
s.Sorbol();
|
|
||||||
s.Sorbol();
|
|
||||||
s.Sorbol();
|
|
||||||
s.Sorbol();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void Elso() //F3.
|
|
||||||
{
|
|
||||||
Sor<int> s = new LancoltSor<int>();
|
|
||||||
s.Sorba(1);
|
|
||||||
s.Sorba(3);
|
|
||||||
s.Sorba(2);
|
|
||||||
Assert.AreEqual(1, s.Elso());
|
|
||||||
Assert.AreEqual(1, s.Elso());
|
|
||||||
s.Sorbol();
|
|
||||||
Assert.AreEqual(3, s.Elso());
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod()]
|
|
||||||
public void Ures() //F3.
|
|
||||||
{
|
|
||||||
Sor<int> s = new LancoltSor<int>();
|
|
||||||
Assert.IsTrue(s.Ures);
|
|
||||||
s.Sorba(1);
|
|
||||||
Assert.IsFalse(s.Ures);
|
|
||||||
s.Sorbol();
|
|
||||||
Assert.IsTrue(s.Ures);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class LancoltListaTesztek
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public void Bejaras() //F4.
|
|
||||||
{
|
|
||||||
Lista<int> l = new LancoltLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
string s = "";
|
|
||||||
l.Bejar(x => s += x.ToString());
|
|
||||||
Assert.AreEqual("132", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void HozzaFuzes() //F4.
|
|
||||||
{
|
|
||||||
Lista<int> l = new LancoltLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
Assert.AreEqual(1, l.Kiolvas(0));
|
|
||||||
Assert.AreEqual(3, l.Kiolvas(1));
|
|
||||||
Assert.AreEqual(2, l.Kiolvas(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void Meret() //F4.
|
|
||||||
{
|
|
||||||
Lista<string> l = new LancoltLista<string>();
|
|
||||||
Assert.AreEqual(0, l.Elemszam);
|
|
||||||
l.Hozzafuz("A");
|
|
||||||
Assert.AreEqual(1, l.Elemszam);
|
|
||||||
l.Hozzafuz("B");
|
|
||||||
Assert.AreEqual(2, l.Elemszam);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void Novekedes() //F4.
|
|
||||||
{
|
|
||||||
Lista<int> l = new LancoltLista<int>();
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
l.Hozzafuz(i * i);
|
|
||||||
for (int i = 0; i < 1000; i++)
|
|
||||||
Assert.AreEqual(i * i, l.Kiolvas(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void Beszuras() //F4.
|
|
||||||
{
|
|
||||||
Lista<int> l = new LancoltLista<int>();
|
|
||||||
l.Beszur(0, 1);
|
|
||||||
l.Beszur(0, 2);
|
|
||||||
l.Beszur(1, 3);
|
|
||||||
l.Beszur(3, 4);
|
|
||||||
l.Beszur(2, 5);
|
|
||||||
Assert.AreEqual(2, l.Kiolvas(0));
|
|
||||||
Assert.AreEqual(3, l.Kiolvas(1));
|
|
||||||
Assert.AreEqual(5, l.Kiolvas(2));
|
|
||||||
Assert.AreEqual(1, l.Kiolvas(3));
|
|
||||||
Assert.AreEqual(4, l.Kiolvas(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void Torles() //F4.
|
|
||||||
{
|
|
||||||
Lista<int> l = new LancoltLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(4);
|
|
||||||
l.Torol(3);
|
|
||||||
Assert.AreEqual(1, l.Kiolvas(0));
|
|
||||||
Assert.AreEqual(2, l.Kiolvas(1));
|
|
||||||
Assert.AreEqual(4, l.Kiolvas(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void Modositas() //F4.
|
|
||||||
{
|
|
||||||
Lista<int> l = new LancoltLista<int>();
|
|
||||||
l.Hozzafuz(1);
|
|
||||||
l.Hozzafuz(3);
|
|
||||||
l.Hozzafuz(2);
|
|
||||||
l.Modosit(1, 5);
|
|
||||||
l.Modosit(0, 4);
|
|
||||||
Assert.AreEqual(4, l.Kiolvas(0));
|
|
||||||
Assert.AreEqual(5, l.Kiolvas(1));
|
|
||||||
Assert.AreEqual(2, l.Kiolvas(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ForeachBejaras() //F5.
|
|
||||||
{
|
|
||||||
LancoltLista<string> l = new LancoltLista<string>();
|
|
||||||
l.Hozzafuz("a");
|
|
||||||
l.Hozzafuz("c");
|
|
||||||
l.Hozzafuz("d");
|
|
||||||
l.Hozzafuz("b");
|
|
||||||
string osszefuzo = "";
|
|
||||||
foreach (string x in l)
|
|
||||||
{
|
|
||||||
osszefuzo += x;
|
|
||||||
}
|
|
||||||
Assert.AreEqual("acdb", osszefuzo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,353 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Adatszerkezetek
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "04 - Lancolt Lista Tesztek")]
|
|
||||||
// public class LancoltListaTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void Elemszam()
|
|
||||||
// {
|
|
||||||
// Lista<string> l = new LancoltLista<string>();
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(0));
|
|
||||||
// l.Hozzafuz("A");
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(1));
|
|
||||||
// l.Hozzafuz("B");
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(2));
|
|
||||||
// l.Torol("A");
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(1));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Bejaras()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// l.Hozzafuz(1);
|
|
||||||
// l.Hozzafuz(3);
|
|
||||||
// l.Hozzafuz(2);
|
|
||||||
// string s = "";
|
|
||||||
// l.Bejar(x => { Guardian.Recursion.CheckStackTrace(); s += x.ToString(); });
|
|
||||||
// Assert.That(s, Is.EqualTo("132"));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Beszuras()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// l.Beszur(0, 1);
|
|
||||||
// l.Beszur(0, 2);
|
|
||||||
// l.Beszur(1, 3);
|
|
||||||
// l.Beszur(3, 4);
|
|
||||||
// l.Beszur(2, 5);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo(2));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo(3));
|
|
||||||
// Assert.That(l.Kiolvas(2), Is.EqualTo(5));
|
|
||||||
// Assert.That(l.Kiolvas(3), Is.EqualTo(1));
|
|
||||||
// Assert.That(l.Kiolvas(4), Is.EqualTo(4));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void BeszurasUres()
|
|
||||||
// {
|
|
||||||
// Lista<string> l = new LancoltLista<string>();
|
|
||||||
// l.Beszur(0, "1");
|
|
||||||
// l.Beszur(0, "2");
|
|
||||||
// l.Beszur(1, "");
|
|
||||||
// l.Beszur(3, "");
|
|
||||||
// l.Beszur(2, "5");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo("2"));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo(""));
|
|
||||||
// Assert.That(l.Kiolvas(2), Is.EqualTo("5"));
|
|
||||||
// Assert.That(l.Kiolvas(3), Is.EqualTo("1"));
|
|
||||||
// Assert.That(l.Kiolvas(4), Is.EqualTo(""));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void HozzaFuzes()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// l.Hozzafuz(1);
|
|
||||||
// l.Hozzafuz(3);
|
|
||||||
// l.Hozzafuz(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo(1));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo(3));
|
|
||||||
// Assert.That(l.Kiolvas(2), Is.EqualTo(2));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void HozzaFuzesUres()
|
|
||||||
// {
|
|
||||||
// Lista<string> l = new LancoltLista<string>();
|
|
||||||
// l.Hozzafuz("1");
|
|
||||||
// l.Hozzafuz("");
|
|
||||||
// l.Hozzafuz("");
|
|
||||||
// l.Hozzafuz("1");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo("1"));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo(""));
|
|
||||||
// Assert.That(l.Kiolvas(2), Is.EqualTo(""));
|
|
||||||
// Assert.That(l.Kiolvas(3), Is.EqualTo("1"));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Novekedes()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// for (int i = 0; i < 1000; i++)
|
|
||||||
// l.Hozzafuz(i * i);
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(1000));
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// for (int i = 0; i < 1000; i++)
|
|
||||||
// Assert.That(l.Kiolvas(i), Is.EqualTo(i * i));
|
|
||||||
// });
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(1000));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Torles()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// l.Hozzafuz(1);
|
|
||||||
// l.Hozzafuz(3);
|
|
||||||
// l.Hozzafuz(2);
|
|
||||||
// l.Hozzafuz(3);
|
|
||||||
// l.Hozzafuz(4);
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(5));
|
|
||||||
// l.Torol(3);
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(3));
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo(1));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo(2));
|
|
||||||
// Assert.That(l.Kiolvas(2), Is.EqualTo(4));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TorlesNincsElem()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(0));
|
|
||||||
// l.Torol(0);
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(0));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TorlesUres()
|
|
||||||
// {
|
|
||||||
// Lista<string> l = new LancoltLista<string>();
|
|
||||||
// l.Hozzafuz("1");
|
|
||||||
// l.Hozzafuz("");
|
|
||||||
// l.Hozzafuz("");
|
|
||||||
// l.Hozzafuz("");
|
|
||||||
// l.Hozzafuz("1");
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(5));
|
|
||||||
// l.Torol("");
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(2));
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo("1"));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo("1"));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NemletezoTorles()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// l.Hozzafuz(1);
|
|
||||||
// l.Hozzafuz(2);
|
|
||||||
// l.Hozzafuz(3);
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(3));
|
|
||||||
// l.Torol(0);
|
|
||||||
// Assert.That(l.Elemszam, Is.EqualTo(3));
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo(1));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo(2));
|
|
||||||
// Assert.That(l.Kiolvas(2), Is.EqualTo(3));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Modositas()
|
|
||||||
// {
|
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
|
||||||
// l.Hozzafuz(1);
|
|
||||||
// l.Hozzafuz(3);
|
|
||||||
// l.Hozzafuz(2);
|
|
||||||
// l.Modosit(1, 5);
|
|
||||||
// l.Modosit(0, 4);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(l.Kiolvas(0), Is.EqualTo(4));
|
|
||||||
// Assert.That(l.Kiolvas(1), Is.EqualTo(5));
|
|
||||||
// Assert.That(l.Kiolvas(2), Is.EqualTo(2));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void ForeachBejaras()
|
|
||||||
// {
|
|
||||||
// LancoltLista<string> l = new LancoltLista<string>();
|
|
||||||
// l.Hozzafuz("a");
|
|
||||||
// l.Hozzafuz("c");
|
|
||||||
// l.Hozzafuz("d");
|
|
||||||
// l.Hozzafuz("b");
|
|
||||||
// string osszefuzo = "";
|
|
||||||
// foreach (string x in l)
|
|
||||||
// {
|
|
||||||
// osszefuzo += x;
|
|
||||||
// }
|
|
||||||
// Assert.That(osszefuzo, Is.EqualTo("acdb"));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "04 - Lancolt Sor Tesztek")]
|
|
||||||
// public class LancoltSorTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void Ures()
|
|
||||||
// {
|
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
|
||||||
// Assert.That(s.Ures, Is.True);
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => s.Elso());
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => s.Sorbol());
|
|
||||||
// s.Sorba(1);
|
|
||||||
// Assert.That(s.Ures, Is.False);
|
|
||||||
// s.Sorbol();
|
|
||||||
// Assert.That(s.Ures, Is.True);
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void AlapMukodes()
|
|
||||||
// {
|
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
|
||||||
// s.Sorba(1);
|
|
||||||
// s.Sorba(3);
|
|
||||||
// s.Sorba(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(1));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(3));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(2));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresElem()
|
|
||||||
// {
|
|
||||||
// Sor<string> s = new LancoltSor<string>();
|
|
||||||
// s.Sorba("");
|
|
||||||
// s.Sorba("1");
|
|
||||||
// s.Sorba("");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(""));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo("1"));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(""));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TulKevesElem()
|
|
||||||
// {
|
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
|
||||||
// s.Sorba(1);
|
|
||||||
// s.Sorba(3);
|
|
||||||
// s.Sorba(2);
|
|
||||||
// s.Sorbol();
|
|
||||||
// s.Sorbol();
|
|
||||||
// s.Sorbol();
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => s.Sorbol());
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Elso()
|
|
||||||
// {
|
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
|
||||||
// s.Sorba(1);
|
|
||||||
// s.Sorba(3);
|
|
||||||
// s.Sorba(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(1));
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(1));
|
|
||||||
// });
|
|
||||||
// s.Sorbol();
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(3));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "04 - Lancolt Verem Tesztek")]
|
|
||||||
// public class LancoltVeremTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void Ures()
|
|
||||||
// {
|
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
|
||||||
// Assert.That(v.Ures, Is.True);
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => v.Felso());
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => v.Verembol());
|
|
||||||
// v.Verembe(1);
|
|
||||||
// Assert.That(v.Ures, Is.False);
|
|
||||||
// v.Verembol();
|
|
||||||
// Assert.That(v.Ures, Is.True);
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void AlapMukodes()
|
|
||||||
// {
|
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
|
||||||
// v.Verembe(1);
|
|
||||||
// v.Verembe(3);
|
|
||||||
// v.Verembe(2);
|
|
||||||
// Assert.That(v.Verembol(), Is.EqualTo(2));
|
|
||||||
// v.Verembe(4);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Verembol(), Is.EqualTo(4));
|
|
||||||
// Assert.That(v.Verembol(), Is.EqualTo(3));
|
|
||||||
// Assert.That(v.Verembol(), Is.EqualTo(1));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresElem()
|
|
||||||
// {
|
|
||||||
// Verem<string> v = new LancoltVerem<string>();
|
|
||||||
// v.Verembe("");
|
|
||||||
// v.Verembe("1");
|
|
||||||
// v.Verembe("");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Verembol(), Is.EqualTo(""));
|
|
||||||
// Assert.That(v.Verembol(), Is.EqualTo("1"));
|
|
||||||
// Assert.That(v.Verembol(), Is.EqualTo(""));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TulKevesElem()
|
|
||||||
// {
|
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
|
||||||
// v.Verembe(1);
|
|
||||||
// v.Verembe(3);
|
|
||||||
// v.Verembe(2);
|
|
||||||
// v.Verembol();
|
|
||||||
// v.Verembol();
|
|
||||||
// v.Verembol();
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => v.Verembol());
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Felso()
|
|
||||||
// {
|
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
|
||||||
// v.Verembe(1);
|
|
||||||
// v.Verembe(3);
|
|
||||||
// v.Verembe(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Felso(), Is.EqualTo(2));
|
|
||||||
// Assert.That(v.Felso(), Is.EqualTo(2));
|
|
||||||
// });
|
|
||||||
// v.Verembol();
|
|
||||||
// Assert.That(v.Felso(), Is.EqualTo(3));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Adatszerkezetek
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "05 - Fa Halmaz Tesztek")]
|
|
||||||
// public class FaHalmazTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void BeszurasUres()
|
|
||||||
// {
|
|
||||||
// Halmaz<string> v = new FaHalmaz<string>();
|
|
||||||
// v.Beszur("");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Eleme(""), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Beszuras()
|
|
||||||
// {
|
|
||||||
// Halmaz<int> v = new FaHalmaz<int>();
|
|
||||||
// v.Beszur(1);
|
|
||||||
// v.Beszur(3);
|
|
||||||
// v.Beszur(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Eleme(1), Is.True);
|
|
||||||
// Assert.That(v.Eleme(2), Is.True);
|
|
||||||
// Assert.That(v.Eleme(3), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void DuplaBeszuras()
|
|
||||||
// {
|
|
||||||
// Halmaz<int> v = new FaHalmaz<int>();
|
|
||||||
// v.Beszur(1);
|
|
||||||
// v.Beszur(2);
|
|
||||||
// v.Beszur(3);
|
|
||||||
// v.Beszur(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Eleme(1), Is.True);
|
|
||||||
// Assert.That(v.Eleme(2), Is.True);
|
|
||||||
// Assert.That(v.Eleme(3), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Torles()
|
|
||||||
// {
|
|
||||||
// Halmaz<int> v = new FaHalmaz<int>();
|
|
||||||
// v.Beszur(1);
|
|
||||||
// v.Beszur(3);
|
|
||||||
// v.Beszur(2);
|
|
||||||
// v.Torol(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Eleme(1), Is.True);
|
|
||||||
// Assert.That(v.Eleme(2), Is.False);
|
|
||||||
// Assert.That(v.Eleme(3), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TorlesUres()
|
|
||||||
// {
|
|
||||||
// Halmaz<string> v = new FaHalmaz<string>();
|
|
||||||
// v.Beszur("");
|
|
||||||
// v.Beszur("1");
|
|
||||||
// v.Beszur("");
|
|
||||||
// v.Torol("");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Eleme(""), Is.False);
|
|
||||||
// Assert.That(v.Eleme("1"), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NemletezoTorles()
|
|
||||||
// {
|
|
||||||
// Halmaz<int> v = new FaHalmaz<int>();
|
|
||||||
// v.Beszur(1);
|
|
||||||
// v.Beszur(3);
|
|
||||||
// v.Beszur(2);
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => v.Torol(0));
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Eleme(1), Is.True);
|
|
||||||
// Assert.That(v.Eleme(2), Is.True);
|
|
||||||
// Assert.That(v.Eleme(3), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void DuplaTorles()
|
|
||||||
// {
|
|
||||||
// Halmaz<int> v = new FaHalmaz<int>();
|
|
||||||
// v.Beszur(1);
|
|
||||||
// v.Beszur(2);
|
|
||||||
// v.Beszur(3);
|
|
||||||
// v.Beszur(2);
|
|
||||||
// v.Torol(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(v.Eleme(1), Is.True);
|
|
||||||
// Assert.That(v.Eleme(2), Is.False);
|
|
||||||
// Assert.That(v.Eleme(3), Is.True);
|
|
||||||
// Assert.That(v.Eleme(4), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void PreorderBejaras()
|
|
||||||
// {
|
|
||||||
// Halmaz<int> v = new FaHalmaz<int>();
|
|
||||||
// v.Beszur(5);
|
|
||||||
// v.Beszur(3);
|
|
||||||
// v.Beszur(1);
|
|
||||||
// v.Beszur(8);
|
|
||||||
// v.Beszur(4);
|
|
||||||
// v.Beszur(9);
|
|
||||||
// v.Beszur(7);
|
|
||||||
// string osszefuzo = "";
|
|
||||||
// v.Bejar(x => osszefuzo += x);
|
|
||||||
// Assert.That(osszefuzo, Is.EqualTo("5314879"));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Adatszerkezetek
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "06 - Szótár Tesztek")]
|
|
||||||
// public class SzotarTesztek
|
|
||||||
// {
|
|
||||||
// private static int TesztHasitoFuggveny(string kulcs)
|
|
||||||
// {
|
|
||||||
// if (string.IsNullOrEmpty(kulcs))
|
|
||||||
// return 0;
|
|
||||||
// int sum = 0;
|
|
||||||
// foreach (char c in kulcs.ToCharArray())
|
|
||||||
// sum += ((byte)c);
|
|
||||||
// return sum * sum; // a modulo osztást a szótárnak kell végeznie, mert ő tudja csak a belső tömb méretet
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void AlapMukodes()
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(10, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("Bela", 5);
|
|
||||||
// sz.Beir("Lajos", 2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(sz.Kiolvas("Bela"), Is.EqualTo(5));
|
|
||||||
// Assert.That(sz.Kiolvas("Lajos"), Is.EqualTo(2));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void AlapertelmezettHasitoFuggvennyel() //F2.(f)
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(10);
|
|
||||||
// sz.Beir("Bela", 5);
|
|
||||||
// sz.Beir("Lajos", 2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(sz.Kiolvas("Bela"), Is.EqualTo(5));
|
|
||||||
// Assert.That(sz.Kiolvas("Lajos"), Is.EqualTo(2));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void Kulcsutkozes()
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(10, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("Bela", 5);
|
|
||||||
// sz.Beir("Bale", 15);
|
|
||||||
// sz.Beir("Lajos", 2);
|
|
||||||
// sz.Beir("Lasoj", 12);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(sz.Kiolvas("Bela"), Is.EqualTo(5));
|
|
||||||
// Assert.That(sz.Kiolvas("Lajos"), Is.EqualTo(2));
|
|
||||||
// Assert.That(sz.Kiolvas("Bale"), Is.EqualTo(15));
|
|
||||||
// Assert.That(sz.Kiolvas("Lasoj"), Is.EqualTo(12));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NullElem()
|
|
||||||
// {
|
|
||||||
// Szotar<string, string> sz = new HasitoSzotarTulcsordulasiTerulettel<string, string>(5, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("null", null!);
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresKulcs()
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("", 0);
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresElem()
|
|
||||||
// {
|
|
||||||
// Szotar<string, string> sz = new HasitoSzotarTulcsordulasiTerulettel<string, string>(5, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("Bela", "");
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NincsElem()
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("Bela", 5);
|
|
||||||
// sz.Beir("Lajos", 2);
|
|
||||||
// Assert.Throws<HibasKulcsKivetel>(() => sz.Kiolvas("Ferenc"));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TorlesNull()
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("Bela", 5);
|
|
||||||
// sz.Beir("Lajos", 2);
|
|
||||||
// Assert.Throws<HibasKulcsKivetel>(() => sz.Torol(null!));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TorlesMarad()
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("Bela", 5);
|
|
||||||
// sz.Beir("Lajos", 2);
|
|
||||||
// sz.Torol("Bela");
|
|
||||||
// Assert.That(sz.Kiolvas("Lajos"), Is.EqualTo(2));
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TorlesEltunt()
|
|
||||||
// {
|
|
||||||
// Szotar<string, int> sz = new HasitoSzotarTulcsordulasiTerulettel<string, int>(5, TesztHasitoFuggveny);
|
|
||||||
// sz.Beir("Bela", 5);
|
|
||||||
// sz.Beir("Lajos", 2);
|
|
||||||
// sz.Torol("Bela");
|
|
||||||
// Assert.Throws<HibasKulcsKivetel>(() => sz.Kiolvas("Bela"));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using System;
|
|
||||||
//using OE.ALGA.Optimalizalas;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Optimalizalas
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Optimalizalas", TestName = "07 - Hátiszák Tesztek")]
|
|
||||||
// public class HatizsakTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(0, 0, [], []);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(problema.OsszSuly(PakolasTesztEsetek.uresPakolas), Is.EqualTo(0));
|
|
||||||
// Assert.That(problema.OsszSuly(PakolasTesztEsetek.teljesPakolas), Is.EqualTo(0));
|
|
||||||
// Assert.That(problema.OsszSuly(PakolasTesztEsetek.feligPakolas), Is.EqualTo(0));
|
|
||||||
// });
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(problema.OsszErtek(PakolasTesztEsetek.uresPakolas), Is.EqualTo(0));
|
|
||||||
// Assert.That(problema.OsszErtek(PakolasTesztEsetek.teljesPakolas), Is.EqualTo(0));
|
|
||||||
// Assert.That(problema.OsszErtek(PakolasTesztEsetek.feligPakolas), Is.EqualTo(0));
|
|
||||||
// });
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(problema.Ervenyes(PakolasTesztEsetek.uresPakolas), Is.True);
|
|
||||||
// Assert.That(problema.Ervenyes(PakolasTesztEsetek.teljesPakolas), Is.True);
|
|
||||||
// Assert.That(problema.Ervenyes(PakolasTesztEsetek.feligPakolas), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void SulyTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(problema.OsszSuly(PakolasTesztEsetek.uresPakolas), Is.EqualTo(0));
|
|
||||||
// Assert.That(problema.OsszSuly(PakolasTesztEsetek.teljesPakolas), Is.EqualTo(10));
|
|
||||||
// Assert.That(problema.OsszSuly(PakolasTesztEsetek.feligPakolas), Is.EqualTo(2));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void JosagTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(problema.OsszErtek(PakolasTesztEsetek.uresPakolas), Is.EqualTo(0));
|
|
||||||
// Assert.That(problema.OsszErtek(PakolasTesztEsetek.teljesPakolas), Is.EqualTo(29));
|
|
||||||
// Assert.That(problema.OsszErtek(PakolasTesztEsetek.feligPakolas), Is.EqualTo(11));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void ErvenyesTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(problema.Ervenyes(PakolasTesztEsetek.uresPakolas), Is.True);
|
|
||||||
// Assert.That(problema.Ervenyes(PakolasTesztEsetek.teljesPakolas), Is.False);
|
|
||||||
// Assert.That(problema.Ervenyes(PakolasTesztEsetek.feligPakolas), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Optimalizalas", TestName = "07 - Nyers Ero Tesztek")]
|
|
||||||
// public class NyersEroTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresTeszt()
|
|
||||||
// {
|
|
||||||
// int[] A = { 4, 6, 7, 4, 2, 1 };
|
|
||||||
// NyersEro<int> opt = new NyersEro<int>(
|
|
||||||
// 0,
|
|
||||||
// x => { Guardian.Recursion.CheckStackTrace(); return A[x - 1]; },
|
|
||||||
// x => { Guardian.Recursion.CheckStackTrace(); return x; });
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EqualTo(4));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(0));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void TombLegnagyobbEleme()
|
|
||||||
// {
|
|
||||||
// int[] A = { 4, 6, 7, 4, 2, 1 };
|
|
||||||
// NyersEro<int> opt = new NyersEro<int>(
|
|
||||||
// A.Length,
|
|
||||||
// x => { Guardian.Recursion.CheckStackTrace(); return A[x - 1]; },
|
|
||||||
// x => { Guardian.Recursion.CheckStackTrace(); return x; });
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EqualTo(7));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(5));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Optimalizalas", TestName = "07 - Nyers Ero Hátizsák Pakolás Tesztek")]
|
|
||||||
// public class NyersEroHatizsakPakolasTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(0, 0, [], []);
|
|
||||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(0));
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(Array.Empty<bool>()));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(0));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaErtekTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.jegyzet_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(63));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(PakolasTesztEsetek.jegyzet_optimalis_pakolas));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(63));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyPeldaMegoldasErtekTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.nagy_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(131071));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// NyersEroHatizsakPakolas opt = new NyersEroHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(PakolasTesztEsetek.nagy_optimalis_pakolas));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(131071));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using System;
|
|
||||||
//using OE.ALGA.Optimalizalas;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Optimalizalas
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Optimalizalas", TestName = "08 - Dinamikus Programozás Tesztek")]
|
|
||||||
// public class DinamikusProgramozasTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(0, 0, [], []);
|
|
||||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(0));
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(Array.Empty<bool>()));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(0));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaErtekTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.jegyzet_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(24));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(PakolasTesztEsetek.jegyzet_optimalis_pakolas));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(24));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyPeldaMegoldasErtekTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.nagy_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(1700));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// DinamikusHatizsakPakolas opt = new DinamikusHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(PakolasTesztEsetek.nagy_optimalis_pakolas));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(1700));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using OE.ALGA.Optimalizalas;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Optimalizalas
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Optimalizalas", TestName = "09 - Visszalépéses Keresés Tesztek")]
|
|
||||||
// public class VisszalepesesKeresesTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaErtekTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.jegyzet_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(98));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(PakolasTesztEsetek.jegyzet_optimalis_pakolas));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(98));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.nagy_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(4832));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void LepesszamVizsgalat()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.nagy_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(4832));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Optimalizalas", TestName = "09 - Szétválasztás és Korlátozás Tesztek")]
|
|
||||||
// public class SzetvalasztasEsKorlatozasTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaErtekTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.jegyzet_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(62));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void JegyzetbenLevoPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisMegoldas(), Is.EquivalentTo(PakolasTesztEsetek.jegyzet_optimalis_pakolas));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(62));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyPeldaMegoldasTeszt()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.nagy_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(618));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// [TestCase]
|
|
||||||
// public void LepesszamVizsgalat()
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(opt.OptimalisErtek(), Is.EqualTo(PakolasTesztEsetek.nagy_optimalis_ertek));
|
|
||||||
// Assert.That(opt.LepesSzam, Is.EqualTo(618));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
// using OE.ALGA.Optimalizalas;
|
|
||||||
//
|
|
||||||
// namespace OE.ALGA.Tesztek
|
|
||||||
// {
|
|
||||||
// [TestClass()]
|
|
||||||
// public class VisszalepesesKeresesTesztek
|
|
||||||
// {
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void JegyzetbenLevoPeldaErtekTeszt() //F2.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// Assert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_ertek, opt.OptimalisErtek());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void JegyzetbenLevoPeldaMegoldasTeszt() //F2.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// CollectionAssert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_pakolas, opt.OptimalisMegoldas());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void NagyPeldaMegoldasTeszt() //F2.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void LepesszamVizsgalat() //F2.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// VisszalepesesHatizsakPakolas opt = new VisszalepesesHatizsakPakolas(problema);
|
|
||||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
|
||||||
// Console.WriteLine("Lépésszám: " + opt.LepesSzam);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [TestClass()]
|
|
||||||
// public class SzetvalasztasEsKorlatozasTesztek
|
|
||||||
// {
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void JegyzetbenLevoPeldaErtekTeszt() //F4.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// Assert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_ertek, opt.OptimalisErtek());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void JegyzetbenLevoPeldaMegoldasTeszt() //F4.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.jegyzet_n, PakolasTesztEsetek.jegyzet_Wmax, PakolasTesztEsetek.jegyzet_w, PakolasTesztEsetek.jegyzet_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// CollectionAssert.AreEqual(PakolasTesztEsetek.jegyzet_optimalis_pakolas, opt.OptimalisMegoldas());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void NagyPeldaMegoldasTeszt() //F4.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [TestMethod()]
|
|
||||||
// public void LepesszamVizsgalat() //F4.
|
|
||||||
// {
|
|
||||||
// HatizsakProblema problema = new HatizsakProblema(PakolasTesztEsetek.nagy_n, PakolasTesztEsetek.nagy_Wmax, PakolasTesztEsetek.nagy_w, PakolasTesztEsetek.nagy_p);
|
|
||||||
// SzetvalasztasEsKorlatozasHatizsakPakolas opt = new SzetvalasztasEsKorlatozasHatizsakPakolas(problema);
|
|
||||||
// Assert.AreEqual(PakolasTesztEsetek.nagy_optimalis_ertek, opt.OptimalisErtek());
|
|
||||||
// Console.WriteLine("Lépésszám: " + opt.LepesSzam);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Adatszerkezetek
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "10 - Csúcsmátrix Gráf Tesztek")]
|
|
||||||
// public class CsucsMatrixGrafTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void MindenCsucsTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(csg.Csucsok.Eleme(0), Is.True);
|
|
||||||
// Assert.That(csg.Csucsok.Eleme(1), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void MindenElTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1);
|
|
||||||
// csg.UjEl(0, 2);
|
|
||||||
// csg.UjEl(1, 2);
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(0, 0)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(0, 1)), Is.True);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(0, 2)), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(1, 0)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(1, 1)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(1, 2)), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(2, 0)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(2, 1)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new EgeszGrafEl(2, 2)), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void VezetElTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(2);
|
|
||||||
// Assert.That(csg.VezetEl(0, 1), Is.False);
|
|
||||||
// csg.UjEl(0, 1);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(csg.VezetEl(0, 1), Is.True);
|
|
||||||
// Assert.That(csg.VezetEl(1, 0), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void SzomszedsagTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozatlanEgeszGraf csg = new CsucsmatrixSulyozatlanEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1);
|
|
||||||
// csg.UjEl(0, 2);
|
|
||||||
// csg.UjEl(1, 2);
|
|
||||||
|
|
||||||
// Halmaz<int> a_szomszedai = csg.Szomszedai(0);
|
|
||||||
// Halmaz<int> b_szomszedai = csg.Szomszedai(1);
|
|
||||||
// Halmaz<int> c_szomszedai = csg.Szomszedai(2);
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a_szomszedai.Eleme(0), Is.False);
|
|
||||||
// Assert.That(a_szomszedai.Eleme(1), Is.True);
|
|
||||||
// Assert.That(a_szomszedai.Eleme(2), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(b_szomszedai.Eleme(0), Is.False);
|
|
||||||
// Assert.That(b_szomszedai.Eleme(1), Is.False);
|
|
||||||
// Assert.That(b_szomszedai.Eleme(2), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(c_szomszedai.Eleme(0), Is.False);
|
|
||||||
// Assert.That(c_szomszedai.Eleme(1), Is.False);
|
|
||||||
// Assert.That(c_szomszedai.Eleme(2), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "10 - Gráf Bejárás Tesztek")]
|
|
||||||
// public class GrafBejarasTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void SzelessegiBejarasTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozatlanEgeszGraf g = new CsucsmatrixSulyozatlanEgeszGraf(6);
|
|
||||||
// g.UjEl(0, 1);
|
|
||||||
// g.UjEl(1, 2);
|
|
||||||
// g.UjEl(1, 4);
|
|
||||||
// g.UjEl(2, 3);
|
|
||||||
// g.UjEl(2, 4);
|
|
||||||
// g.UjEl(4, 3);
|
|
||||||
// g.UjEl(3, 0);
|
|
||||||
|
|
||||||
// string ut = "";
|
|
||||||
// Halmaz<int> elertCsucsok = GrafBejarasok.SzelessegiBejaras(g, 0, (a) => { ut += a; });
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(ut == "01243" || ut == "01423", Is.True);
|
|
||||||
// for (int i = 0; i <= 4; i++)
|
|
||||||
// Assert.That(elertCsucsok.Eleme(i), Is.True);
|
|
||||||
// Assert.That(elertCsucsok.Eleme(6), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void MelysegiBejarasTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozatlanEgeszGraf g = new CsucsmatrixSulyozatlanEgeszGraf(6);
|
|
||||||
// g.UjEl(0, 1);
|
|
||||||
// g.UjEl(1, 2);
|
|
||||||
// g.UjEl(1, 4);
|
|
||||||
// g.UjEl(2, 3);
|
|
||||||
// g.UjEl(2, 4);
|
|
||||||
// g.UjEl(4, 3);
|
|
||||||
// g.UjEl(3, 0);
|
|
||||||
|
|
||||||
// string ut = "";
|
|
||||||
// Halmaz<int> elertCsucsok = GrafBejarasok.MelysegiBejaras(g, 0, (a) => { ut += a; });
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(ut == "01243" || ut == "01432" || ut == "01234", Is.True);
|
|
||||||
// for (int i = 0; i <= 4; i++)
|
|
||||||
// Assert.That(elertCsucsok.Eleme(i), Is.True);
|
|
||||||
// Assert.That(elertCsucsok.Eleme(6), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,240 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using System;
|
|
||||||
//using OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Adatszerkezetek
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "11 - Kupac Prioritásos Sor Tesztek")]
|
|
||||||
// public class KupacPrioritasosSorTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void TulSokElemTeszt()
|
|
||||||
// {
|
|
||||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(2, (x, y) => x > y);
|
|
||||||
// s.Sorba(1);
|
|
||||||
// s.Sorba(2);
|
|
||||||
// Assert.Throws<NincsHelyKivetel>(() => s.Sorba(3));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void TulKevesElemTeszt()
|
|
||||||
// {
|
|
||||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(5, (x, y) => x > y);
|
|
||||||
// s.Sorba(1);
|
|
||||||
// s.Sorba(2);
|
|
||||||
// s.Sorba(3);
|
|
||||||
// s.Sorbol();
|
|
||||||
// s.Sorbol();
|
|
||||||
// s.Sorbol();
|
|
||||||
// Assert.Throws<NincsElemKivetel>(() => s.Sorbol());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void UresTeszt()
|
|
||||||
// {
|
|
||||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(5, (x, y) => x > y);
|
|
||||||
// Assert.That(s.Ures, Is.True);
|
|
||||||
// s.Sorba(1);
|
|
||||||
// Assert.That(s.Ures, Is.False);
|
|
||||||
// s.Sorba(2);
|
|
||||||
// Assert.That(s.Ures, Is.False);
|
|
||||||
// s.Sorbol();
|
|
||||||
// Assert.That(s.Ures, Is.False);
|
|
||||||
// s.Elso();
|
|
||||||
// Assert.That(s.Ures, Is.False);
|
|
||||||
// s.Sorbol();
|
|
||||||
// Assert.That(s.Ures, Is.True);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void SorbaSorbolElsoTeszt()
|
|
||||||
// {
|
|
||||||
// PrioritasosSor<int> s = new KupacPrioritasosSor<int>(10, (x, y) => x > y);
|
|
||||||
// s.Sorba(1);
|
|
||||||
// s.Sorba(4);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(4));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(4));
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(1));
|
|
||||||
// });
|
|
||||||
// s.Sorba(4);
|
|
||||||
// s.Sorba(2);
|
|
||||||
// s.Sorba(8);
|
|
||||||
// s.Sorba(3);
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(8));
|
|
||||||
// s.Sorba(9);
|
|
||||||
// s.Sorba(5);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(9));
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(9));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(9));
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(8));
|
|
||||||
// });
|
|
||||||
// s.Sorba(7);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(8));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(7));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(5));
|
|
||||||
// });
|
|
||||||
// s.Sorba(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(4));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(3));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(2));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(2));
|
|
||||||
// Assert.That(s.Elso(), Is.EqualTo(1));
|
|
||||||
// Assert.That(s.Sorbol(), Is.EqualTo(1));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// class PrioritasosSzoveg : IComparable
|
|
||||||
// {
|
|
||||||
// public string Szoveg { get; set; }
|
|
||||||
// public float Prioritas { get; set; }
|
|
||||||
// public PrioritasosSzoveg(string szoveg, float prioritas)
|
|
||||||
// {
|
|
||||||
// this.Szoveg = szoveg;
|
|
||||||
// this.Prioritas = prioritas;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public int CompareTo(object? obj)
|
|
||||||
// {
|
|
||||||
// if (obj is not PrioritasosSzoveg o)
|
|
||||||
// throw new NullReferenceException();
|
|
||||||
// else
|
|
||||||
// return Prioritas.CompareTo(o.Prioritas);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void PrioritasValtozasTeszt()
|
|
||||||
// {
|
|
||||||
// PrioritasosSzoveg a = new PrioritasosSzoveg("a", 10.0f);
|
|
||||||
// PrioritasosSzoveg b = new PrioritasosSzoveg("b", 5.0f);
|
|
||||||
// PrioritasosSzoveg c = new PrioritasosSzoveg("c", 2.0f);
|
|
||||||
// PrioritasosSzoveg d = new PrioritasosSzoveg("d", 12.0f);
|
|
||||||
// PrioritasosSzoveg e = new PrioritasosSzoveg("e", 15.0f);
|
|
||||||
// PrioritasosSzoveg f = new PrioritasosSzoveg("f", 9.0f);
|
|
||||||
// PrioritasosSzoveg g = new PrioritasosSzoveg("g", 2.0f);
|
|
||||||
// PrioritasosSor<PrioritasosSzoveg> s = new KupacPrioritasosSor<PrioritasosSzoveg>(10, (x, y) => x.CompareTo(y) > 0);
|
|
||||||
// s.Sorba(a);
|
|
||||||
// s.Sorba(b);
|
|
||||||
// s.Sorba(c);
|
|
||||||
// s.Sorba(d);
|
|
||||||
// s.Sorba(e);
|
|
||||||
// Assert.That(s.Elso().Szoveg, Is.EqualTo("e"));
|
|
||||||
// d.Prioritas = 22.0f;
|
|
||||||
// s.Frissit(d);
|
|
||||||
// Assert.That(s.Elso().Szoveg, Is.EqualTo("d"));
|
|
||||||
// d.Prioritas = 8.0f;
|
|
||||||
// s.Frissit(d);
|
|
||||||
// e.Prioritas = 7.0f;
|
|
||||||
// s.Frissit(e);
|
|
||||||
// Assert.That(s.Sorbol().Szoveg, Is.EqualTo("a"));
|
|
||||||
// s.Sorba(f);
|
|
||||||
// s.Sorba(g);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Sorbol().Szoveg, Is.EqualTo("f"));
|
|
||||||
// Assert.That(s.Sorbol().Szoveg, Is.EqualTo("d"));
|
|
||||||
// Assert.That(s.Sorbol().Szoveg, Is.EqualTo("e"));
|
|
||||||
// Assert.That(s.Sorbol().Szoveg, Is.EqualTo("b"));
|
|
||||||
// });
|
|
||||||
// c.Prioritas = 1.5f;
|
|
||||||
// s.Frissit(c);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(s.Sorbol().Szoveg, Is.EqualTo("g"));
|
|
||||||
// Assert.That(s.Sorbol().Szoveg, Is.EqualTo("c"));
|
|
||||||
// Assert.That(s.Ures, Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "11 - Kupac Külső Fügvénnyel Tesztek")]
|
|
||||||
// public class KupacKulsoFuggvennyelTesztek
|
|
||||||
// {
|
|
||||||
// /// <summary>
|
|
||||||
// /// Nincs külön rendező függvény, ezért ABC sorrendben rendez az IComparable alapján.
|
|
||||||
// /// </summary>
|
|
||||||
// [TestCase]
|
|
||||||
// public void KupacEpitesIComparableAlapjan()
|
|
||||||
// {
|
|
||||||
// KupacPrioritasosSor<string> ps = new KupacPrioritasosSor<string>(10, (x, y) => x.CompareTo(y) > 0);
|
|
||||||
// ps.Sorba("oszibarack");
|
|
||||||
// ps.Sorba("alma");
|
|
||||||
// ps.Sorba("korte");
|
|
||||||
// ps.Sorba("birsalma");
|
|
||||||
// ps.Sorba("barack");
|
|
||||||
// ps.Sorba("dio");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("oszibarack"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("korte"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("dio"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("birsalma"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("barack"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("alma"));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// <summary>
|
|
||||||
// /// Van egy saját hossz alapú rendező függvény, ezért elsőként a leghosszabb stringeket adja vissza.
|
|
||||||
// /// </summary>
|
|
||||||
// [TestCase]
|
|
||||||
// public void KupacEpitesSajatFuggvennyel()
|
|
||||||
// {
|
|
||||||
// KupacPrioritasosSor<string> ps = new KupacPrioritasosSor<string>(10, (ez, ennel) => ez.Length > ennel.Length);
|
|
||||||
// ps.Sorba("oszibarack");
|
|
||||||
// ps.Sorba("alma");
|
|
||||||
// ps.Sorba("korte");
|
|
||||||
// ps.Sorba("birsalma");
|
|
||||||
// ps.Sorba("barack");
|
|
||||||
// ps.Sorba("dio");
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("oszibarack"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("birsalma"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("barack"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("korte"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("alma"));
|
|
||||||
// Assert.That(ps.Sorbol(), Is.EqualTo("dio"));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "11 - Kupac Rendezés Tesztek")]
|
|
||||||
// public class KupacRendezesTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void KupacEpites()
|
|
||||||
// {
|
|
||||||
// int[] A = [1, 3, 2, 4, 9, 12, 32, 21, 12, 8, 11];
|
|
||||||
// _ = new Kupac<int>(A, A.Length, (x, y) => x > y);
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// for (int i = 1; i < A.Length; i++)
|
|
||||||
// Assert.That(A[Kupac<int>.Szulo(i)] >= A[i], Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void KupacRendezes()
|
|
||||||
// {
|
|
||||||
// int[] A = [5, 8, 7, 0, 9, 6, 4, 1, 3, 2];
|
|
||||||
// KupacRendezes<int> k = new KupacRendezes<int>(A);
|
|
||||||
// k.Rendezes();
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// for (int i = 1; i < A.Length; i++)
|
|
||||||
// Assert.That(A[i], Is.EqualTo(i));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
//using NUnit.Framework;
|
|
||||||
//using OE.ALGA.Adatszerkezetek;
|
|
||||||
|
|
||||||
//namespace OE.ALGA.Tesztek.Adatszerkezetek
|
|
||||||
//{
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "12 - Csúcs Mátrix Súlyozott Gráf Tesztek")]
|
|
||||||
// public class CsucsMatrixSulyozottGrafTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void MindenCsucsTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(2);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(csg.Csucsok.Eleme(0), Is.True);
|
|
||||||
// Assert.That(csg.Csucsok.Eleme(1), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void MindenElTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1, 1.0f);
|
|
||||||
// csg.UjEl(0, 2, 2.0f);
|
|
||||||
// csg.UjEl(1, 2, 3.0f);
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(0, 0, 0.0f)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(0, 1, 1.0f)), Is.True);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(0, 2, 2.0f)), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(1, 0, 0.0f)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(1, 1, 0.0f)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(1, 2, 3.0f)), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(2, 0, 0.0f)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(2, 1, 0.0f)), Is.False);
|
|
||||||
// Assert.That(csg.Elek.Eleme(new SulyozottEgeszGrafEl(2, 2, 0.0f)), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void VezetElTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(2);
|
|
||||||
// Assert.That(csg.VezetEl(0, 1), Is.False);
|
|
||||||
// csg.UjEl(0, 1, 1.0f);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(csg.VezetEl(0, 1), Is.True);
|
|
||||||
// Assert.That(csg.VezetEl(1, 0), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void SzomszedsagTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1, 1.0f);
|
|
||||||
// csg.UjEl(0, 2, 1.0f);
|
|
||||||
// csg.UjEl(1, 2, 1.0f);
|
|
||||||
|
|
||||||
// Halmaz<int> a_szomszedai = csg.Szomszedai(0);
|
|
||||||
// Halmaz<int> b_szomszedai = csg.Szomszedai(1);
|
|
||||||
// Halmaz<int> c_szomszedai = csg.Szomszedai(2);
|
|
||||||
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(a_szomszedai.Eleme(0), Is.False);
|
|
||||||
// Assert.That(a_szomszedai.Eleme(1), Is.True);
|
|
||||||
// Assert.That(a_szomszedai.Eleme(2), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(b_szomszedai.Eleme(0), Is.False);
|
|
||||||
// Assert.That(b_szomszedai.Eleme(1), Is.False);
|
|
||||||
// Assert.That(b_szomszedai.Eleme(2), Is.True);
|
|
||||||
|
|
||||||
// Assert.That(c_szomszedai.Eleme(0), Is.False);
|
|
||||||
// Assert.That(c_szomszedai.Eleme(1), Is.False);
|
|
||||||
// Assert.That(c_szomszedai.Eleme(2), Is.False);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void NemLetezoElTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1, 1.0f);
|
|
||||||
// csg.UjEl(0, 2, 1.0f);
|
|
||||||
// Assert.Throws<NincsElKivetel>(() => csg.Suly(1, 0));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void ElSulyTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1, 2.0f);
|
|
||||||
// csg.UjEl(0, 2, 3.0f);
|
|
||||||
// float szum = 0.0f;
|
|
||||||
// csg.Elek.Bejar(x => szum += csg.Suly(x.Honnan, x.Hova));
|
|
||||||
// Assert.That(szum, Is.EqualTo(5.0f));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "12 - Gráf Min Feszítőfa Tesztek")]
|
|
||||||
// public class GrafMinFeszitofaTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void KisPrimTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1, 10.0f);
|
|
||||||
// csg.UjEl(0, 2, 20.0f);
|
|
||||||
// csg.UjEl(1, 2, 5.0f);
|
|
||||||
// Szotar<int, int> elek = FeszitofaKereses.Prim(csg, 0);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(elek.Kiolvas(1), Is.EqualTo(0));
|
|
||||||
// Assert.That(elek.Kiolvas(2), Is.EqualTo(1));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyPrimTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(5);
|
|
||||||
// csg.UjEl(0, 1, 5.0f);
|
|
||||||
// csg.UjEl(0, 3, 4.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(1, 0, 5.0f);
|
|
||||||
// csg.UjEl(1, 3, 2.0f);
|
|
||||||
// csg.UjEl(1, 2, 1.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(2, 1, 1.0f);
|
|
||||||
// csg.UjEl(2, 3, 3.0f);
|
|
||||||
// csg.UjEl(2, 4, 4.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(3, 0, 4.0f);
|
|
||||||
// csg.UjEl(3, 1, 2.0f);
|
|
||||||
// csg.UjEl(3, 2, 3.0f);
|
|
||||||
// csg.UjEl(3, 4, 1.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(4, 2, 4.0f);
|
|
||||||
// csg.UjEl(4, 3, 1.0f);
|
|
||||||
|
|
||||||
// Szotar<int, int> elek = FeszitofaKereses.Prim(csg, 0);
|
|
||||||
// float sum = 0.0f;
|
|
||||||
// csg.Csucsok.Bejar(x =>
|
|
||||||
// {
|
|
||||||
// if (x != 0)
|
|
||||||
// {
|
|
||||||
// int p = elek.Kiolvas(x);
|
|
||||||
// sum += csg.Suly(p, x);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// Assert.That(sum, Is.EqualTo(8.0f));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void KisKruskalTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1, 10.0f);
|
|
||||||
// csg.UjEl(0, 2, 20.0f);
|
|
||||||
// csg.UjEl(1, 2, 5.0f);
|
|
||||||
// Halmaz<SulyozottEgeszGrafEl> elek = FeszitofaKereses.Kruskal(csg);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(elek.Eleme(new SulyozottEgeszGrafEl(0, 1, 10.0f)), Is.True);
|
|
||||||
// Assert.That(elek.Eleme(new SulyozottEgeszGrafEl(0, 2, 20.0f)), Is.False);
|
|
||||||
// Assert.That(elek.Eleme(new SulyozottEgeszGrafEl(1, 2, 5.0f)), Is.True);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void NagyKruskalTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(5);
|
|
||||||
// csg.UjEl(0, 1, 5.0f);
|
|
||||||
// csg.UjEl(0, 3, 4.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(1, 0, 5.0f);
|
|
||||||
// csg.UjEl(1, 3, 2.0f);
|
|
||||||
// csg.UjEl(1, 2, 1.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(2, 1, 1.0f);
|
|
||||||
// csg.UjEl(2, 3, 3.0f);
|
|
||||||
// csg.UjEl(2, 4, 4.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(3, 0, 4.0f);
|
|
||||||
// csg.UjEl(3, 1, 2.0f);
|
|
||||||
// csg.UjEl(3, 2, 3.0f);
|
|
||||||
// csg.UjEl(3, 4, 1.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(4, 2, 4.0f);
|
|
||||||
// csg.UjEl(4, 3, 1.0f);
|
|
||||||
|
|
||||||
// Halmaz<SulyozottEgeszGrafEl> elek = FeszitofaKereses.Kruskal(csg);
|
|
||||||
// float sum = 0.0f;
|
|
||||||
// elek.Bejar(x =>
|
|
||||||
// {
|
|
||||||
// sum += x.Suly;
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// Assert.That(sum, Is.EqualTo(8.0f));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestFixture(Category = "Adatszerkezetek", TestName = "12 - Gráf Útkeresés Tesztek")]
|
|
||||||
// public class GrafUtkeresesTesztek
|
|
||||||
// {
|
|
||||||
// [TestCase]
|
|
||||||
// public void DijkstraKicsiGrafTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(3);
|
|
||||||
// csg.UjEl(0, 1, 10.0f);
|
|
||||||
// csg.UjEl(0, 2, 20.0f);
|
|
||||||
// Szotar<int, float> hossz = Utkereses.Dijkstra(csg, 0);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(hossz.Kiolvas(0), Is.EqualTo(0.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(1), Is.EqualTo(10.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(2), Is.EqualTo(20.0f));
|
|
||||||
// });
|
|
||||||
|
|
||||||
// csg.UjEl(1, 2, 5.0f);
|
|
||||||
// hossz = Utkereses.Dijkstra(csg, 0);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(hossz.Kiolvas(0), Is.EqualTo(0.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(1), Is.EqualTo(10.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(2), Is.EqualTo(15.0f));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [TestCase]
|
|
||||||
// public void DijkstraJegyzetGrafTeszt()
|
|
||||||
// {
|
|
||||||
// CsucsmatrixSulyozottEgeszGraf csg = new CsucsmatrixSulyozottEgeszGraf(7);
|
|
||||||
// csg.UjEl(0, 1, 1.0f);
|
|
||||||
// csg.UjEl(0, 3, 2.0f);
|
|
||||||
// csg.UjEl(0, 4, 4.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(1, 0, 1.0f);
|
|
||||||
// csg.UjEl(1, 3, 2.0f);
|
|
||||||
// csg.UjEl(1, 2, 9.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(2, 1, 9.0f);
|
|
||||||
// csg.UjEl(2, 3, 5.0f);
|
|
||||||
// csg.UjEl(2, 5, 1.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(3, 0, 2.0f);
|
|
||||||
// csg.UjEl(3, 1, 2.0f);
|
|
||||||
// csg.UjEl(3, 2, 5.0f);
|
|
||||||
// csg.UjEl(3, 5, 3.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(5, 2, 1.0f);
|
|
||||||
// csg.UjEl(5, 3, 3.0f);
|
|
||||||
// csg.UjEl(5, 6, 3.0f);
|
|
||||||
|
|
||||||
// csg.UjEl(6, 5, 3.0f);
|
|
||||||
|
|
||||||
// Szotar<int, float> hossz = Utkereses.Dijkstra(csg, 1);
|
|
||||||
// Assert.Multiple(() =>
|
|
||||||
// {
|
|
||||||
// Assert.That(hossz.Kiolvas(0), Is.EqualTo(1.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(1), Is.EqualTo(0.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(2), Is.EqualTo(6.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(3), Is.EqualTo(2.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(4), Is.EqualTo(5.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(5), Is.EqualTo(5.0f));
|
|
||||||
// Assert.That(hossz.Kiolvas(6), Is.EqualTo(8.0f));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
## Duplikált tesztek a Test Explorer-ben
|
|
||||||
Az **NUnit 3 VS Test Adapter** ismert hibája, hogy amennyiben a *TestFixture*-be a *TestName* értéket kap, akkor a **Test Explorer**-ben kétszer fognak megjelenni a tesztek.
|
|
||||||
Issue: https://github.com/nunit/nunit3-vs-adapter/issues/729
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
<IsTestProject>true</IsTestProject>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
|
||||||
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.14.2" />
|
|
||||||
<PackageReference Include="MSTest" Version="3.10.4" />
|
|
||||||
<PackageReference Include="NUnit" Version="4.4.0" />
|
|
||||||
<PackageReference Include="NUnit.Analyzers" Version="4.10.0">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\ALGA\ALGA.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Using Include="NUnit.Framework" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,225 +1,226 @@
|
|||||||
// using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
// using OE.ALGA.Adatszerkezetek;
|
using OE.ALGA.Adatszerkezetek;
|
||||||
//
|
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
|
||||||
// namespace OE.ALGA.Tesztek
|
|
||||||
// {
|
namespace OE.ALGA.Tesztek
|
||||||
// [TestClass()]
|
{
|
||||||
// public class LancoltVeremTesztek
|
[TestClass()]
|
||||||
// {
|
public class LancoltVeremTesztek
|
||||||
// [TestMethod()]
|
{
|
||||||
// public void MindenJolMukodik() //F2.
|
[TestMethod()]
|
||||||
// {
|
public void MindenJolMukodik() //F2.
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
{
|
||||||
// v.Verembe(1);
|
Verem<int> v = new LancoltVerem<int>();
|
||||||
// v.Verembe(3);
|
v.Verembe(1);
|
||||||
// v.Verembe(2);
|
v.Verembe(3);
|
||||||
// Assert.AreEqual(2, v.Verembol());
|
v.Verembe(2);
|
||||||
// v.Verembe(4);
|
Assert.AreEqual(2, v.Verembol());
|
||||||
// Assert.AreEqual(4, v.Verembol());
|
v.Verembe(4);
|
||||||
// Assert.AreEqual(3, v.Verembol());
|
Assert.AreEqual(4, v.Verembol());
|
||||||
// Assert.AreEqual(1, v.Verembol());
|
Assert.AreEqual(3, v.Verembol());
|
||||||
// }
|
Assert.AreEqual(1, v.Verembol());
|
||||||
//
|
}
|
||||||
// [TestMethod()]
|
|
||||||
// [ExpectedException(typeof(NincsElemKivetel))]
|
[TestMethod()]
|
||||||
// public void TulKevesElem() //F2.
|
[ExpectedException(typeof(NincsElemKivetel))]
|
||||||
// {
|
public void TulKevesElem() //F2.
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
{
|
||||||
// v.Verembe(1);
|
Verem<int> v = new LancoltVerem<int>();
|
||||||
// v.Verembe(3);
|
v.Verembe(1);
|
||||||
// v.Verembe(2);
|
v.Verembe(3);
|
||||||
// v.Verembol();
|
v.Verembe(2);
|
||||||
// v.Verembol();
|
v.Verembol();
|
||||||
// v.Verembol();
|
v.Verembol();
|
||||||
// v.Verembol();
|
v.Verembol();
|
||||||
// }
|
v.Verembol();
|
||||||
//
|
}
|
||||||
// [TestMethod()]
|
|
||||||
// public void Felso() //F2.
|
[TestMethod()]
|
||||||
// {
|
public void Felso() //F2.
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
{
|
||||||
// v.Verembe(1);
|
Verem<int> v = new LancoltVerem<int>();
|
||||||
// v.Verembe(3);
|
v.Verembe(1);
|
||||||
// v.Verembe(2);
|
v.Verembe(3);
|
||||||
// Assert.AreEqual(2, v.Felso());
|
v.Verembe(2);
|
||||||
// Assert.AreEqual(2, v.Felso());
|
Assert.AreEqual(2, v.Felso());
|
||||||
// v.Verembol();
|
Assert.AreEqual(2, v.Felso());
|
||||||
// Assert.AreEqual(3, v.Felso());
|
v.Verembol();
|
||||||
// }
|
Assert.AreEqual(3, v.Felso());
|
||||||
//
|
}
|
||||||
// [TestMethod()]
|
|
||||||
// public void Ures() //F2.
|
[TestMethod()]
|
||||||
// {
|
public void Ures() //F2.
|
||||||
// Verem<int> v = new LancoltVerem<int>();
|
{
|
||||||
// Assert.IsTrue(v.Ures);
|
Verem<int> v = new LancoltVerem<int>();
|
||||||
// v.Verembe(1);
|
Assert.IsTrue(v.Ures);
|
||||||
// Assert.IsFalse(v.Ures);
|
v.Verembe(1);
|
||||||
// v.Verembol();
|
Assert.IsFalse(v.Ures);
|
||||||
// Assert.IsTrue(v.Ures);
|
v.Verembol();
|
||||||
// }
|
Assert.IsTrue(v.Ures);
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// [TestClass()]
|
|
||||||
// public class LancoltSorTesztek
|
[TestClass()]
|
||||||
// {
|
public class LancoltSorTesztek
|
||||||
// [TestMethod()]
|
{
|
||||||
// public void AlapMukodes() //F3.
|
[TestMethod()]
|
||||||
// {
|
public void AlapMukodes() //F3.
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
{
|
||||||
// s.Sorba(1);
|
Sor<int> s = new LancoltSor<int>();
|
||||||
// s.Sorba(3);
|
s.Sorba(1);
|
||||||
// s.Sorba(2);
|
s.Sorba(3);
|
||||||
// Assert.AreEqual(1, s.Sorbol());
|
s.Sorba(2);
|
||||||
// Assert.AreEqual(3, s.Sorbol());
|
Assert.AreEqual(1, s.Sorbol());
|
||||||
// Assert.AreEqual(2, s.Sorbol());
|
Assert.AreEqual(3, s.Sorbol());
|
||||||
// }
|
Assert.AreEqual(2, s.Sorbol());
|
||||||
//
|
}
|
||||||
// [TestMethod()]
|
|
||||||
// [ExpectedException(typeof(NincsElemKivetel))]
|
[TestMethod()]
|
||||||
// public void TulKevesElem() //F3.
|
[ExpectedException(typeof(NincsElemKivetel))]
|
||||||
// {
|
public void TulKevesElem() //F3.
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
{
|
||||||
// s.Sorba(1);
|
Sor<int> s = new LancoltSor<int>();
|
||||||
// s.Sorba(3);
|
s.Sorba(1);
|
||||||
// s.Sorba(2);
|
s.Sorba(3);
|
||||||
// s.Sorbol();
|
s.Sorba(2);
|
||||||
// s.Sorbol();
|
s.Sorbol();
|
||||||
// s.Sorbol();
|
s.Sorbol();
|
||||||
// s.Sorbol();
|
s.Sorbol();
|
||||||
// }
|
s.Sorbol();
|
||||||
//
|
}
|
||||||
// [TestMethod()]
|
|
||||||
// public void Elso() //F3.
|
[TestMethod()]
|
||||||
// {
|
public void Elso() //F3.
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
{
|
||||||
// s.Sorba(1);
|
Sor<int> s = new LancoltSor<int>();
|
||||||
// s.Sorba(3);
|
s.Sorba(1);
|
||||||
// s.Sorba(2);
|
s.Sorba(3);
|
||||||
// Assert.AreEqual(1, s.Elso());
|
s.Sorba(2);
|
||||||
// Assert.AreEqual(1, s.Elso());
|
Assert.AreEqual(1, s.Elso());
|
||||||
// s.Sorbol();
|
Assert.AreEqual(1, s.Elso());
|
||||||
// Assert.AreEqual(3, s.Elso());
|
s.Sorbol();
|
||||||
// }
|
Assert.AreEqual(3, s.Elso());
|
||||||
//
|
}
|
||||||
// [TestMethod()]
|
|
||||||
// public void Ures() //F3.
|
[TestMethod()]
|
||||||
// {
|
public void Ures() //F3.
|
||||||
// Sor<int> s = new LancoltSor<int>();
|
{
|
||||||
// Assert.IsTrue(s.Ures);
|
Sor<int> s = new LancoltSor<int>();
|
||||||
// s.Sorba(1);
|
Assert.IsTrue(s.Ures);
|
||||||
// Assert.IsFalse(s.Ures);
|
s.Sorba(1);
|
||||||
// s.Sorbol();
|
Assert.IsFalse(s.Ures);
|
||||||
// Assert.IsTrue(s.Ures);
|
s.Sorbol();
|
||||||
// }
|
Assert.IsTrue(s.Ures);
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// [TestClass]
|
|
||||||
// public class LancoltListaTesztek
|
[TestClass]
|
||||||
// {
|
public class LancoltListaTesztek
|
||||||
// [TestMethod]
|
{
|
||||||
// public void Bejaras() //F4.
|
[TestMethod]
|
||||||
// {
|
public void Bejaras() //F4.
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
{
|
||||||
// l.Hozzafuz(1);
|
Lista<int> l = new LancoltLista<int>();
|
||||||
// l.Hozzafuz(3);
|
l.Hozzafuz(1);
|
||||||
// l.Hozzafuz(2);
|
l.Hozzafuz(3);
|
||||||
// string s = "";
|
l.Hozzafuz(2);
|
||||||
// l.Bejar(x => s += x.ToString());
|
string s = "";
|
||||||
// Assert.AreEqual("132", s);
|
l.Bejar(x => s += x.ToString());
|
||||||
// }
|
Assert.AreEqual("132", s);
|
||||||
//
|
}
|
||||||
// [TestMethod]
|
|
||||||
// public void HozzaFuzes() //F4.
|
[TestMethod]
|
||||||
// {
|
public void HozzaFuzes() //F4.
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
{
|
||||||
// l.Hozzafuz(1);
|
Lista<int> l = new LancoltLista<int>();
|
||||||
// l.Hozzafuz(3);
|
l.Hozzafuz(1);
|
||||||
// l.Hozzafuz(2);
|
l.Hozzafuz(3);
|
||||||
// Assert.AreEqual(1, l.Kiolvas(0));
|
l.Hozzafuz(2);
|
||||||
// Assert.AreEqual(3, l.Kiolvas(1));
|
Assert.AreEqual(1, l.Kiolvas(0));
|
||||||
// Assert.AreEqual(2, l.Kiolvas(2));
|
Assert.AreEqual(3, l.Kiolvas(1));
|
||||||
// }
|
Assert.AreEqual(2, l.Kiolvas(2));
|
||||||
//
|
}
|
||||||
// [TestMethod]
|
|
||||||
// public void Meret() //F4.
|
[TestMethod]
|
||||||
// {
|
public void Meret() //F4.
|
||||||
// Lista<string> l = new LancoltLista<string>();
|
{
|
||||||
// Assert.AreEqual(0, l.Elemszam);
|
Lista<string> l = new LancoltLista<string>();
|
||||||
// l.Hozzafuz("A");
|
Assert.AreEqual(0, l.Elemszam);
|
||||||
// Assert.AreEqual(1, l.Elemszam);
|
l.Hozzafuz("A");
|
||||||
// l.Hozzafuz("B");
|
Assert.AreEqual(1, l.Elemszam);
|
||||||
// Assert.AreEqual(2, l.Elemszam);
|
l.Hozzafuz("B");
|
||||||
// }
|
Assert.AreEqual(2, l.Elemszam);
|
||||||
//
|
}
|
||||||
// [TestMethod]
|
|
||||||
// public void Novekedes() //F4.
|
[TestMethod]
|
||||||
// {
|
public void Novekedes() //F4.
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
{
|
||||||
// for (int i = 0; i < 1000; i++)
|
Lista<int> l = new LancoltLista<int>();
|
||||||
// l.Hozzafuz(i * i);
|
for (int i = 0; i < 1000; i++)
|
||||||
// for (int i = 0; i < 1000; i++)
|
l.Hozzafuz(i * i);
|
||||||
// Assert.AreEqual(i * i, l.Kiolvas(i));
|
for (int i = 0; i < 1000; i++)
|
||||||
// }
|
Assert.AreEqual(i * i, l.Kiolvas(i));
|
||||||
//
|
}
|
||||||
// [TestMethod]
|
|
||||||
// public void Beszuras() //F4.
|
[TestMethod]
|
||||||
// {
|
public void Beszuras() //F4.
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
{
|
||||||
// l.Beszur(0, 1);
|
Lista<int> l = new LancoltLista<int>();
|
||||||
// l.Beszur(0, 2);
|
l.Beszur(0, 1);
|
||||||
// l.Beszur(1, 3);
|
l.Beszur(0, 2);
|
||||||
// l.Beszur(3, 4);
|
l.Beszur(1, 3);
|
||||||
// l.Beszur(2, 5);
|
l.Beszur(3, 4);
|
||||||
// Assert.AreEqual(2, l.Kiolvas(0));
|
l.Beszur(2, 5);
|
||||||
// Assert.AreEqual(3, l.Kiolvas(1));
|
Assert.AreEqual(2, l.Kiolvas(0));
|
||||||
// Assert.AreEqual(5, l.Kiolvas(2));
|
Assert.AreEqual(3, l.Kiolvas(1));
|
||||||
// Assert.AreEqual(1, l.Kiolvas(3));
|
Assert.AreEqual(5, l.Kiolvas(2));
|
||||||
// Assert.AreEqual(4, l.Kiolvas(4));
|
Assert.AreEqual(1, l.Kiolvas(3));
|
||||||
// }
|
Assert.AreEqual(4, l.Kiolvas(4));
|
||||||
//
|
}
|
||||||
// [TestMethod]
|
|
||||||
// public void Torles() //F4.
|
[TestMethod]
|
||||||
// {
|
public void Torles() //F4.
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
{
|
||||||
// l.Hozzafuz(1);
|
Lista<int> l = new LancoltLista<int>();
|
||||||
// l.Hozzafuz(3);
|
l.Hozzafuz(1);
|
||||||
// l.Hozzafuz(2);
|
l.Hozzafuz(3);
|
||||||
// l.Hozzafuz(3);
|
l.Hozzafuz(2);
|
||||||
// l.Hozzafuz(4);
|
l.Hozzafuz(3);
|
||||||
// l.Torol(3);
|
l.Hozzafuz(4);
|
||||||
// Assert.AreEqual(1, l.Kiolvas(0));
|
l.Torol(3);
|
||||||
// Assert.AreEqual(2, l.Kiolvas(1));
|
Assert.AreEqual(1, l.Kiolvas(0));
|
||||||
// Assert.AreEqual(4, l.Kiolvas(2));
|
Assert.AreEqual(2, l.Kiolvas(1));
|
||||||
// }
|
Assert.AreEqual(4, l.Kiolvas(2));
|
||||||
//
|
}
|
||||||
// [TestMethod]
|
|
||||||
// public void Modositas() //F4.
|
[TestMethod]
|
||||||
// {
|
public void Modositas() //F4.
|
||||||
// Lista<int> l = new LancoltLista<int>();
|
{
|
||||||
// l.Hozzafuz(1);
|
Lista<int> l = new LancoltLista<int>();
|
||||||
// l.Hozzafuz(3);
|
l.Hozzafuz(1);
|
||||||
// l.Hozzafuz(2);
|
l.Hozzafuz(3);
|
||||||
// l.Modosit(1, 5);
|
l.Hozzafuz(2);
|
||||||
// l.Modosit(0, 4);
|
l.Modosit(1, 5);
|
||||||
// Assert.AreEqual(4, l.Kiolvas(0));
|
l.Modosit(0, 4);
|
||||||
// Assert.AreEqual(5, l.Kiolvas(1));
|
Assert.AreEqual(4, l.Kiolvas(0));
|
||||||
// Assert.AreEqual(2, l.Kiolvas(2));
|
Assert.AreEqual(5, l.Kiolvas(1));
|
||||||
// }
|
Assert.AreEqual(2, l.Kiolvas(2));
|
||||||
//
|
}
|
||||||
// [TestMethod]
|
|
||||||
// public void ForeachBejaras() //F5.
|
[TestMethod]
|
||||||
// {
|
public void ForeachBejaras() //F5.
|
||||||
// LancoltLista<string> l = new LancoltLista<string>();
|
{
|
||||||
// l.Hozzafuz("a");
|
LancoltLista<string> l = new LancoltLista<string>();
|
||||||
// l.Hozzafuz("c");
|
l.Hozzafuz("a");
|
||||||
// l.Hozzafuz("d");
|
l.Hozzafuz("c");
|
||||||
// l.Hozzafuz("b");
|
l.Hozzafuz("d");
|
||||||
// string osszefuzo = "";
|
l.Hozzafuz("b");
|
||||||
// foreach (string x in l)
|
string osszefuzo = "";
|
||||||
// {
|
foreach (string x in l)
|
||||||
// osszefuzo += x;
|
{
|
||||||
// }
|
osszefuzo += x;
|
||||||
// Assert.AreEqual("acdb", osszefuzo);
|
}
|
||||||
// }
|
Assert.AreEqual("acdb", osszefuzo);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user