diff --git a/ALGA_heti_feladatok/.editorconfig b/ALGA_heti_feladatok/.editorconfig new file mode 100644 index 0000000..01ab030 --- /dev/null +++ b/ALGA_heti_feladatok/.editorconfig @@ -0,0 +1,6 @@ +[*.cs] + +dotnet_diagnostic.IDE1006.severity = none +dotnet_diagnostic.IDE0090.severity = none +dotnet_diagnostic.IDE0290.severity = none +dotnet_diagnostic.CA1859.severity = none diff --git a/ALGA_heti_feladatok/.gitattributes b/ALGA_heti_feladatok/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/ALGA_heti_feladatok/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# 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 diff --git a/ALGA_heti_feladatok/.gitignore b/ALGA_heti_feladatok/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/ALGA_heti_feladatok/.gitignore @@ -0,0 +1,363 @@ +## 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 \ No newline at end of file diff --git a/ALGA_heti_feladatok/ALGA/03_Tomb.cs b/ALGA_heti_feladatok/ALGA/03_Tomb.cs new file mode 100644 index 0000000..dd51b19 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/03_Tomb.cs @@ -0,0 +1,274 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace OE.ALGA.Adatszerkezetek +{ + public class TombVerem : Verem + { + 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 : Sor + { + 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 : Lista, IEnumerable + { + 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 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 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 bejaro = new TombListaBejaro(tomb, n); + return bejaro; + } + } + public class TombListaBejaro : IEnumerator + { + 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; + } + } +} \ No newline at end of file diff --git a/ALGA_heti_feladatok/ALGA/04_EgyszeruLanc.cs b/ALGA_heti_feladatok/ALGA/04_EgyszeruLanc.cs new file mode 100644 index 0000000..7cb71cd --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/04_EgyszeruLanc.cs @@ -0,0 +1,193 @@ +using System; +using System.Runtime.CompilerServices; + +namespace OE.ALGA.Adatszerkezetek; + +public class LancElem +{ + public T tart; + public LancElem? kov; + public LancElem? elozo; + + public LancElem(T tart, LancElem? kov, LancElem? elozo) + { + this.tart = tart; + this.kov = kov; + this.elozo = elozo; + } +} +public class LancoltVerem : Verem +{ + LancElem? fej; + LancElem? teteje; + public LancoltVerem() + { + } + public void Felszabadit() + { + + } + public bool Ures + { + get { return fej == null; } + } + + public T Felso() + { + if (Ures) + { + throw new NincsElemKivetel(); + } + else + { + LancElem? tmp = fej; + while (tmp.kov != null) + { + tmp = tmp.kov; + } + teteje = tmp; + return tmp.tart; + } + } + + public void Verembe(T ertek) + { + if (Ures) + { + fej.kov = new LancElem(ertek, null, fej); + } + else + { + teteje.kov = new LancElem(ertek, null, teteje); + } + } + + public T Verembol() + { + if (Ures) + { + throw new NincsElemKivetel(); + } + else + { + T ertek = Felso(); + teteje.elozo.kov = null; + return ertek; + } + } +} +public class LancoltSor : Sor +{ + LancElem? fej; + LancElem? vege; + public bool Ures + { + get { return (fej == null && vege == null); } + } + public LancoltSor() + { + + } + public void Felszabadit() + { + + } + public T Elso() + { + return fej.tart; + } + + public void Sorba(T ertek) + { + if (Ures) + { + fej.tart = ertek; + } + else + { + LancElem? tmp = fej; + while (tmp.kov != null) + { + tmp = tmp.kov; + } + tmp.kov = new LancElem(ertek, null, tmp); + vege = tmp.kov; + } + } + + public T Sorbol() + { + if (Ures) + { + throw new NincsElemKivetel(); + } + else + { + T ertek = vege.tart; + vege = vege.elozo; + vege.kov = null; + return ertek; + } + } +} +public class LancoltLista : Lista +{ + int n; + LancElem? fej; + + public int Elemszam + { + get { return n; } + } + public LancoltLista() + { + + } + public void Felszabadit() + { + + } + + public void Bejar(Action muvelet) + { + throw new NotImplementedException(); + } + + public void Beszur(int index, T ertek) + { + LancElem? xd = Indexedik(index).elozo; + xd.kov = new LancElem(ertek, Indexedik(index), xd); + n++; + } + + public void Hozzafuz(T ertek) + { + LancElem asd = Indexedik(n); + asd.kov = new LancElem(ertek, null, asd); + n++; + } + + public T Kiolvas(int index) + { + return Indexedik(index).tart; + } + + public void Modosit(int index, T ertek) + { + Indexedik(index).tart = ertek; + } + + public void Torol(T ertek) + { + //ez gonixd + } + private LancElem Indexedik(int index) + { + LancElem? tmp = fej; + for (int i = 0; i < index; i++) + { + tmp = tmp.kov; + } + return tmp; + } +} diff --git a/ALGA_heti_feladatok/ALGA/ADT.cs b/ALGA_heti_feladatok/ALGA/ADT.cs new file mode 100644 index 0000000..4bba337 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/ADT.cs @@ -0,0 +1,113 @@ +using System; + +namespace OE.ALGA +{ + public interface Lista + { + 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 muvelet); + } + + public interface Halmaz + { + public void Beszur(T ertek); + public bool Eleme(T ertek); + public void Torol(T ertek); + public void Bejar(Action muvelet); + } + + public interface Verem + { + bool Ures { get; } + void Verembe(T ertek); + T Verembol(); + T Felso(); + } + + public interface Sor + { + bool Ures { get; } + void Sorba(T ertek); + T Sorbol(); + T Elso(); + } + + public interface PrioritasosSor + { + bool Ures { get; } + void Sorba(T ertek); + T Sorbol(); + T Elso(); + void Frissit(T elem); + } + + public interface GrafEl + { + V Honnan { get; } + V Hova { get; } + } + + public interface Graf + { + int CsucsokSzama { get; } + int ElekSzama { get; } + Halmaz Csucsok { get; } + Halmaz Elek { get; } + bool VezetEl(V honnan, V hova); + Halmaz Szomszedai(V csucs); + } + + public interface SulyozatlanGraf : Graf + { + void UjEl(V honnan, V hova); + } + + public interface SulyozottGrafEl : GrafEl + { + float Suly { get; } + } + + public interface SulyozottGraf : Graf + { + void UjEl(V honnan, V hova, float suly); + float Suly(V honnan, V hova); + } + + public interface Szotar + { + 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 + { + } + +} diff --git a/ALGA_heti_feladatok/ALGA/ALGA.csproj b/ALGA_heti_feladatok/ALGA/ALGA.csproj new file mode 100644 index 0000000..572d7c4 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/ALGA.csproj @@ -0,0 +1,10 @@ + + + + net8.0 + disable + enable + OE.ALGA + + + diff --git a/ALGA_heti_feladatok/ALGA/Adatszerkezetek/03_TombImplementacio.cs b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/03_TombImplementacio.cs new file mode 100644 index 0000000..ac3f62b --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/03_TombImplementacio.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace OE.ALGA.Adatszerkezetek +{ + // 3. heti labor feladat - Tesztek: 03_TombImplementacioTesztek.cs +} diff --git a/ALGA_heti_feladatok/ALGA/Adatszerkezetek/04_LancoltImplementacio.cs b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/04_LancoltImplementacio.cs new file mode 100644 index 0000000..6c3a8c4 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/04_LancoltImplementacio.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace OE.ALGA.Adatszerkezetek +{ + // 4. heti labor feladat - Tesztek: 04_LancoltImplementacioTesztek.cs +} \ No newline at end of file diff --git a/ALGA_heti_feladatok/ALGA/Adatszerkezetek/05_BinarisKeresoFa.cs b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/05_BinarisKeresoFa.cs new file mode 100644 index 0000000..26d2ea6 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/05_BinarisKeresoFa.cs @@ -0,0 +1,6 @@ +using System; + +namespace OE.ALGA.Adatszerkezetek +{ + // 5. heti labor feladat - Tesztek: 05_BinarisKeresoFaTesztek.cs +} diff --git a/ALGA_heti_feladatok/ALGA/Adatszerkezetek/06_Szotar.cs b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/06_Szotar.cs new file mode 100644 index 0000000..095456c --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/06_Szotar.cs @@ -0,0 +1,6 @@ +using System; + +namespace OE.ALGA.Adatszerkezetek +{ + // 6. heti labor feladat - Tesztek: 06_SzotarTesztek.cs +} diff --git a/ALGA_heti_feladatok/ALGA/Adatszerkezetek/10_SulyozotlanGraf.cs b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/10_SulyozotlanGraf.cs new file mode 100644 index 0000000..ccd32ec --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/10_SulyozotlanGraf.cs @@ -0,0 +1,6 @@ +using System; + +namespace OE.ALGA.Adatszerkezetek +{ + // 10. heti labor feladat - Tesztek: 10_SulyozatlanGrafTesztek.cs +} \ No newline at end of file diff --git a/ALGA_heti_feladatok/ALGA/Adatszerkezetek/11_Kupac.cs b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/11_Kupac.cs new file mode 100644 index 0000000..89a1058 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/11_Kupac.cs @@ -0,0 +1,6 @@ +using System; + +namespace OE.ALGA.Adatszerkezetek +{ + // 11. heti labor feladat - Tesztek: 11_KupacTesztek.cs +} \ No newline at end of file diff --git a/ALGA_heti_feladatok/ALGA/Adatszerkezetek/12_SulyozottGraf.cs b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/12_SulyozottGraf.cs new file mode 100644 index 0000000..38080ee --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Adatszerkezetek/12_SulyozottGraf.cs @@ -0,0 +1,6 @@ +using System; + +namespace OE.ALGA.Adatszerkezetek +{ + // 12. heti labor feladat - Tesztek: 12_SulyozottGrafTesztek.cs +} diff --git a/ALGA_heti_feladatok/ALGA/Class1.cs b/ALGA_heti_feladatok/ALGA/Class1.cs new file mode 100644 index 0000000..8649e9b --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Class1.cs @@ -0,0 +1,92 @@ +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 Students { get; set; } + Func Condition { get; set; } + + public Exam(string subject, DateTime date, int maxseats, List students, Func 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 logs; + + public ExamNotifier(string date) + { + logs = new List(); + 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); + } + } +} diff --git a/ALGA_heti_feladatok/ALGA/Class2.cs b/ALGA_heti_feladatok/ALGA/Class2.cs new file mode 100644 index 0000000..533a02f --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Class2.cs @@ -0,0 +1,63 @@ +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 evets; + int key; + ToDoService todos; + public User(int key) + { + evets = new List(); + 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); + } +} diff --git a/ALGA_heti_feladatok/ALGA/Class3.cs b/ALGA_heti_feladatok/ALGA/Class3.cs new file mode 100644 index 0000000..a9b2c12 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Class3.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace OE.ALGA; + +public class Cars +{ + List cars = new List + { + 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 bybrand = new Dictionary(); + 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 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; + } + } +} diff --git a/ALGA_heti_feladatok/ALGA/Optimalizalas/07_NyersEro.cs b/ALGA_heti_feladatok/ALGA/Optimalizalas/07_NyersEro.cs new file mode 100644 index 0000000..db5d73a --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Optimalizalas/07_NyersEro.cs @@ -0,0 +1,6 @@ +using System; + +namespace OE.ALGA.Optimalizalas +{ + // 7. heti labor feladat - Tesztek: 07_NyersEroTesztek.cs +} diff --git a/ALGA_heti_feladatok/ALGA/Optimalizalas/08_DinamikusProgramozas.cs b/ALGA_heti_feladatok/ALGA/Optimalizalas/08_DinamikusProgramozas.cs new file mode 100644 index 0000000..fd97afc --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Optimalizalas/08_DinamikusProgramozas.cs @@ -0,0 +1,4 @@ +namespace OE.ALGA.Optimalizalas +{ + // 8. heti labor feladat - Tesztek: 08_DinamikusProgramozasTesztek.cs +} diff --git a/ALGA_heti_feladatok/ALGA/Optimalizalas/09_VisszalepesesKereses.cs b/ALGA_heti_feladatok/ALGA/Optimalizalas/09_VisszalepesesKereses.cs new file mode 100644 index 0000000..ea8a489 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Optimalizalas/09_VisszalepesesKereses.cs @@ -0,0 +1,6 @@ +using System; + +namespace OE.ALGA.Optimalizalas +{ + // 9. heti labor feladat - Tesztek: 09VisszalepesesKeresesTesztek.cs +} diff --git a/ALGA_heti_feladatok/ALGA/Paradigmak/01_ImperativParadigma.cs b/ALGA_heti_feladatok/ALGA/Paradigmak/01_ImperativParadigma.cs new file mode 100644 index 0000000..3028074 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Paradigmak/01_ImperativParadigma.cs @@ -0,0 +1,151 @@ +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 : IEnumerable 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 IEnumerable.GetEnumerator() + { + FeladatTaroloBejaro bejaro = new FeladatTaroloBejaro(tarolo, n); + return bejaro; + } + + } + + public class FuggoFeladatTarolo : FeladatTarolo, IEnumerable 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 : IEnumerator + { + 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; + } + } +} diff --git a/ALGA_heti_feladatok/ALGA/Paradigmak/02_FunkcionalisParadigma.cs b/ALGA_heti_feladatok/ALGA/Paradigmak/02_FunkcionalisParadigma.cs new file mode 100644 index 0000000..befc53c --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/Paradigmak/02_FunkcionalisParadigma.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace OE.ALGA.Paradigmak +{ + public class FeltetelesFeladatTarolo : FeladatTarolo, IEnumerable where T : IVegrehajthato + { + public Func BejaroFeltetel + { + get; + set; + } + public bool Igaz(T t) + { + return true; + } + public FeltetelesFeladatTarolo(int l) : base(l) + { + BejaroFeltetel = Igaz; + } + public void FeltetelesVegrehajtas(Func feltetel) + { + foreach (T t in tarolo) + { + if (t != null && feltetel(t)) + { + t.Vegrehajtas(); + } + } + } + + new public IEnumerator GetEnumerator() + { + FeltetelesFeladatTaroloBejaro bejaro = new FeltetelesFeladatTaroloBejaro(tarolo, n, BejaroFeltetel); + return bejaro.GetEnumerator(); + } + + } + public class FeltetelesFeladatTaroloBejaro : IEnumerator where T : IVegrehajthato + { + T[] tarolo; + int n; + int aktualisindex; + public Func Feltetel + { + get; + } + public T Current + { + get { return tarolo[aktualisindex]; } + } + public FeltetelesFeladatTaroloBejaro(T[] tarolo, int n, Func 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; + } + } +} diff --git a/ALGA_heti_feladatok/ALGA/README.md b/ALGA_heti_feladatok/ALGA/README.md new file mode 100644 index 0000000..b2a372f --- /dev/null +++ b/ALGA_heti_feladatok/ALGA/README.md @@ -0,0 +1,6 @@ +# 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. diff --git a/ALGA_heti_feladatok/ALGA_heti_feladatok.sln b/ALGA_heti_feladatok/ALGA_heti_feladatok.sln new file mode 100644 index 0000000..98c9072 --- /dev/null +++ b/ALGA_heti_feladatok/ALGA_heti_feladatok.sln @@ -0,0 +1,52 @@ + +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 diff --git a/ALGA_heti_feladatok/ALGAme/ALGAme.csproj b/ALGA_heti_feladatok/ALGAme/ALGAme.csproj new file mode 100644 index 0000000..51f0932 --- /dev/null +++ b/ALGA_heti_feladatok/ALGAme/ALGAme.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + enable + enable + OE.ALGA.ALGAme + + + + + + + + diff --git a/ALGA_heti_feladatok/ALGAme/Jatek.cs b/ALGA_heti_feladatok/ALGAme/Jatek.cs new file mode 100644 index 0000000..b939eda --- /dev/null +++ b/ALGA_heti_feladatok/ALGAme/Jatek.cs @@ -0,0 +1,42 @@ +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); + } + } +} diff --git a/ALGA_heti_feladatok/ALGAme/Program.cs b/ALGA_heti_feladatok/ALGAme/Program.cs new file mode 100644 index 0000000..de4deb3 --- /dev/null +++ b/ALGA_heti_feladatok/ALGAme/Program.cs @@ -0,0 +1,4 @@ +using OE.ALGA.ALGAme; + +Jatek jatek = new Jatek(); +jatek.Start(); \ No newline at end of file diff --git a/ALGA_heti_feladatok/Engine/AlapTipusok.cs b/ALGA_heti_feladatok/Engine/AlapTipusok.cs new file mode 100644 index 0000000..d3fafb8 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/AlapTipusok.cs @@ -0,0 +1,91 @@ +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; + } + } +} diff --git a/ALGA_heti_feladatok/Engine/Backend.cs b/ALGA_heti_feladatok/Engine/Backend.cs new file mode 100644 index 0000000..cbf49c9 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/Backend.cs @@ -0,0 +1,31 @@ +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; + } + } +} diff --git a/ALGA_heti_feladatok/Engine/BillentyuzetKezelo.cs b/ALGA_heti_feladatok/Engine/BillentyuzetKezelo.cs new file mode 100644 index 0000000..fe88ef2 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/BillentyuzetKezelo.cs @@ -0,0 +1,43 @@ +namespace OE.ALGA.Engine +{ + public interface IBillentyuLenyomasKezelo + { + void BillentyuLenyomas(ConsoleKey billentyu); + } + + public class BillentyuzetKezelo : IOrajelFogado + { + private readonly List billentyuLenyomasKezelok = new List(); + + public void BillentyuLenyomasKezeloFelvetele(IBillentyuLenyomasKezelo kezelo) + { + billentyuLenyomasKezelok.Add(kezelo); + } + + public void BillentyuLenyomasKezeloEltavolitasa(IBillentyuLenyomasKezelo kezelo) + { + billentyuLenyomasKezelok.Remove(kezelo); + } + + private readonly Dictionary billentyuAkciok = new Dictionary(); + + 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(); + } + } + } +} diff --git a/ALGA_heti_feladatok/Engine/Engine.csproj b/ALGA_heti_feladatok/Engine/Engine.csproj new file mode 100644 index 0000000..6476313 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/Engine.csproj @@ -0,0 +1,10 @@ + + + + net8.0 + enable + enable + OE.ALGA.Engine + + + diff --git a/ALGA_heti_feladatok/Engine/GlobalSuppressions.cs b/ALGA_heti_feladatok/Engine/GlobalSuppressions.cs new file mode 100644 index 0000000..996ee97 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/GlobalSuppressions.cs @@ -0,0 +1,12 @@ +// 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 = "", Scope = "module")] +[assembly: SuppressMessage("Style", "IDE0300:Simplify collection initialization", Justification = "", Scope = "module")] +[assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'", Justification = "", Scope = "module")] +[assembly: SuppressMessage("Style", "IDE0028:Simplify collection initialization", Justification = "", Scope = "module")] +[assembly: SuppressMessage("Style", "IDE0305:Simplify collection initialization", Justification = "", Scope = "module")] diff --git a/ALGA_heti_feladatok/Engine/Kivetelek.cs b/ALGA_heti_feladatok/Engine/Kivetelek.cs new file mode 100644 index 0000000..fa57748 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/Kivetelek.cs @@ -0,0 +1,22 @@ +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) + { + + } + } +} diff --git a/ALGA_heti_feladatok/Engine/KonzolMegjelenito.cs b/ALGA_heti_feladatok/Engine/KonzolMegjelenito.cs new file mode 100644 index 0000000..222650c --- /dev/null +++ b/ALGA_heti_feladatok/Engine/KonzolMegjelenito.cs @@ -0,0 +1,209 @@ +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> HUDmegjelenitok = new List>(); + + public void HUDAdatFelvetele(Func hudMegjelenito) + { + HUDmegjelenitok.Add(hudMegjelenito); + } + + readonly List nezopontok = new List(); + + 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 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(); + } + } +} diff --git a/ALGA_heti_feladatok/Engine/OrajelGenerator.cs b/ALGA_heti_feladatok/Engine/OrajelGenerator.cs new file mode 100644 index 0000000..6df8239 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/OrajelGenerator.cs @@ -0,0 +1,54 @@ +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 aktivOrajelFogadok = new List(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 orajelFogadok = new List(); + + public void OrajelFogadoFelvetele(IOrajelFogado fogado) + { + orajelFogadok.Add(fogado); + } + + public void OrajelFogadoEltavolitasa(IOrajelFogado fogado) + { + orajelFogadok.Remove(fogado); + } + } +} diff --git a/ALGA_heti_feladatok/Engine/Parameterek.cs b/ALGA_heti_feladatok/Engine/Parameterek.cs new file mode 100644 index 0000000..058c1c2 --- /dev/null +++ b/ALGA_heti_feladatok/Engine/Parameterek.cs @@ -0,0 +1,43 @@ +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; + } +} diff --git a/ALGA_heti_feladatok/Engine/Terkep.cs b/ALGA_heti_feladatok/Engine/Terkep.cs new file mode 100644 index 0000000..2a54e1b --- /dev/null +++ b/ALGA_heti_feladatok/Engine/Terkep.cs @@ -0,0 +1,277 @@ +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 elemek = new List(); + + 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 AdottHelyen(Pozicio pozicio) + { + return elemek.FindAll(x => x.Pozicio == pozicio); + } + + public TerkepElem[] Kornyezet(Pozicio pozicio, int tavolsag) + { + List elemek = new List(); + 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 falak = new List(); + List bovitheto = new List(); + + // 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? 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(); + } + + 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 elemek = new List(); + 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; + } + } +} diff --git a/ALGA_heti_feladatok/Sandbox/Program.cs b/ALGA_heti_feladatok/Sandbox/Program.cs new file mode 100644 index 0000000..33422bb --- /dev/null +++ b/ALGA_heti_feladatok/Sandbox/Program.cs @@ -0,0 +1,9 @@ +namespace OE.ALGA.Sandbox +{ + internal class Program + { + static void Main() + { + } + } +} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Sandbox/Sandbox.csproj b/ALGA_heti_feladatok/Sandbox/Sandbox.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/ALGA_heti_feladatok/Sandbox/Sandbox.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/ALGA_heti_feladatok/Tesztek/00_Utils.cs b/ALGA_heti_feladatok/Tesztek/00_Utils.cs new file mode 100644 index 0000000..0e51fa1 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/00_Utils.cs @@ -0,0 +1,72 @@ +using OE.ALGA.Paradigmak; + +namespace Guardian +{ + public static class Recursion + { + /// + /// 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. + /// + /// + 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 +} diff --git a/ALGA_heti_feladatok/Tesztek/01_ImperativParadigmaTesztek.cs b/ALGA_heti_feladatok/Tesztek/01_ImperativParadigmaTesztek.cs new file mode 100644 index 0000000..397dec9 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/01_ImperativParadigmaTesztek.cs @@ -0,0 +1,280 @@ +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 tarolo = new FeladatTarolo(0); + TesztFeladat a = new TesztFeladat("a"); + Assert.Throws(() => tarolo.Felvesz(a)); + } + [TestCase] + public void Felvesz() + { + FeladatTarolo tarolo = new FeladatTarolo(5); + TesztFeladat a = new TesztFeladat("a"); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + } + + [TestCase] + public void TulsokatFelvesz() + { + FeladatTarolo tarolo = new FeladatTarolo(3); + TesztFeladat a = new TesztFeladat("a"); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + Assert.Throws(() => tarolo.Felvesz(a)); + } + [TestCase] + public void NincsMitVegrehajtani() + { + FeladatTarolo tarolo = new FeladatTarolo(2); + tarolo.MindentVegrehajt(); + } + [TestCase] + public void MindentVegrehajt() + { + FeladatTarolo tarolo = new FeladatTarolo(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 tarolo = new FeladatTarolo(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 tarolo = new FuggoFeladatTarolo(5); + TesztFuggoFeladat a = new TesztFuggoFeladat("a"); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + } + [TestCase] + public void TulsokatFelvesz() + { + FuggoFeladatTarolo tarolo = new FuggoFeladatTarolo(3); + TesztFuggoFeladat a = new TesztFuggoFeladat("a"); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + tarolo.Felvesz(a); + Assert.Throws(() => tarolo.Felvesz(a)); + } + [TestCase] + public void NincsMitVegrehajtani() + { + FuggoFeladatTarolo tarolo = new FuggoFeladatTarolo(2); + tarolo.MindentVegrehajt(); + } + [TestCase] + public void MindentVegrehajt() + { + FuggoFeladatTarolo tarolo = new FuggoFeladatTarolo(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 tarolo = new FuggoFeladatTarolo(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 tarolo = new FuggoFeladatTarolo(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 tarolo = new FuggoFeladatTarolo(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 tarolo = new FuggoFeladatTarolo(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 tarolo = new FeladatTarolo(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 tarolo = new FuggoFeladatTarolo(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")); + } + } +} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/02_FunkcionalisParadigmaTesztek.cs b/ALGA_heti_feladatok/Tesztek/02_FunkcionalisParadigmaTesztek.cs new file mode 100644 index 0000000..220227e --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/02_FunkcionalisParadigmaTesztek.cs @@ -0,0 +1,136 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OE.ALGA.Paradigmak; + +namespace OE.ALGA.Tesztek +{ + [TestClass()] + public class FeltetelesFeladatTaroloTesztek + { + [TestMethod()] + public void FelveszTeszt() //F1.(a) + { + FeltetelesFeladatTarolo tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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); + } + } +} diff --git a/ALGA_heti_feladatok/Tesztek/02_FunkconalisParadigmaTesztek.cs b/ALGA_heti_feladatok/Tesztek/02_FunkconalisParadigmaTesztek.cs new file mode 100644 index 0000000..9d14ece --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/02_FunkconalisParadigmaTesztek.cs @@ -0,0 +1,154 @@ +//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 tarolo = new FeltetelesFeladatTarolo(5); +// TesztFeladat a = new TesztFeladat("a"); +// tarolo.Felvesz(a); +// tarolo.Felvesz(a); +// tarolo.Felvesz(a); +// } +// [TestCase] +// public void TulsokatFelvesz() +// { +// FeltetelesFeladatTarolo tarolo = new FeltetelesFeladatTarolo(3); +// TesztFeladat a = new TesztFeladat("a"); +// tarolo.Felvesz(a); +// tarolo.Felvesz(a); +// tarolo.Felvesz(a); +// Assert.Throws(() => tarolo.Felvesz(a)); +// } +// [TestCase] +// public void NincsMitVegrehajtani() +// { +// FeltetelesFeladatTarolo tarolo = new FeltetelesFeladatTarolo(2); +// tarolo.MindentVegrehajt(); +// } +// [TestCase] +// public void MindenVegrehajtas() +// { +// FeltetelesFeladatTarolo tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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 tarolo = new FeltetelesFeladatTarolo(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")); +// } +// } +//} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/03_TombImplementacioTesztek.cs b/ALGA_heti_feladatok/Tesztek/03_TombImplementacioTesztek.cs new file mode 100644 index 0000000..ca92237 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/03_TombImplementacioTesztek.cs @@ -0,0 +1,399 @@ +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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + Assert.That(l.Elemszam, Is.EqualTo(0)); + l.Torol(0); + Assert.That(l.Elemszam, Is.EqualTo(0)); + } + [TestCase] + public void TorlesUres() + { + Lista l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 l = new TombLista(); + 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 s = new TombSor(0); + Assert.That(s.Ures, Is.True); + Assert.Throws(() => s.Sorba(1)); + } + [TestCase] + public void AlapMukodes() + { + Sor s = new TombSor(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 s = new TombSor(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 s = new TombSor(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 s = new TombSor(3); + s.Sorba(1); + s.Sorba(3); + s.Sorba(2); + Assert.Throws(() => s.Sorba(4)); + } + + [TestCase] + public void TulKevesElem() + { + Sor s = new TombSor(3); + s.Sorba(1); + s.Sorba(3); + s.Sorba(2); + s.Sorbol(); + s.Sorbol(); + s.Sorbol(); + Assert.Throws(() => s.Sorbol()); + } + [TestCase] + public void Elso() + { + Sor s = new TombSor(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 v = new TombVerem(0); + Assert.That(v.Ures, Is.True); + Assert.Throws(() => v.Verembe(1)); + } + [TestCase] + public void AlapMukodes() + { + Verem v = new TombVerem(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 v = new TombVerem(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 v = new TombVerem(3); + v.Verembe(1); + v.Verembe(3); + v.Verembe(2); + Assert.Throws(() => v.Verembe(4)); + } + [TestCase] + public void TulKevesElem() + { + Verem v = new TombVerem(3); + v.Verembe(1); + v.Verembe(3); + v.Verembe(2); + v.Verembol(); + v.Verembol(); + v.Verembol(); + Assert.Throws(() => v.Verembol()); + } + [TestCase] + public void Felso() + { + Verem v = new TombVerem(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)); + } + } +} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/04_EgyszeruLancTesztek.cs b/ALGA_heti_feladatok/Tesztek/04_EgyszeruLancTesztek.cs new file mode 100644 index 0000000..4a254e5 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/04_EgyszeruLancTesztek.cs @@ -0,0 +1,226 @@ +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 v = new LancoltVerem(); + 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 v = new LancoltVerem(); + v.Verembe(1); + v.Verembe(3); + v.Verembe(2); + v.Verembol(); + v.Verembol(); + v.Verembol(); + v.Verembol(); + } + + [TestMethod()] + public void Felso() //F2. + { + Verem v = new LancoltVerem(); + 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 v = new LancoltVerem(); + 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 s = new LancoltSor(); + 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 s = new LancoltSor(); + s.Sorba(1); + s.Sorba(3); + s.Sorba(2); + s.Sorbol(); + s.Sorbol(); + s.Sorbol(); + s.Sorbol(); + } + + [TestMethod()] + public void Elso() //F3. + { + Sor s = new LancoltSor(); + 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 s = new LancoltSor(); + 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 l = new LancoltLista(); + 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 l = new LancoltLista(); + 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 l = new LancoltLista(); + 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 l = new LancoltLista(); + 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 l = new LancoltLista(); + 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 l = new LancoltLista(); + 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 l = new LancoltLista(); + 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 l = new LancoltLista(); + 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); + } + } +} diff --git a/ALGA_heti_feladatok/Tesztek/04_LancoltImplementacioTesztek.cs b/ALGA_heti_feladatok/Tesztek/04_LancoltImplementacioTesztek.cs new file mode 100644 index 0000000..e8b48ba --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/04_LancoltImplementacioTesztek.cs @@ -0,0 +1,353 @@ +//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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// Assert.That(l.Elemszam, Is.EqualTo(0)); +// l.Torol(0); +// Assert.That(l.Elemszam, Is.EqualTo(0)); +// } +// [TestCase] +// public void TorlesUres() +// { +// Lista l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 l = new LancoltLista(); +// 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 s = new LancoltSor(); +// Assert.That(s.Ures, Is.True); +// Assert.Throws(() => s.Elso()); +// Assert.Throws(() => s.Sorbol()); +// s.Sorba(1); +// Assert.That(s.Ures, Is.False); +// s.Sorbol(); +// Assert.That(s.Ures, Is.True); +// } +// [TestCase] +// public void AlapMukodes() +// { +// Sor s = new LancoltSor(); +// 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 s = new LancoltSor(); +// 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 s = new LancoltSor(); +// s.Sorba(1); +// s.Sorba(3); +// s.Sorba(2); +// s.Sorbol(); +// s.Sorbol(); +// s.Sorbol(); +// Assert.Throws(() => s.Sorbol()); +// } +// [TestCase] +// public void Elso() +// { +// Sor s = new LancoltSor(); +// 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 v = new LancoltVerem(); +// Assert.That(v.Ures, Is.True); +// Assert.Throws(() => v.Felso()); +// Assert.Throws(() => v.Verembol()); +// v.Verembe(1); +// Assert.That(v.Ures, Is.False); +// v.Verembol(); +// Assert.That(v.Ures, Is.True); +// } +// [TestCase] +// public void AlapMukodes() +// { +// Verem v = new LancoltVerem(); +// 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 v = new LancoltVerem(); +// 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 v = new LancoltVerem(); +// v.Verembe(1); +// v.Verembe(3); +// v.Verembe(2); +// v.Verembol(); +// v.Verembol(); +// v.Verembol(); +// Assert.Throws(() => v.Verembol()); +// } +// [TestCase] +// public void Felso() +// { +// Verem v = new LancoltVerem(); +// 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)); +// } + +// } +//} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/05_BinarisKeresoFaTesztek.cs b/ALGA_heti_feladatok/Tesztek/05_BinarisKeresoFaTesztek.cs new file mode 100644 index 0000000..fd13012 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/05_BinarisKeresoFaTesztek.cs @@ -0,0 +1,125 @@ +//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 v = new FaHalmaz(); +// v.Beszur(""); +// Assert.Multiple(() => +// { +// Assert.That(v.Eleme(""), Is.True); +// }); +// } +// [TestCase] +// public void Beszuras() +// { +// Halmaz v = new FaHalmaz(); +// 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 v = new FaHalmaz(); +// 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 v = new FaHalmaz(); +// 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 v = new FaHalmaz(); +// 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 v = new FaHalmaz(); +// v.Beszur(1); +// v.Beszur(3); +// v.Beszur(2); +// Assert.Throws(() => 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 v = new FaHalmaz(); +// 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 v = new FaHalmaz(); +// 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")); +// } +// } +//} diff --git a/ALGA_heti_feladatok/Tesztek/06_SzotarTesztek.cs b/ALGA_heti_feladatok/Tesztek/06_SzotarTesztek.cs new file mode 100644 index 0000000..2d33576 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/06_SzotarTesztek.cs @@ -0,0 +1,112 @@ +//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 sz = new HasitoSzotarTulcsordulasiTerulettel(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 sz = new HasitoSzotarTulcsordulasiTerulettel(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 sz = new HasitoSzotarTulcsordulasiTerulettel(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 sz = new HasitoSzotarTulcsordulasiTerulettel(5, TesztHasitoFuggveny); +// sz.Beir("null", null!); +// } +// [TestCase] +// public void UresKulcs() +// { +// Szotar sz = new HasitoSzotarTulcsordulasiTerulettel(5, TesztHasitoFuggveny); +// sz.Beir("", 0); +// } +// [TestCase] +// public void UresElem() +// { +// Szotar sz = new HasitoSzotarTulcsordulasiTerulettel(5, TesztHasitoFuggveny); +// sz.Beir("Bela", ""); +// } +// [TestCase] +// public void NincsElem() +// { +// Szotar sz = new HasitoSzotarTulcsordulasiTerulettel(5, TesztHasitoFuggveny); +// sz.Beir("Bela", 5); +// sz.Beir("Lajos", 2); +// Assert.Throws(() => sz.Kiolvas("Ferenc")); +// } +// [TestCase] +// public void TorlesNull() +// { +// Szotar sz = new HasitoSzotarTulcsordulasiTerulettel(5, TesztHasitoFuggveny); +// sz.Beir("Bela", 5); +// sz.Beir("Lajos", 2); +// Assert.Throws(() => sz.Torol(null!)); +// } +// [TestCase] +// public void TorlesMarad() +// { +// Szotar sz = new HasitoSzotarTulcsordulasiTerulettel(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 sz = new HasitoSzotarTulcsordulasiTerulettel(5, TesztHasitoFuggveny); +// sz.Beir("Bela", 5); +// sz.Beir("Lajos", 2); +// sz.Torol("Bela"); +// Assert.Throws(() => sz.Kiolvas("Bela")); +// } +// } +//} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/07_NyersEroTesztek.cs b/ALGA_heti_feladatok/Tesztek/07_NyersEroTesztek.cs new file mode 100644 index 0000000..6849779 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/07_NyersEroTesztek.cs @@ -0,0 +1,162 @@ +//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 opt = new NyersEro( +// 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 opt = new NyersEro( +// 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())); +// 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)); +// }); +// } +// } +//} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/08_DinamikusProgramozasTesztek.cs b/ALGA_heti_feladatok/Tesztek/08_DinamikusProgramozasTesztek.cs new file mode 100644 index 0000000..7e2a0e0 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/08_DinamikusProgramozasTesztek.cs @@ -0,0 +1,67 @@ +//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())); +// 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)); +// }); +// } +// } +//} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/09_VisszalepesesKereses.cs b/ALGA_heti_feladatok/Tesztek/09_VisszalepesesKereses.cs new file mode 100644 index 0000000..4abb032 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/09_VisszalepesesKereses.cs @@ -0,0 +1,103 @@ +//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)); +// }); +// } +// } +//} \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/09_VisszalepesesKeresesTesztek.cs b/ALGA_heti_feladatok/Tesztek/09_VisszalepesesKeresesTesztek.cs new file mode 100644 index 0000000..4608715 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/09_VisszalepesesKeresesTesztek.cs @@ -0,0 +1,79 @@ +// 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); +// } +// } +// } diff --git a/ALGA_heti_feladatok/Tesztek/10_SulyozatlanGrafTesztek.cs b/ALGA_heti_feladatok/Tesztek/10_SulyozatlanGrafTesztek.cs new file mode 100644 index 0000000..1795a6a --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/10_SulyozatlanGrafTesztek.cs @@ -0,0 +1,138 @@ +//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 a_szomszedai = csg.Szomszedai(0); +// Halmaz b_szomszedai = csg.Szomszedai(1); +// Halmaz 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 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 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); +// }); +// } +// } +//} diff --git a/ALGA_heti_feladatok/Tesztek/11_KupacTesztek.cs b/ALGA_heti_feladatok/Tesztek/11_KupacTesztek.cs new file mode 100644 index 0000000..c8db5db --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/11_KupacTesztek.cs @@ -0,0 +1,240 @@ +//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 s = new KupacPrioritasosSor(2, (x, y) => x > y); +// s.Sorba(1); +// s.Sorba(2); +// Assert.Throws(() => s.Sorba(3)); +// } + +// [TestCase] +// public void TulKevesElemTeszt() +// { +// PrioritasosSor s = new KupacPrioritasosSor(5, (x, y) => x > y); +// s.Sorba(1); +// s.Sorba(2); +// s.Sorba(3); +// s.Sorbol(); +// s.Sorbol(); +// s.Sorbol(); +// Assert.Throws(() => s.Sorbol()); +// } + +// [TestCase] +// public void UresTeszt() +// { +// PrioritasosSor s = new KupacPrioritasosSor(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 s = new KupacPrioritasosSor(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 s = new KupacPrioritasosSor(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 +// { +// /// +// /// Nincs külön rendező függvény, ezért ABC sorrendben rendez az IComparable alapján. +// /// +// [TestCase] +// public void KupacEpitesIComparableAlapjan() +// { +// KupacPrioritasosSor ps = new KupacPrioritasosSor(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")); +// }); +// } + +// /// +// /// Van egy saját hossz alapú rendező függvény, ezért elsőként a leghosszabb stringeket adja vissza. +// /// +// [TestCase] +// public void KupacEpitesSajatFuggvennyel() +// { +// KupacPrioritasosSor ps = new KupacPrioritasosSor(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(A, A.Length, (x, y) => x > y); + +// Assert.Multiple(() => +// { +// for (int i = 1; i < A.Length; i++) +// Assert.That(A[Kupac.Szulo(i)] >= A[i], Is.True); +// }); +// } + +// [TestCase] +// public void KupacRendezes() +// { +// int[] A = [5, 8, 7, 0, 9, 6, 4, 1, 3, 2]; +// KupacRendezes k = new KupacRendezes(A); +// k.Rendezes(); + +// Assert.Multiple(() => +// { +// for (int i = 1; i < A.Length; i++) +// Assert.That(A[i], Is.EqualTo(i)); +// }); +// } +// } +//} diff --git a/ALGA_heti_feladatok/Tesztek/12_SulyozottGrafTesztek.cs b/ALGA_heti_feladatok/Tesztek/12_SulyozottGrafTesztek.cs new file mode 100644 index 0000000..a68f426 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/12_SulyozottGrafTesztek.cs @@ -0,0 +1,278 @@ +//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 a_szomszedai = csg.Szomszedai(0); +// Halmaz b_szomszedai = csg.Szomszedai(1); +// Halmaz 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(() => 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 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 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 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 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 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 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)); +// }); +// } +// } +//} diff --git a/ALGA_heti_feladatok/Tesztek/NOTES.md b/ALGA_heti_feladatok/Tesztek/NOTES.md new file mode 100644 index 0000000..c2bcf60 --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/NOTES.md @@ -0,0 +1,3 @@ +## 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 \ No newline at end of file diff --git a/ALGA_heti_feladatok/Tesztek/Tesztek.csproj b/ALGA_heti_feladatok/Tesztek/Tesztek.csproj new file mode 100644 index 0000000..b24444c --- /dev/null +++ b/ALGA_heti_feladatok/Tesztek/Tesztek.csproj @@ -0,0 +1,33 @@ + + + + net8.0 + disable + enable + en + + false + true + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + +