From 75a0a85a8caeb72d26324beccd1577f5ca72040b Mon Sep 17 00:00:00 2001 From: Dani Danyel Date: Fri, 5 Oct 2018 18:53:03 +0300 Subject: [PATCH 1/3] Task 1 done --- .DS_Store | Bin 0 -> 8196 bytes FirstLesson/.DS_Store | Bin 0 -> 6148 bytes .../DaniDanyelAristizabal-task1/.DS_Store | Bin 0 -> 6148 bytes .../StudentsStatistics/.DS_Store | Bin 0 -> 8196 bytes .../StudentsStatisticCore/Class1.cs | 8 ++++ .../Exceptions/StudentListIsEmptyException.cs | 8 ++++ .../StudentsFileDoesNotExistsException.cs | 7 +++ .../StudentsStatisticCore/Student.cs | 23 ++++++++++ .../StudentStatisticCalc.cs | 40 ++++++++++++++++ .../StudentsStatisticCore/StudentsCreator.cs | 40 ++++++++++++++++ .../StudentsStatisticCore.csproj | 14 ++++++ .../Views/StatisticView.cs | 11 +++++ .../StudentsStatistics/StudentsStatistics.sln | 29 ++++++++++++ .../StudentsStatistics/.DS_Store | Bin 0 -> 8196 bytes ...Statistics:StudentsStatisticsTests:Test.cs | 14 ++++++ .../StudentsStatistics.csproj | 32 +++++++++++++ .../StudentsStatisticsConsole/.DS_Store | Bin 0 -> 6148 bytes .../StudentsStatisticsConsole/Program.cs | 21 +++++++++ .../Properties/AssemblyInfo.cs | 26 +++++++++++ .../StudentsStatisticsConsole.csproj | 43 ++++++++++++++++++ .../StudentsStatisticsCore/Program.cs | 21 +++++++++ .../StudentsStatisticsConsoleCore.csproj | 11 +++++ .../StudentsStatisticsTests.csproj | 19 ++++++++ .../StudentsStatisticsTests/UnitTest1.cs | 36 +++++++++++++++ StudentsStatisticCore/Class1.cs | 8 ++++ .../Exceptions/StudentListIsEmptyException.cs | 8 ++++ .../StudentsFileDoesNotExistsException.cs | 7 +++ StudentsStatisticCore/Student.cs | 23 ++++++++++ StudentsStatisticCore/StudentStatisticCalc.cs | 40 ++++++++++++++++ StudentsStatisticCore/StudentsCreator.cs | 40 ++++++++++++++++ .../StudentsStatisticCore.csproj | 14 ++++++ StudentsStatisticCore/Views/StatisticView.cs | 11 +++++ StudentsStatistics.sln | 29 ++++++++++++ StudentsStatistics/.DS_Store | Bin 0 -> 8196 bytes ...Statistics:StudentsStatisticsTests:Test.cs | 14 ++++++ StudentsStatistics/StudentsStatistics.csproj | 32 +++++++++++++ StudentsStatisticsConsole/.DS_Store | Bin 0 -> 6148 bytes StudentsStatisticsConsole/Program.cs | 21 +++++++++ .../Properties/AssemblyInfo.cs | 26 +++++++++++ .../StudentsStatisticsConsole.csproj | 43 ++++++++++++++++++ StudentsStatisticsCore/Program.cs | 21 +++++++++ .../StudentsStatisticsConsoleCore.csproj | 11 +++++ .../StudentsStatisticsTests.csproj | 19 ++++++++ StudentsStatisticsTests/UnitTest1.cs | 36 +++++++++++++++ 44 files changed, 806 insertions(+) create mode 100644 .DS_Store create mode 100644 FirstLesson/.DS_Store create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/.DS_Store create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/.DS_Store create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/.DS_Store create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/.DS_Store create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/Program.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/Properties/AssemblyInfo.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/StudentsStatisticsConsole.csproj create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj create mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs create mode 100644 StudentsStatisticCore/Class1.cs create mode 100644 StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs create mode 100644 StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs create mode 100644 StudentsStatisticCore/Student.cs create mode 100644 StudentsStatisticCore/StudentStatisticCalc.cs create mode 100644 StudentsStatisticCore/StudentsCreator.cs create mode 100644 StudentsStatisticCore/StudentsStatisticCore.csproj create mode 100644 StudentsStatisticCore/Views/StatisticView.cs create mode 100644 StudentsStatistics.sln create mode 100644 StudentsStatistics/.DS_Store create mode 100644 StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs create mode 100644 StudentsStatistics/StudentsStatistics.csproj create mode 100644 StudentsStatisticsConsole/.DS_Store create mode 100644 StudentsStatisticsConsole/Program.cs create mode 100644 StudentsStatisticsConsole/Properties/AssemblyInfo.cs create mode 100644 StudentsStatisticsConsole/StudentsStatisticsConsole.csproj create mode 100644 StudentsStatisticsCore/Program.cs create mode 100644 StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj create mode 100644 StudentsStatisticsTests/StudentsStatisticsTests.csproj create mode 100644 StudentsStatisticsTests/UnitTest1.cs diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fed48bd50aa9de08859b22f115f7d561aba2ac3c GIT binary patch literal 8196 zcmeHM&2G~`5T0!UY=RIGLNwfbLE;dhw58;LkgT*EdP6dT1EAJUtk%NVQS3B=5abIF z0dK&g@B};v4*=i(5VbZHQIHUn8ENO6-JNgke73wEhloUfGTb0)6Olwy*t!h&6I1i5 zRcy_UD4qbH(m@cX0eY=UE)TE*tN<&(3a|pKz~7+&_H1SHjD6qCvS$TYf&Wqg^?Y#9 z6uK4*gZj|{r%M1}9mCoX>z99^qXvMk#lj#)V8T#=hAM1{A#Cj+3?1{X%`XfZIthJb ztYeQXY=t6h=^-4QPQo?Fo)usPstTyRzeacHn6kb2RQ-M*Gq=BK(=2*9aA!S20_FL`QY_qrB zaW=QM=N)I(>vcQM-K~4`c|)$>+IX;c@apxO+1vTM5BjH*uumPjYWfTR5m7~$V{e?q zX>y1;#k)ox35Gy|@iz(K@J1PEBYn)esm-_J~(QhmxI_~?7VoFZm z`Qm*^{F_UywL>W`Zw4PzSX%Mx@2_}XFYXHBp1jn&|KrwTV+B@Fpk_F2^$zgx?C<|8 ztjrWvfED;x6cF`YZ?})L{qdGtK5{x+6s=#+i3Poc8 literal 0 HcmV?d00001 diff --git a/FirstLesson/.DS_Store b/FirstLesson/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b4d9f9c0d05173f32753741a44ae94b595eee9e9 GIT binary patch literal 6148 zcmeHK-D(p-6h6~NokYZ32o}7V8$l&X(pqyN!ZxlKy%SbcP-%C&OS5#d6S5ma8zcJ^ zf(pSIF$!)S}tH8#JPn3Myd_u&*O%MmNz8 z(Yr^T%}nk@nT(J@9Ut$Z*S~0iw{X^IQVea@!)TbLMcHnDVoS@lGiT3n-r$W3jTb>* zPJ%Kl$3-t3JyWfRVcCzY|47R0n;%Ax(`2&MymVjYWtis4NC&5Jf+^3RqoudmRMa|pS8ra+ikbR?X^3zS)E_L+PSy6J=i~(zM8#$s|zNE zLr}{_i%0Md&VnRoyPaT14u(gm7SA-0zHf=;hfm+!`26AH#-C)1PcYlCe^OPx3`Th- z^IcS?{*5{oae@UK(*Sr2HvVDR-o>nI-z{4-Pm9>)%Fmycf?b`C0mr~^Goa1~0afT( ztPJX-14cgqfHib$fv-LWRE)6bS*#3V1j0-x(1bGk#9$^I{ld=kELH|hI5GS9VD^`p zeW5V@>&P$kbYh-CXB`8Mf#VD;n`Tqp{||os{y!e%T8;t7z<IT&`V>@VVCI|KotfpnJ$7%1NR6i17EzCgG?cN`fw@I^p7n;b!pIs> zxf)|CsiulzSdo8$0p7dEZoj6K(bfG+u!lMJlI&3!5UIKb9BJXTO}lyJL-X zR-K0$KhpCeuj;|zr)sUW@7-V5x~sbnyYJ&OJB#b2o>rq|a>P%slKLzS{%dQCOFv29 zm)D76PKK4V}!hWo0plLjqJ3{Dpx1=6Iyq4=eV~ypKlL$`et`~(Kqwq zaL_k9&vzG#j^2E_wRd>(@$;AY*TuK*?(In7`*!ju;1Vw2+=;(W@uVzl`2q3ETFV-O z!hkR!46K@ga1QAQt6o^v69$BVzn%d;9}JW+3fOpbM+b~+0f21`JAu!?hn!;qMgbd- zn1Lvt3iPQev>3{#W88$eC}88!r;`fJhYBmJ(4i=|I_eu2PAc*!Ru~Wlt~0>BAEd|k z|G}U8e-|W17!U^jPX<(bKi(hV-NM~^<1P8FHP90%3&%AcFH_*Ss~E9-6+eMG!MI@u V7zJ!RVgw>T0*(eT!oW%y_zi^fYtH}x literal 0 HcmV?d00001 diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/.DS_Store b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fed48bd50aa9de08859b22f115f7d561aba2ac3c GIT binary patch literal 8196 zcmeHM&2G~`5T0!UY=RIGLNwfbLE;dhw58;LkgT*EdP6dT1EAJUtk%NVQS3B=5abIF z0dK&g@B};v4*=i(5VbZHQIHUn8ENO6-JNgke73wEhloUfGTb0)6Olwy*t!h&6I1i5 zRcy_UD4qbH(m@cX0eY=UE)TE*tN<&(3a|pKz~7+&_H1SHjD6qCvS$TYf&Wqg^?Y#9 z6uK4*gZj|{r%M1}9mCoX>z99^qXvMk#lj#)V8T#=hAM1{A#Cj+3?1{X%`XfZIthJb ztYeQXY=t6h=^-4QPQo?Fo)usPstTyRzeacHn6kb2RQ-M*Gq=BK(=2*9aA!S20_FL`QY_qrB zaW=QM=N)I(>vcQM-K~4`c|)$>+IX;c@apxO+1vTM5BjH*uumPjYWfTR5m7~$V{e?q zX>y1;#k)ox35Gy|@iz(K@J1PEBYn)esm-_J~(QhmxI_~?7VoFZm z`Qm*^{F_UywL>W`Zw4PzSX%Mx@2_}XFYXHBp1jn&|KrwTV+B@Fpk_F2^$zgx?C<|8 ztjrWvfED;x6cF`YZ?})L{qdGtK5{x+6s=#+i3Poc8 literal 0 HcmV?d00001 diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs new file mode 100644 index 0000000..e7db970 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace StudentsStatisticCore +{ + public class Class1 + { + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs new file mode 100644 index 0000000..c880b95 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs @@ -0,0 +1,8 @@ +using System; +namespace StudentsStatistics.Exceptions +{ + public class StudentsListIsEmptyException : Exception + { + + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs new file mode 100644 index 0000000..e7707af --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs @@ -0,0 +1,7 @@ +using System; +namespace StudentsStatistics.Exceptions +{ + public class StudentsFileDoesNotExistsException : Exception + { + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs new file mode 100644 index 0000000..dfd9fb5 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs @@ -0,0 +1,23 @@ +using System; + +namespace StudentsStatistics +{ + public class Student + { + public string Date { get; private set; } + public string Name { get; private set; } + public string Course { get; private set; } + public string Institute { get; private set; } + public string Dormitory { get; private set; } + + public Student(string date, string name, string course, string insitute, string dormitory) + { + Date = date ?? throw new ArgumentNullException(); + Name = name ?? throw new ArgumentNullException(); + Course = course ?? throw new ArgumentNullException(); + Institute = insitute ?? throw new ArgumentNullException(); + Dormitory = dormitory ?? throw new ArgumentNullException(); + } + } +} + diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs new file mode 100644 index 0000000..9acfcd4 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using StudentsStatistics.Views; +using System; +using StudentsStatistics.Exceptions; + +namespace StudentsStatistics +{ + public class StudentStatisticCalc + { + public StatisticView CountInDorm(List studentsList) + { + if (studentsList == null) throw new ArgumentNullException(); + if (studentsList.Count == 0) throw new StudentsListIsEmptyException(); + var indorm = new int[] { }; + var result = new StatisticView(); + + foreach (var element in studentsList) + { + + result.Total++; + if (element.Course == "1 бакалавриат" && element.Dormitory == "Да") + { + result.FirstCourse++; + + } + if (element.Course == "2 бакалавриат" && element.Dormitory == "Да") + { + result.SecondCourse++; + + } + if (element.Course == "3 бакалавриат" && element.Dormitory == "Да") + { + result.ThirdCourse++; + } + } + + return result; + } + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs new file mode 100644 index 0000000..ed45058 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.IO; +using StudentsStatistics.Exceptions; + +namespace StudentsStatistics +{ + public static class StudentsCreator + { + private static Student FromLine(string line) + { + if (line == null) throw new ArgumentNullException(); + var data = new string[] { }; + data = line.Split(';'); + + return new Student(data[0], data[1], data[2], data[3], data[4]); + } + + public static List ReadStudents(string path) + { + var list = new List(); + try + { + foreach (var line in File.ReadLines(path)) + { + list.Add(FromLine(line)); + + } + } + catch(FileNotFoundException) + { + throw new StudentsFileDoesNotExistsException(); + } + + return list; + } + + + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj new file mode 100644 index 0000000..075a554 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj @@ -0,0 +1,14 @@ + + + + netstandard2.0 + + + + + + + + + + diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs new file mode 100644 index 0000000..ca344f5 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs @@ -0,0 +1,11 @@ +namespace StudentsStatistics.Views +{ + public class StatisticView + { + public int FirstCourse { get; set; } + public int SecondCourse { get; set; } + public int ThirdCourse { get; set; } + public int FourthCourse { get; set; } + public int Total { get; set; } + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln new file mode 100644 index 0000000..268d4e2 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticsTests", "StudentsStatisticsTests\StudentsStatisticsTests.csproj", "{598857A4-8927-453F-8697-A3C06D4389DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticsConsoleCore", "StudentsStatisticsCore\StudentsStatisticsConsoleCore.csproj", "{9BC44367-5EA5-43E6-9322-4A58548F2FA9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticCore", "StudentsStatisticCore\StudentsStatisticCore.csproj", "{E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {598857A4-8927-453F-8697-A3C06D4389DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {598857A4-8927-453F-8697-A3C06D4389DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {598857A4-8927-453F-8697-A3C06D4389DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {598857A4-8927-453F-8697-A3C06D4389DB}.Release|Any CPU.Build.0 = Release|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Release|Any CPU.Build.0 = Release|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/.DS_Store b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a1aac1c57870e546c5d5178365f1dfeae2cb7f8e GIT binary patch literal 8196 zcmeHM!EVz)5S?vWaDxyLLTb4Ag2bUhX-itE2q{Y1LvNK_$^lSnCl+;ay;bZGXb8%M ze*pe~PvHyr5Iz9j>~5>nanu6`3f-x8W_NaG?0xGUXIvr@&3<=hu|)bA0-F)H~UMVQOLPcaJ6 zVmeZKpN^r8@h1^s3-&3!fu*Dqj6K>`Jfl9o2!!||kYU~f_f<3sF$gdR}|_Z(4@v-(zS6%5i76YG0$5=UuPtNjpjrTK*$ zHyx+!ly8?`d53b~Wq#IAn||*Fk9Pg+Ffjc+DdY3LAM8irpk2Awl1b)AN!U})Q8$Fi z%jZ$jm4l}2C*4%V@$`h_EINzrN_99~-Ka0St84YqvOC<^s4csX*Vad)MQ7>3%F~^L zm{*FUPHsyWo*$qKp0}fc!MQ2DF>%mg54yX zg+5mewmQRB|8v+17n=jI1lR&Py7+vFPdV6()&B~VSzZpBGVLOLa5~`B!cQ1dL=LE* zIiSk9WH9T9f1WtvcXK`|wQ#*qB^rrdQ4CH1lQHg3#VATuDiYSitIBUVpOndnOSy>C z@meaGc8cy#JwTJu7HD7LHz-7K(h|2}$s%w$0wrxy<@$en_V@qG16d1;fJNY+ML^7N zd0S1~{@E|c{7SgicF_*dnAmQtrE&pNI2BbB}!vFvP literal 0 HcmV?d00001 diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs new file mode 100644 index 0000000..6400173 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs @@ -0,0 +1,14 @@ +using NUnit.Framework; +using System; +namespace StudentsStatisticsTests +{ + [TestFixture()] + public class Test + { + [Test()] + public void TestCase() + { + + } + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj new file mode 100644 index 0000000..8949b90 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj @@ -0,0 +1,32 @@ + + + Debug + AnyCPU + {6F144441-95B7-41A4-93C7-6FF98031EB88} + Library + StudentsStatistics + StudentsStatistics + v4.7 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + true + bin\Release + prompt + 4 + false + + + + + + \ No newline at end of file diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/.DS_Store b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2a266f7686fec6bf5a201549b7a8bc70db2014ba GIT binary patch literal 6148 zcmeHK!EV$r5FK|H>J38d0jWLag2Z8kwk>532r1f@LvNLW-~gyiny3v*HMgFe@_)v zlojcegR>-s%bQnOk*N7t&5EStaYEA}Wl#2w`kRZz_GowDZ}03b2mWF-8V>x&J5QF& zp4@n__3YsI{KLn^#q!e^^A-d)DVBQ{FX1Z;o8J3yTI8xYMT_?CkODdHTGV_)Pm>z< zy1vwKdM#=^I;1J+IfahsoF35$l})0=MvJJ+m0v2F+PRxoKXVb0#?cO zh@(r^n3wkOBn41W4nKYtn(*_rUY_{b8XwggDt0-@J2y0cm$qZTF>o~ldVlayGzJ!H zgS>S>@f85rMKcR*{`m*`x&atitPP?CB1|aIgbI7b5ccjMOgQ=j>t7o*;UsuwjALgO z_J$(t)kFB~P9iYqv}3?A&}5)vs(pR_Kfn6^-wbj!$ADwtS}`EH`{Di=DcQ4iB{_Z8 t`Y6XJTC`tnkVByCam + + + Debug + AnyCPU + {1CCC4C27-5E6B-4DB6-8C6F-0ADB81D52B1F} + Exe + StudentsStatisticsConsole + StudentsStatisticsConsole + v4.7 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + + + true + bin\Release + prompt + 4 + true + + + + + + + + + + + {6F144441-95B7-41A4-93C7-6FF98031EB88} + StudentsStatistics + + + + \ No newline at end of file diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs new file mode 100644 index 0000000..7fac1e0 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs @@ -0,0 +1,21 @@ +using System; +using StudentsStatistics; + +namespace StudentsStatisticsConsole +{ + class MainClass + { + public static void Main(string[] args) + { + // var path = Console.ReadLine(); + var path = "/Users/danielaristizabaljaramillo/Desktop/SE/StudentsStatistics/StudentsStatistics/bin/Debug/Тестирование.csv"; + var loadedStudents = StudentsCreator.ReadStudents(path); + + var studentsStat = new StudentStatisticCalc(); + + var result = studentsStat.CountInDorm(loadedStudents); + + Console.WriteLine($"1: {result.FirstCourse} 2: {result.SecondCourse} 3: {result.ThirdCourse} total: {result.Total}"); + } + } +} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj new file mode 100644 index 0000000..1956998 --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj @@ -0,0 +1,11 @@ + + + + Exe + netcoreapp2.1 + + + + + + diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj new file mode 100644 index 0000000..1fbe80b --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + + + + + diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs new file mode 100644 index 0000000..8fb371d --- /dev/null +++ b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs @@ -0,0 +1,36 @@ +using StudentsStatistics; +using Xunit; + +namespace StudentsStatisticsTests +{ + public class StudentStatisticsTest + { + [Fact] + public void ParsingisRight() + { + // Arrange + string expected = "test"; + // Act + var StudentTest = new Student("5-3]['", "test", "56]54]['", "56]34[5", "]4]435']6"); + //Assert + Assert.Equal(expected, StudentTest.Name); + + } + + [Fact] + public void FromLineTest(){ + //Arrange + Student expected = new Student("sfnrngjs","we2534","FWEGWE","WEG W GARG "," EGEWG"); + // Act + string AnyString = "sfnrngjs;we2534;FWEGWE;WEG W GARG;EGEWG"; + Student Resulttest = FromLine(AnyString); + + //Assert + Assert.Equal(expected, Resulttest); + + + + } + } + +} diff --git a/StudentsStatisticCore/Class1.cs b/StudentsStatisticCore/Class1.cs new file mode 100644 index 0000000..e7db970 --- /dev/null +++ b/StudentsStatisticCore/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace StudentsStatisticCore +{ + public class Class1 + { + } +} diff --git a/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs b/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs new file mode 100644 index 0000000..c880b95 --- /dev/null +++ b/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs @@ -0,0 +1,8 @@ +using System; +namespace StudentsStatistics.Exceptions +{ + public class StudentsListIsEmptyException : Exception + { + + } +} diff --git a/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs b/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs new file mode 100644 index 0000000..e7707af --- /dev/null +++ b/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs @@ -0,0 +1,7 @@ +using System; +namespace StudentsStatistics.Exceptions +{ + public class StudentsFileDoesNotExistsException : Exception + { + } +} diff --git a/StudentsStatisticCore/Student.cs b/StudentsStatisticCore/Student.cs new file mode 100644 index 0000000..dfd9fb5 --- /dev/null +++ b/StudentsStatisticCore/Student.cs @@ -0,0 +1,23 @@ +using System; + +namespace StudentsStatistics +{ + public class Student + { + public string Date { get; private set; } + public string Name { get; private set; } + public string Course { get; private set; } + public string Institute { get; private set; } + public string Dormitory { get; private set; } + + public Student(string date, string name, string course, string insitute, string dormitory) + { + Date = date ?? throw new ArgumentNullException(); + Name = name ?? throw new ArgumentNullException(); + Course = course ?? throw new ArgumentNullException(); + Institute = insitute ?? throw new ArgumentNullException(); + Dormitory = dormitory ?? throw new ArgumentNullException(); + } + } +} + diff --git a/StudentsStatisticCore/StudentStatisticCalc.cs b/StudentsStatisticCore/StudentStatisticCalc.cs new file mode 100644 index 0000000..9acfcd4 --- /dev/null +++ b/StudentsStatisticCore/StudentStatisticCalc.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using StudentsStatistics.Views; +using System; +using StudentsStatistics.Exceptions; + +namespace StudentsStatistics +{ + public class StudentStatisticCalc + { + public StatisticView CountInDorm(List studentsList) + { + if (studentsList == null) throw new ArgumentNullException(); + if (studentsList.Count == 0) throw new StudentsListIsEmptyException(); + var indorm = new int[] { }; + var result = new StatisticView(); + + foreach (var element in studentsList) + { + + result.Total++; + if (element.Course == "1 бакалавриат" && element.Dormitory == "Да") + { + result.FirstCourse++; + + } + if (element.Course == "2 бакалавриат" && element.Dormitory == "Да") + { + result.SecondCourse++; + + } + if (element.Course == "3 бакалавриат" && element.Dormitory == "Да") + { + result.ThirdCourse++; + } + } + + return result; + } + } +} diff --git a/StudentsStatisticCore/StudentsCreator.cs b/StudentsStatisticCore/StudentsCreator.cs new file mode 100644 index 0000000..ed45058 --- /dev/null +++ b/StudentsStatisticCore/StudentsCreator.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.IO; +using StudentsStatistics.Exceptions; + +namespace StudentsStatistics +{ + public static class StudentsCreator + { + private static Student FromLine(string line) + { + if (line == null) throw new ArgumentNullException(); + var data = new string[] { }; + data = line.Split(';'); + + return new Student(data[0], data[1], data[2], data[3], data[4]); + } + + public static List ReadStudents(string path) + { + var list = new List(); + try + { + foreach (var line in File.ReadLines(path)) + { + list.Add(FromLine(line)); + + } + } + catch(FileNotFoundException) + { + throw new StudentsFileDoesNotExistsException(); + } + + return list; + } + + + } +} diff --git a/StudentsStatisticCore/StudentsStatisticCore.csproj b/StudentsStatisticCore/StudentsStatisticCore.csproj new file mode 100644 index 0000000..075a554 --- /dev/null +++ b/StudentsStatisticCore/StudentsStatisticCore.csproj @@ -0,0 +1,14 @@ + + + + netstandard2.0 + + + + + + + + + + diff --git a/StudentsStatisticCore/Views/StatisticView.cs b/StudentsStatisticCore/Views/StatisticView.cs new file mode 100644 index 0000000..ca344f5 --- /dev/null +++ b/StudentsStatisticCore/Views/StatisticView.cs @@ -0,0 +1,11 @@ +namespace StudentsStatistics.Views +{ + public class StatisticView + { + public int FirstCourse { get; set; } + public int SecondCourse { get; set; } + public int ThirdCourse { get; set; } + public int FourthCourse { get; set; } + public int Total { get; set; } + } +} diff --git a/StudentsStatistics.sln b/StudentsStatistics.sln new file mode 100644 index 0000000..268d4e2 --- /dev/null +++ b/StudentsStatistics.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticsTests", "StudentsStatisticsTests\StudentsStatisticsTests.csproj", "{598857A4-8927-453F-8697-A3C06D4389DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticsConsoleCore", "StudentsStatisticsCore\StudentsStatisticsConsoleCore.csproj", "{9BC44367-5EA5-43E6-9322-4A58548F2FA9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticCore", "StudentsStatisticCore\StudentsStatisticCore.csproj", "{E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {598857A4-8927-453F-8697-A3C06D4389DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {598857A4-8927-453F-8697-A3C06D4389DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {598857A4-8927-453F-8697-A3C06D4389DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {598857A4-8927-453F-8697-A3C06D4389DB}.Release|Any CPU.Build.0 = Release|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Release|Any CPU.Build.0 = Release|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/StudentsStatistics/.DS_Store b/StudentsStatistics/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a1aac1c57870e546c5d5178365f1dfeae2cb7f8e GIT binary patch literal 8196 zcmeHM!EVz)5S?vWaDxyLLTb4Ag2bUhX-itE2q{Y1LvNK_$^lSnCl+;ay;bZGXb8%M ze*pe~PvHyr5Iz9j>~5>nanu6`3f-x8W_NaG?0xGUXIvr@&3<=hu|)bA0-F)H~UMVQOLPcaJ6 zVmeZKpN^r8@h1^s3-&3!fu*Dqj6K>`Jfl9o2!!||kYU~f_f<3sF$gdR}|_Z(4@v-(zS6%5i76YG0$5=UuPtNjpjrTK*$ zHyx+!ly8?`d53b~Wq#IAn||*Fk9Pg+Ffjc+DdY3LAM8irpk2Awl1b)AN!U})Q8$Fi z%jZ$jm4l}2C*4%V@$`h_EINzrN_99~-Ka0St84YqvOC<^s4csX*Vad)MQ7>3%F~^L zm{*FUPHsyWo*$qKp0}fc!MQ2DF>%mg54yX zg+5mewmQRB|8v+17n=jI1lR&Py7+vFPdV6()&B~VSzZpBGVLOLa5~`B!cQ1dL=LE* zIiSk9WH9T9f1WtvcXK`|wQ#*qB^rrdQ4CH1lQHg3#VATuDiYSitIBUVpOndnOSy>C z@meaGc8cy#JwTJu7HD7LHz-7K(h|2}$s%w$0wrxy<@$en_V@qG16d1;fJNY+ML^7N zd0S1~{@E|c{7SgicF_*dnAmQtrE&pNI2BbB}!vFvP literal 0 HcmV?d00001 diff --git a/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs b/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs new file mode 100644 index 0000000..6400173 --- /dev/null +++ b/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs @@ -0,0 +1,14 @@ +using NUnit.Framework; +using System; +namespace StudentsStatisticsTests +{ + [TestFixture()] + public class Test + { + [Test()] + public void TestCase() + { + + } + } +} diff --git a/StudentsStatistics/StudentsStatistics.csproj b/StudentsStatistics/StudentsStatistics.csproj new file mode 100644 index 0000000..8949b90 --- /dev/null +++ b/StudentsStatistics/StudentsStatistics.csproj @@ -0,0 +1,32 @@ + + + Debug + AnyCPU + {6F144441-95B7-41A4-93C7-6FF98031EB88} + Library + StudentsStatistics + StudentsStatistics + v4.7 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + true + bin\Release + prompt + 4 + false + + + + + + \ No newline at end of file diff --git a/StudentsStatisticsConsole/.DS_Store b/StudentsStatisticsConsole/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2a266f7686fec6bf5a201549b7a8bc70db2014ba GIT binary patch literal 6148 zcmeHK!EV$r5FK|H>J38d0jWLag2Z8kwk>532r1f@LvNLW-~gyiny3v*HMgFe@_)v zlojcegR>-s%bQnOk*N7t&5EStaYEA}Wl#2w`kRZz_GowDZ}03b2mWF-8V>x&J5QF& zp4@n__3YsI{KLn^#q!e^^A-d)DVBQ{FX1Z;o8J3yTI8xYMT_?CkODdHTGV_)Pm>z< zy1vwKdM#=^I;1J+IfahsoF35$l})0=MvJJ+m0v2F+PRxoKXVb0#?cO zh@(r^n3wkOBn41W4nKYtn(*_rUY_{b8XwggDt0-@J2y0cm$qZTF>o~ldVlayGzJ!H zgS>S>@f85rMKcR*{`m*`x&atitPP?CB1|aIgbI7b5ccjMOgQ=j>t7o*;UsuwjALgO z_J$(t)kFB~P9iYqv}3?A&}5)vs(pR_Kfn6^-wbj!$ADwtS}`EH`{Di=DcQ4iB{_Z8 t`Y6XJTC`tnkVByCam + + + Debug + AnyCPU + {1CCC4C27-5E6B-4DB6-8C6F-0ADB81D52B1F} + Exe + StudentsStatisticsConsole + StudentsStatisticsConsole + v4.7 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + + + true + bin\Release + prompt + 4 + true + + + + + + + + + + + {6F144441-95B7-41A4-93C7-6FF98031EB88} + StudentsStatistics + + + + \ No newline at end of file diff --git a/StudentsStatisticsCore/Program.cs b/StudentsStatisticsCore/Program.cs new file mode 100644 index 0000000..7fac1e0 --- /dev/null +++ b/StudentsStatisticsCore/Program.cs @@ -0,0 +1,21 @@ +using System; +using StudentsStatistics; + +namespace StudentsStatisticsConsole +{ + class MainClass + { + public static void Main(string[] args) + { + // var path = Console.ReadLine(); + var path = "/Users/danielaristizabaljaramillo/Desktop/SE/StudentsStatistics/StudentsStatistics/bin/Debug/Тестирование.csv"; + var loadedStudents = StudentsCreator.ReadStudents(path); + + var studentsStat = new StudentStatisticCalc(); + + var result = studentsStat.CountInDorm(loadedStudents); + + Console.WriteLine($"1: {result.FirstCourse} 2: {result.SecondCourse} 3: {result.ThirdCourse} total: {result.Total}"); + } + } +} diff --git a/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj b/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj new file mode 100644 index 0000000..1956998 --- /dev/null +++ b/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj @@ -0,0 +1,11 @@ + + + + Exe + netcoreapp2.1 + + + + + + diff --git a/StudentsStatisticsTests/StudentsStatisticsTests.csproj b/StudentsStatisticsTests/StudentsStatisticsTests.csproj new file mode 100644 index 0000000..1fbe80b --- /dev/null +++ b/StudentsStatisticsTests/StudentsStatisticsTests.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + + + + + diff --git a/StudentsStatisticsTests/UnitTest1.cs b/StudentsStatisticsTests/UnitTest1.cs new file mode 100644 index 0000000..8fb371d --- /dev/null +++ b/StudentsStatisticsTests/UnitTest1.cs @@ -0,0 +1,36 @@ +using StudentsStatistics; +using Xunit; + +namespace StudentsStatisticsTests +{ + public class StudentStatisticsTest + { + [Fact] + public void ParsingisRight() + { + // Arrange + string expected = "test"; + // Act + var StudentTest = new Student("5-3]['", "test", "56]54]['", "56]34[5", "]4]435']6"); + //Assert + Assert.Equal(expected, StudentTest.Name); + + } + + [Fact] + public void FromLineTest(){ + //Arrange + Student expected = new Student("sfnrngjs","we2534","FWEGWE","WEG W GARG "," EGEWG"); + // Act + string AnyString = "sfnrngjs;we2534;FWEGWE;WEG W GARG;EGEWG"; + Student Resulttest = FromLine(AnyString); + + //Assert + Assert.Equal(expected, Resulttest); + + + + } + } + +} From 991bdb4ff21bb500191ced96b5b0685a62702a17 Mon Sep 17 00:00:00 2001 From: Dani Danyel Date: Fri, 5 Oct 2018 19:03:13 +0300 Subject: [PATCH 2/3] Task 1 --- .DS_Store | Bin 8196 -> 6148 bytes FifthLesson/readme.md | 1 - FirstLesson/.DS_Store | Bin 6148 -> 0 bytes .../DaniDanyelAristizabal-task1/.DS_Store | Bin 6148 -> 0 bytes .../StudentsStatistics/.DS_Store | Bin 8196 -> 0 bytes .../StudentsStatisticCore/Class1.cs | 8 ---- .../Exceptions/StudentListIsEmptyException.cs | 8 ---- .../StudentsFileDoesNotExistsException.cs | 7 --- .../StudentsStatisticCore/Student.cs | 23 ---------- .../StudentStatisticCalc.cs | 40 ---------------- .../StudentsStatisticCore/StudentsCreator.cs | 40 ---------------- .../StudentsStatisticCore.csproj | 14 ------ .../Views/StatisticView.cs | 11 ----- .../StudentsStatistics/StudentsStatistics.sln | 29 ------------ .../StudentsStatistics/.DS_Store | Bin 8196 -> 0 bytes ...Statistics:StudentsStatisticsTests:Test.cs | 14 ------ .../StudentsStatistics.csproj | 32 ------------- .../StudentsStatisticsConsole/.DS_Store | Bin 6148 -> 0 bytes .../StudentsStatisticsConsole/Program.cs | 21 --------- .../Properties/AssemblyInfo.cs | 26 ----------- .../StudentsStatisticsConsole.csproj | 43 ------------------ .../StudentsStatisticsCore/Program.cs | 21 --------- .../StudentsStatisticsConsoleCore.csproj | 11 ----- .../StudentsStatisticsTests.csproj | 19 -------- .../StudentsStatisticsTests/UnitTest1.cs | 36 --------------- FirstLesson/readme.md | 1 - ForthLesson/readme.md | 1 - SecondLesson/readme.md | 1 - SixthLesson/readme.md | 1 - ThirdLesson/readme.md | 1 - 30 files changed, 409 deletions(-) delete mode 100644 FifthLesson/readme.md delete mode 100644 FirstLesson/.DS_Store delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/.DS_Store delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/.DS_Store delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/.DS_Store delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/.DS_Store delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/Program.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/Properties/AssemblyInfo.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/StudentsStatisticsConsole.csproj delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj delete mode 100644 FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs delete mode 100644 FirstLesson/readme.md delete mode 100644 ForthLesson/readme.md delete mode 100644 SecondLesson/readme.md delete mode 100644 SixthLesson/readme.md delete mode 100644 ThirdLesson/readme.md diff --git a/.DS_Store b/.DS_Store index fed48bd50aa9de08859b22f115f7d561aba2ac3c..946c963d5d506bcef2ee1aad2757100c4b146749 100644 GIT binary patch delta 134 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGqg=C6q~50$ju031F-;uXU@b3LtYSXsT|kB0K*AM>+cp+{XP(S2qss}>a{!1LCfo2x^Dsdy N0olv2Ii6<*GXOSa6RZFL literal 8196 zcmeHM&2G~`5T0!UY=RIGLNwfbLE;dhw58;LkgT*EdP6dT1EAJUtk%NVQS3B=5abIF z0dK&g@B};v4*=i(5VbZHQIHUn8ENO6-JNgke73wEhloUfGTb0)6Olwy*t!h&6I1i5 zRcy_UD4qbH(m@cX0eY=UE)TE*tN<&(3a|pKz~7+&_H1SHjD6qCvS$TYf&Wqg^?Y#9 z6uK4*gZj|{r%M1}9mCoX>z99^qXvMk#lj#)V8T#=hAM1{A#Cj+3?1{X%`XfZIthJb ztYeQXY=t6h=^-4QPQo?Fo)usPstTyRzeacHn6kb2RQ-M*Gq=BK(=2*9aA!S20_FL`QY_qrB zaW=QM=N)I(>vcQM-K~4`c|)$>+IX;c@apxO+1vTM5BjH*uumPjYWfTR5m7~$V{e?q zX>y1;#k)ox35Gy|@iz(K@J1PEBYn)esm-_J~(QhmxI_~?7VoFZm z`Qm*^{F_UywL>W`Zw4PzSX%Mx@2_}XFYXHBp1jn&|KrwTV+B@Fpk_F2^$zgx?C<|8 ztjrWvfED;x6cF`YZ?})L{qdGtK5{x+6s=#+i3Poc8 diff --git a/FifthLesson/readme.md b/FifthLesson/readme.md deleted file mode 100644 index 1db0aa3..0000000 --- a/FifthLesson/readme.md +++ /dev/null @@ -1 +0,0 @@ -Fifth lesson of Margelov Vitaly \ No newline at end of file diff --git a/FirstLesson/.DS_Store b/FirstLesson/.DS_Store deleted file mode 100644 index b4d9f9c0d05173f32753741a44ae94b595eee9e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK-D(p-6h6~NokYZ32o}7V8$l&X(pqyN!ZxlKy%SbcP-%C&OS5#d6S5ma8zcJ^ zf(pSIF$!)S}tH8#JPn3Myd_u&*O%MmNz8 z(Yr^T%}nk@nT(J@9Ut$Z*S~0iw{X^IQVea@!)TbLMcHnDVoS@lGiT3n-r$W3jTb>* zPJ%Kl$3-t3JyWfRVcCzY|47R0n;%Ax(`2&MymVjYWtis4NC&5Jf+^3RqoudmRMa|pS8ra+ikbR?X^3zS)E_L+PSy6J=i~(zM8#$s|zNE zLr}{_i%0Md&VnRoyPaT14u(gm7SA-0zHf=;hfm+!`26AH#-C)1PcYlCe^OPx3`Th- z^IcS?{*5{oae@UK(*Sr2HvVDR-o>nI-z{4-Pm9>)%Fmycf?b`C0mr~^Goa1~0afT( ztPJX-14cgqfHib$fv-LWRE)6bS*#3V1j0-x(1bGk#9$^I{ld=kELH|hI5GS9VD^`p zeW5V@>&P$kbYh-CXB`8Mf#VD;n`Tqp{||os{y!e%T8;t7z<IT&`V>@VVCI|KotfpnJ$7%1NR6i17EzCgG?cN`fw@I^p7n;b!pIs> zxf)|CsiulzSdo8$0p7dEZoj6K(bfG+u!lMJlI&3!5UIKb9BJXTO}lyJL-X zR-K0$KhpCeuj;|zr)sUW@7-V5x~sbnyYJ&OJB#b2o>rq|a>P%slKLzS{%dQCOFv29 zm)D76PKK4V}!hWo0plLjqJ3{Dpx1=6Iyq4=eV~ypKlL$`et`~(Kqwq zaL_k9&vzG#j^2E_wRd>(@$;AY*TuK*?(In7`*!ju;1Vw2+=;(W@uVzl`2q3ETFV-O z!hkR!46K@ga1QAQt6o^v69$BVzn%d;9}JW+3fOpbM+b~+0f21`JAu!?hn!;qMgbd- zn1Lvt3iPQev>3{#W88$eC}88!r;`fJhYBmJ(4i=|I_eu2PAc*!Ru~Wlt~0>BAEd|k z|G}U8e-|W17!U^jPX<(bKi(hV-NM~^<1P8FHP90%3&%AcFH_*Ss~E9-6+eMG!MI@u V7zJ!RVgw>T0*(eT!oW%y_zi^fYtH}x diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/.DS_Store b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/.DS_Store deleted file mode 100644 index fed48bd50aa9de08859b22f115f7d561aba2ac3c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM&2G~`5T0!UY=RIGLNwfbLE;dhw58;LkgT*EdP6dT1EAJUtk%NVQS3B=5abIF z0dK&g@B};v4*=i(5VbZHQIHUn8ENO6-JNgke73wEhloUfGTb0)6Olwy*t!h&6I1i5 zRcy_UD4qbH(m@cX0eY=UE)TE*tN<&(3a|pKz~7+&_H1SHjD6qCvS$TYf&Wqg^?Y#9 z6uK4*gZj|{r%M1}9mCoX>z99^qXvMk#lj#)V8T#=hAM1{A#Cj+3?1{X%`XfZIthJb ztYeQXY=t6h=^-4QPQo?Fo)usPstTyRzeacHn6kb2RQ-M*Gq=BK(=2*9aA!S20_FL`QY_qrB zaW=QM=N)I(>vcQM-K~4`c|)$>+IX;c@apxO+1vTM5BjH*uumPjYWfTR5m7~$V{e?q zX>y1;#k)ox35Gy|@iz(K@J1PEBYn)esm-_J~(QhmxI_~?7VoFZm z`Qm*^{F_UywL>W`Zw4PzSX%Mx@2_}XFYXHBp1jn&|KrwTV+B@Fpk_F2^$zgx?C<|8 ztjrWvfED;x6cF`YZ?})L{qdGtK5{x+6s=#+i3Poc8 diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs deleted file mode 100644 index e7db970..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace StudentsStatisticCore -{ - public class Class1 - { - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs deleted file mode 100644 index c880b95..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentListIsEmptyException.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; -namespace StudentsStatistics.Exceptions -{ - public class StudentsListIsEmptyException : Exception - { - - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs deleted file mode 100644 index e7707af..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Exceptions/StudentsFileDoesNotExistsException.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; -namespace StudentsStatistics.Exceptions -{ - public class StudentsFileDoesNotExistsException : Exception - { - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs deleted file mode 100644 index dfd9fb5..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Student.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace StudentsStatistics -{ - public class Student - { - public string Date { get; private set; } - public string Name { get; private set; } - public string Course { get; private set; } - public string Institute { get; private set; } - public string Dormitory { get; private set; } - - public Student(string date, string name, string course, string insitute, string dormitory) - { - Date = date ?? throw new ArgumentNullException(); - Name = name ?? throw new ArgumentNullException(); - Course = course ?? throw new ArgumentNullException(); - Institute = insitute ?? throw new ArgumentNullException(); - Dormitory = dormitory ?? throw new ArgumentNullException(); - } - } -} - diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs deleted file mode 100644 index 9acfcd4..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentStatisticCalc.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using StudentsStatistics.Views; -using System; -using StudentsStatistics.Exceptions; - -namespace StudentsStatistics -{ - public class StudentStatisticCalc - { - public StatisticView CountInDorm(List studentsList) - { - if (studentsList == null) throw new ArgumentNullException(); - if (studentsList.Count == 0) throw new StudentsListIsEmptyException(); - var indorm = new int[] { }; - var result = new StatisticView(); - - foreach (var element in studentsList) - { - - result.Total++; - if (element.Course == "1 бакалавриат" && element.Dormitory == "Да") - { - result.FirstCourse++; - - } - if (element.Course == "2 бакалавриат" && element.Dormitory == "Да") - { - result.SecondCourse++; - - } - if (element.Course == "3 бакалавриат" && element.Dormitory == "Да") - { - result.ThirdCourse++; - } - } - - return result; - } - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs deleted file mode 100644 index ed45058..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsCreator.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using StudentsStatistics.Exceptions; - -namespace StudentsStatistics -{ - public static class StudentsCreator - { - private static Student FromLine(string line) - { - if (line == null) throw new ArgumentNullException(); - var data = new string[] { }; - data = line.Split(';'); - - return new Student(data[0], data[1], data[2], data[3], data[4]); - } - - public static List ReadStudents(string path) - { - var list = new List(); - try - { - foreach (var line in File.ReadLines(path)) - { - list.Add(FromLine(line)); - - } - } - catch(FileNotFoundException) - { - throw new StudentsFileDoesNotExistsException(); - } - - return list; - } - - - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj deleted file mode 100644 index 075a554..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/StudentsStatisticCore.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - netstandard2.0 - - - - - - - - - - diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs deleted file mode 100644 index ca344f5..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticCore/Views/StatisticView.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace StudentsStatistics.Views -{ - public class StatisticView - { - public int FirstCourse { get; set; } - public int SecondCourse { get; set; } - public int ThirdCourse { get; set; } - public int FourthCourse { get; set; } - public int Total { get; set; } - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln deleted file mode 100644 index 268d4e2..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticsTests", "StudentsStatisticsTests\StudentsStatisticsTests.csproj", "{598857A4-8927-453F-8697-A3C06D4389DB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticsConsoleCore", "StudentsStatisticsCore\StudentsStatisticsConsoleCore.csproj", "{9BC44367-5EA5-43E6-9322-4A58548F2FA9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentsStatisticCore", "StudentsStatisticCore\StudentsStatisticCore.csproj", "{E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {598857A4-8927-453F-8697-A3C06D4389DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {598857A4-8927-453F-8697-A3C06D4389DB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {598857A4-8927-453F-8697-A3C06D4389DB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {598857A4-8927-453F-8697-A3C06D4389DB}.Release|Any CPU.Build.0 = Release|Any CPU - {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9BC44367-5EA5-43E6-9322-4A58548F2FA9}.Release|Any CPU.Build.0 = Release|Any CPU - {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6C18921-C5BD-46C7-BA2E-E54392DDB0C0}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/.DS_Store b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/.DS_Store deleted file mode 100644 index a1aac1c57870e546c5d5178365f1dfeae2cb7f8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM!EVz)5S?vWaDxyLLTb4Ag2bUhX-itE2q{Y1LvNK_$^lSnCl+;ay;bZGXb8%M ze*pe~PvHyr5Iz9j>~5>nanu6`3f-x8W_NaG?0xGUXIvr@&3<=hu|)bA0-F)H~UMVQOLPcaJ6 zVmeZKpN^r8@h1^s3-&3!fu*Dqj6K>`Jfl9o2!!||kYU~f_f<3sF$gdR}|_Z(4@v-(zS6%5i76YG0$5=UuPtNjpjrTK*$ zHyx+!ly8?`d53b~Wq#IAn||*Fk9Pg+Ffjc+DdY3LAM8irpk2Awl1b)AN!U})Q8$Fi z%jZ$jm4l}2C*4%V@$`h_EINzrN_99~-Ka0St84YqvOC<^s4csX*Vad)MQ7>3%F~^L zm{*FUPHsyWo*$qKp0}fc!MQ2DF>%mg54yX zg+5mewmQRB|8v+17n=jI1lR&Py7+vFPdV6()&B~VSzZpBGVLOLa5~`B!cQ1dL=LE* zIiSk9WH9T9f1WtvcXK`|wQ#*qB^rrdQ4CH1lQHg3#VATuDiYSitIBUVpOndnOSy>C z@meaGc8cy#JwTJu7HD7LHz-7K(h|2}$s%w$0wrxy<@$en_V@qG16d1;fJNY+ML^7N zd0S1~{@E|c{7SgicF_*dnAmQtrE&pNI2BbB}!vFvP diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs deleted file mode 100644 index 6400173..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/:Users:danielaristizabaljaramillo:Desktop:SE:StudentsStatistics:StudentsStatisticsTests:Test.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NUnit.Framework; -using System; -namespace StudentsStatisticsTests -{ - [TestFixture()] - public class Test - { - [Test()] - public void TestCase() - { - - } - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj deleted file mode 100644 index 8949b90..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatistics/StudentsStatistics.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - Debug - AnyCPU - {6F144441-95B7-41A4-93C7-6FF98031EB88} - Library - StudentsStatistics - StudentsStatistics - v4.7 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - false - - - true - bin\Release - prompt - 4 - false - - - - - - \ No newline at end of file diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/.DS_Store b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsConsole/.DS_Store deleted file mode 100644 index 2a266f7686fec6bf5a201549b7a8bc70db2014ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!EV$r5FK|H>J38d0jWLag2Z8kwk>532r1f@LvNLW-~gyiny3v*HMgFe@_)v zlojcegR>-s%bQnOk*N7t&5EStaYEA}Wl#2w`kRZz_GowDZ}03b2mWF-8V>x&J5QF& zp4@n__3YsI{KLn^#q!e^^A-d)DVBQ{FX1Z;o8J3yTI8xYMT_?CkODdHTGV_)Pm>z< zy1vwKdM#=^I;1J+IfahsoF35$l})0=MvJJ+m0v2F+PRxoKXVb0#?cO zh@(r^n3wkOBn41W4nKYtn(*_rUY_{b8XwggDt0-@J2y0cm$qZTF>o~ldVlayGzJ!H zgS>S>@f85rMKcR*{`m*`x&atitPP?CB1|aIgbI7b5ccjMOgQ=j>t7o*;UsuwjALgO z_J$(t)kFB~P9iYqv}3?A&}5)vs(pR_Kfn6^-wbj!$ADwtS}`EH`{Di=DcQ4iB{_Z8 t`Y6XJTC`tnkVByCam - - - Debug - AnyCPU - {1CCC4C27-5E6B-4DB6-8C6F-0ADB81D52B1F} - Exe - StudentsStatisticsConsole - StudentsStatisticsConsole - v4.7 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - true - - - true - bin\Release - prompt - 4 - true - - - - - - - - - - - {6F144441-95B7-41A4-93C7-6FF98031EB88} - StudentsStatistics - - - - \ No newline at end of file diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs deleted file mode 100644 index 7fac1e0..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using StudentsStatistics; - -namespace StudentsStatisticsConsole -{ - class MainClass - { - public static void Main(string[] args) - { - // var path = Console.ReadLine(); - var path = "/Users/danielaristizabaljaramillo/Desktop/SE/StudentsStatistics/StudentsStatistics/bin/Debug/Тестирование.csv"; - var loadedStudents = StudentsCreator.ReadStudents(path); - - var studentsStat = new StudentStatisticCalc(); - - var result = studentsStat.CountInDorm(loadedStudents); - - Console.WriteLine($"1: {result.FirstCourse} 2: {result.SecondCourse} 3: {result.ThirdCourse} total: {result.Total}"); - } - } -} diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj deleted file mode 100644 index 1956998..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsCore/StudentsStatisticsConsoleCore.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - netcoreapp2.1 - - - - - - diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj deleted file mode 100644 index 1fbe80b..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/StudentsStatisticsTests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - netcoreapp2.1 - - false - - - - - - - - - - - - - diff --git a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs b/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs deleted file mode 100644 index 8fb371d..0000000 --- a/FirstLesson/DaniDanyelAristizabal-task1/StudentsStatistics/StudentsStatisticsTests/UnitTest1.cs +++ /dev/null @@ -1,36 +0,0 @@ -using StudentsStatistics; -using Xunit; - -namespace StudentsStatisticsTests -{ - public class StudentStatisticsTest - { - [Fact] - public void ParsingisRight() - { - // Arrange - string expected = "test"; - // Act - var StudentTest = new Student("5-3]['", "test", "56]54]['", "56]34[5", "]4]435']6"); - //Assert - Assert.Equal(expected, StudentTest.Name); - - } - - [Fact] - public void FromLineTest(){ - //Arrange - Student expected = new Student("sfnrngjs","we2534","FWEGWE","WEG W GARG "," EGEWG"); - // Act - string AnyString = "sfnrngjs;we2534;FWEGWE;WEG W GARG;EGEWG"; - Student Resulttest = FromLine(AnyString); - - //Assert - Assert.Equal(expected, Resulttest); - - - - } - } - -} diff --git a/FirstLesson/readme.md b/FirstLesson/readme.md deleted file mode 100644 index d135227..0000000 --- a/FirstLesson/readme.md +++ /dev/null @@ -1 +0,0 @@ -First lesson of Margelov Vitaly \ No newline at end of file diff --git a/ForthLesson/readme.md b/ForthLesson/readme.md deleted file mode 100644 index 4681cff..0000000 --- a/ForthLesson/readme.md +++ /dev/null @@ -1 +0,0 @@ -Forth lesson of Margelov Vitaly \ No newline at end of file diff --git a/SecondLesson/readme.md b/SecondLesson/readme.md deleted file mode 100644 index c420268..0000000 --- a/SecondLesson/readme.md +++ /dev/null @@ -1 +0,0 @@ -Second lesson of Margelov Vitaly \ No newline at end of file diff --git a/SixthLesson/readme.md b/SixthLesson/readme.md deleted file mode 100644 index dd112f1..0000000 --- a/SixthLesson/readme.md +++ /dev/null @@ -1 +0,0 @@ -Sixth lesson of Margelov Vitaly \ No newline at end of file diff --git a/ThirdLesson/readme.md b/ThirdLesson/readme.md deleted file mode 100644 index 681ccfd..0000000 --- a/ThirdLesson/readme.md +++ /dev/null @@ -1 +0,0 @@ -Third lesson of Margelov Vitaly \ No newline at end of file From d15d8393aa1641bb15bb5f4ed3e8919221fd2019 Mon Sep 17 00:00:00 2001 From: Dani Danyel Date: Fri, 12 Oct 2018 21:56:09 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=B2=D1=82=D0=BE=D1=80=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=B4=D0=B7=20CarTest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Второй дз CarTest с тестами --- RentCars/RentCars.sln | 23 ++++++++ RentCars/RentCars/AdminFacade.cs | 21 +++++++ RentCars/RentCars/Car.cs | 64 ++++++++++++++++++++++ RentCars/RentCars/CarPark.cs | 57 +++++++++++++++++++ RentCars/RentCars/Costumer.cs | 27 +++++++++ RentCars/RentCars/Interval.cs | 39 +++++++++++++ RentCars/RentCars/Program.cs | 11 ++++ RentCars/RentCars/Rent.cs | 34 ++++++++++++ RentCars/RentCars/RentCars.csproj | 21 +++++++ RentCars/RentCars/UserFacade.cs | 24 ++++++++ RentCars/RentCarsTest/CarParkTest.cs | 52 ++++++++++++++++++ RentCars/RentCarsTest/CarTest.cs | 30 ++++++++++ RentCars/RentCarsTest/IntervalLogicTest.cs | 44 +++++++++++++++ RentCars/RentCarsTest/RentCarsTest.csproj | 22 ++++++++ RentCars/RentCarsTest/RentTest.cs | 28 ++++++++++ 15 files changed, 497 insertions(+) create mode 100644 RentCars/RentCars.sln create mode 100644 RentCars/RentCars/AdminFacade.cs create mode 100644 RentCars/RentCars/Car.cs create mode 100644 RentCars/RentCars/CarPark.cs create mode 100644 RentCars/RentCars/Costumer.cs create mode 100644 RentCars/RentCars/Interval.cs create mode 100644 RentCars/RentCars/Program.cs create mode 100644 RentCars/RentCars/Rent.cs create mode 100644 RentCars/RentCars/RentCars.csproj create mode 100644 RentCars/RentCars/UserFacade.cs create mode 100644 RentCars/RentCarsTest/CarParkTest.cs create mode 100644 RentCars/RentCarsTest/CarTest.cs create mode 100644 RentCars/RentCarsTest/IntervalLogicTest.cs create mode 100644 RentCars/RentCarsTest/RentCarsTest.csproj create mode 100644 RentCars/RentCarsTest/RentTest.cs diff --git a/RentCars/RentCars.sln b/RentCars/RentCars.sln new file mode 100644 index 0000000..599b386 --- /dev/null +++ b/RentCars/RentCars.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RentCars", "RentCars\RentCars.csproj", "{106C5519-D955-40F3-A4AA-F6229D9E29FB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RentCarsTest", "RentCarsTest\RentCarsTest.csproj", "{E3641E35-A492-4547-8D91-FA311E841C38}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {106C5519-D955-40F3-A4AA-F6229D9E29FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {106C5519-D955-40F3-A4AA-F6229D9E29FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {106C5519-D955-40F3-A4AA-F6229D9E29FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {106C5519-D955-40F3-A4AA-F6229D9E29FB}.Release|Any CPU.Build.0 = Release|Any CPU + {E3641E35-A492-4547-8D91-FA311E841C38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E3641E35-A492-4547-8D91-FA311E841C38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E3641E35-A492-4547-8D91-FA311E841C38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E3641E35-A492-4547-8D91-FA311E841C38}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/RentCars/RentCars/AdminFacade.cs b/RentCars/RentCars/AdminFacade.cs new file mode 100644 index 0000000..8e847cd --- /dev/null +++ b/RentCars/RentCars/AdminFacade.cs @@ -0,0 +1,21 @@ +using System; +namespace RentCars +{ + public class AdminFacade + { + string Name { get; } + public AdminFacade(string name) + { + Name = name; + } + public void AddCar(Car car, CarPark carPark) + { + carPark.AddCarToPark(car, carPark); + } + public Rent CreateNewRent(Car rentedcar, Costumer costumerrenting, Interval rentedinterval) + { + var NewRent = new Rent(rentedcar, costumerrenting, rentedinterval); + return NewRent; + } + } +} diff --git a/RentCars/RentCars/Car.cs b/RentCars/RentCars/Car.cs new file mode 100644 index 0000000..c8cf06e --- /dev/null +++ b/RentCars/RentCars/Car.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; + +namespace RentCars +{ + public class Car + { + public string Id { get; } + public int RentCounter { get; set; } + public List RentedIntervals { get; set; } + + public Car(string id) + { + Id = id; + RentCounter = new int(); + RentedIntervals = new List(); + } + public bool CheckMaintenance() + { + bool Maintenance; + if (RentCounter <= 10) + { + Maintenance = true; + return Maintenance; + } + else + { + Maintenance = false; + return Maintenance; + } + } + + public void DoMaintenance(Interval Dayofstart) + { + Dayofstart.MaintenanceInterval(); + RentedIntervals.Add(Dayofstart); + + + } + + public bool Disponibility(Interval IntentionalInterval) + { + + bool Disponible = true; + + for (int i = 0; i < RentedIntervals.Count; i++) + { + if (RentedIntervals[i].TimeIntervalChecker(IntentionalInterval) != true) + { + + return Disponible = false; + + } + + } + + return Disponible; + + + } + + } + +} diff --git a/RentCars/RentCars/CarPark.cs b/RentCars/RentCars/CarPark.cs new file mode 100644 index 0000000..f0474f7 --- /dev/null +++ b/RentCars/RentCars/CarPark.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; + +namespace RentCars +{ + public class CarPark + { + public List AvaiableCars {get; set; } + public List TotalCars { get; set; } + + public CarPark(){ + + + AvaiableCars = new List(); + TotalCars = new List(); + + } + public void AddCarToPark(Car carToAdd, CarPark carPark) + { + carPark.TotalCars.Add(carToAdd); + } + + public List CheckDisponibilityOfCarsOnSpecificInterval(Interval Intended ){ + bool avaiable; + for (int i = 0; i < TotalCars.Count; i++) + { + avaiable = true; + for (int j = 0; j < TotalCars[i].RentedIntervals.Count; j++) + { + + avaiable = TotalCars[i].RentedIntervals[j].TimeIntervalChecker(Intended); + + } + if (avaiable == true) + { + + AvaiableCars.Add(TotalCars[i].Id); + + } + } + return AvaiableCars; + + + } + public List ShowAvaiableCars(){ + + for (int i = 0; i < AvaiableCars.Count; i++) + { + Console.WriteLine(AvaiableCars[i]); + } + return AvaiableCars; + } + + + + } +} diff --git a/RentCars/RentCars/Costumer.cs b/RentCars/RentCars/Costumer.cs new file mode 100644 index 0000000..c01b858 --- /dev/null +++ b/RentCars/RentCars/Costumer.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; + +namespace RentCars +{ + public class Costumer + { + public string CostumerID { get; } + public List RentHistory { get; set; } + public List Rents { get; set; } + + public Costumer(string costumerid) + { + CostumerID = costumerid; + RentHistory = new List(); + Rents = new List(); + } + + public void ShowCostumerHistory(){ + for (int i = 0; i < RentHistory.Count; i++) + { + Console.WriteLine(RentHistory[i]); + } + } + + } +} diff --git a/RentCars/RentCars/Interval.cs b/RentCars/RentCars/Interval.cs new file mode 100644 index 0000000..98bfbef --- /dev/null +++ b/RentCars/RentCars/Interval.cs @@ -0,0 +1,39 @@ +using System; +namespace RentCars +{ + public class Interval + { + + public DateTimeOffset Date1 { get; set; } + public DateTimeOffset Date2 { get; set; } + + public Interval(DateTimeOffset date1, DateTimeOffset date2) + { + + Date1 = date1; + Date2 = date2; + } + + public bool TimeIntervalChecker(Interval IntervalToCheck ) + { + bool Result = false; + if(DateTimeOffset.Compare(Date1, IntervalToCheck.Date1) > 0 && DateTimeOffset.Compare(Date1, IntervalToCheck.Date2) > 0){ + Result = true; + }if(DateTimeOffset.Compare(Date2, IntervalToCheck.Date1) < 0 && DateTimeOffset.Compare(Date2, IntervalToCheck.Date1) < 0) + { + Result = true; + } + return Result; + } + + + public Interval MaintenanceInterval(){ + Date2 = Date2.AddDays(7); + var TenDaysInterval = new Interval(Date1, Date2); + return TenDaysInterval; + } + + + + } +} diff --git a/RentCars/RentCars/Program.cs b/RentCars/RentCars/Program.cs new file mode 100644 index 0000000..d4aadbb --- /dev/null +++ b/RentCars/RentCars/Program.cs @@ -0,0 +1,11 @@ +using System; +namespace RentCars +{ + public class Program + { + public static void Main(string[] args) + { + + } + } +} diff --git a/RentCars/RentCars/Rent.cs b/RentCars/RentCars/Rent.cs new file mode 100644 index 0000000..e588200 --- /dev/null +++ b/RentCars/RentCars/Rent.cs @@ -0,0 +1,34 @@ +using System; +namespace RentCars +{ + public class Rent + { + public Car RentedCar { set; get; } + public Costumer CostumerRenting { set; get; } + public Interval RentedInterval { get; set; } + + public Rent(Car rentedcar, Costumer costumerrenting, Interval rentedinterval) + { + + RentedCar = rentedcar; + CostumerRenting = costumerrenting; + RentedInterval = rentedinterval; + + if (RentedCar.Disponibility(RentedInterval) & RentedCar.CheckMaintenance()) + { + CostumerRenting.Rents.Add(RentedInterval); + CostumerRenting.RentHistory.Add(RentedCar.Id); + RentedCar.RentCounter++; + + } + if (RentedCar.CheckMaintenance() == false) + { + RentedCar.DoMaintenance(RentedInterval); + Console.WriteLine("Cannot rent this car is going to Maintenance"); + }else { + Console.WriteLine("Can not rent this car, it is going to Maintenance"); + + } + } + } +} diff --git a/RentCars/RentCars/RentCars.csproj b/RentCars/RentCars/RentCars.csproj new file mode 100644 index 0000000..f48c46a --- /dev/null +++ b/RentCars/RentCars/RentCars.csproj @@ -0,0 +1,21 @@ + + + + Exe + netcoreapp2.1 + + + + + + + + + + + + + + + + diff --git a/RentCars/RentCars/UserFacade.cs b/RentCars/RentCars/UserFacade.cs new file mode 100644 index 0000000..cc42a8d --- /dev/null +++ b/RentCars/RentCars/UserFacade.cs @@ -0,0 +1,24 @@ +using System; +namespace RentCars +{ + public class UserFacade + { + public Costumer Costumer { get; } + + public UserFacade(Costumer costumer) + { + Costumer = costumer; + } + public void ShowCostumerHistory(){ + + Costumer.ShowCostumerHistory(); + + } + public Rent CreateNewRent(Car rentedcar, Costumer costumerrenting, Interval rentedinterval) + { + var NewRent = new Rent(rentedcar, costumerrenting, rentedinterval); + return NewRent; + } + + } +} diff --git a/RentCars/RentCarsTest/CarParkTest.cs b/RentCars/RentCarsTest/CarParkTest.cs new file mode 100644 index 0000000..32c8c4f --- /dev/null +++ b/RentCars/RentCarsTest/CarParkTest.cs @@ -0,0 +1,52 @@ +using System; +using Xunit; +using RentCars; +using System.Collections.Generic; + +namespace RentCarsTest +{ + public class CarParkTest + { + [Fact] + public void AddCarToPark() + { + // Arrange + var Admin = new AdminFacade("Daniel"); + var newCar = new Car("Red"); + var newCarPark = new CarPark(); + // Act + Admin.AddCar(newCar, newCarPark); + var expected = new List(); + expected.Add(newCar); + //Asert + newCarPark.ShowAvaiableCars(); + Assert.True(expected[0] == newCarPark.TotalCars[0]); + + } + [Fact] + public void CheckDisponibilityOfCarsOnSpecificIntervalTestNotCoorrectDates(){ + + //Arrange + DateTimeOffset date1 = new DateTimeOffset(2018, 10, 1, 0, 0, 0, DateTimeOffset.Now.Offset); + DateTimeOffset date2 = new DateTimeOffset(2018, 10, 10, 0, 0, 0, DateTimeOffset.Now.Offset); + var firstInterval = new Interval(date1, date2); + DateTimeOffset date3 = new DateTimeOffset(2018, 11, 11, 0, 0, 0, DateTimeOffset.Now.Offset); + DateTimeOffset date4 = new DateTimeOffset(2018, 11, 20, 0, 0, 0, DateTimeOffset.Now.Offset); + var secondInterval = new Interval(date3, date4); + var Admin = new AdminFacade("Daniel"); + var newCar = new Car("Red"); + var newCarPark = new CarPark(); + newCar.RentedIntervals.Add(firstInterval); + //Act + Admin.AddCar(newCar, newCarPark); + List result = newCarPark.CheckDisponibilityOfCarsOnSpecificInterval(secondInterval); + var expected = new List(); + expected.Add(newCar.Id); + //Assert + Assert.True(expected[0] == result[0]); + } + + + + } +} diff --git a/RentCars/RentCarsTest/CarTest.cs b/RentCars/RentCarsTest/CarTest.cs new file mode 100644 index 0000000..f728825 --- /dev/null +++ b/RentCars/RentCarsTest/CarTest.cs @@ -0,0 +1,30 @@ +using System; +using RentCars; +using Xunit; + +namespace RentCarsTest +{ + + public class CarTest + { + + [Fact] + public void CheckMaintenance() + { + // Arrange + var newCar = new Car("Red"); + // Act + DateTimeOffset date1 = new DateTimeOffset(2018, 11, 1, 0, 0, 0, DateTimeOffset.Now.Offset); + DateTimeOffset date2 = new DateTimeOffset(2018, 11, 10, 0, 0, 0, DateTimeOffset.Now.Offset); + var firstInterval = new Interval(date1, date2); + newCar.RentCounter = newCar.RentCounter + 10; + bool result = newCar.CheckMaintenance(); + bool expected = true; + //Asert + Assert.True(result == expected); + } + + + + } +} diff --git a/RentCars/RentCarsTest/IntervalLogicTest.cs b/RentCars/RentCarsTest/IntervalLogicTest.cs new file mode 100644 index 0000000..f40f9b3 --- /dev/null +++ b/RentCars/RentCarsTest/IntervalLogicTest.cs @@ -0,0 +1,44 @@ +using System; +using RentCars; +using Xunit; +namespace RentCarsTest +{ + public class IntervalLogicTest + { + [Fact] + public void TimeIntervalInterfereTest() + { + // Arrange + DateTimeOffset date1 = new DateTimeOffset(2018, 10, 1, 0, 0, 0, DateTimeOffset.Now.Offset); + DateTimeOffset date2 = new DateTimeOffset(2018, 10, 10, 0, 0, 0, DateTimeOffset.Now.Offset); + var firstInterval = new Interval(date1, date2); + DateTimeOffset date3 = new DateTimeOffset(2018, 10, 3, 0, 0, 0, DateTimeOffset.Now.Offset); + DateTimeOffset date4 = new DateTimeOffset(2018, 10, 20, 0, 0, 0, DateTimeOffset.Now.Offset); + var secondInterval = new Interval(date3, date4); + // Act + bool result = firstInterval.TimeIntervalChecker(secondInterval); + // Assert + Assert.False(result); + } + [Fact] + public void AddMaintainanceInterval( ){ + // Arrange + DateTimeOffset date1 = new DateTimeOffset(2018, 10, 1, 0, 0, 0, DateTimeOffset.Now.Offset); + DateTimeOffset date2 = new DateTimeOffset(2018, 10, 10, 0, 0, 0, DateTimeOffset.Now.Offset); + var firstInterval = new Interval(date1, date2); + //Act + firstInterval.MaintenanceInterval(); + DateTimeOffset expected = new DateTimeOffset(2018, 10, 17, 0, 0, 0, DateTimeOffset.Now.Offset); + //Assert + bool result; + if(expected == firstInterval.Date2){ + result = true; + }else{ + result = false; + } + Assert.True(result); + + + } + } +} \ No newline at end of file diff --git a/RentCars/RentCarsTest/RentCarsTest.csproj b/RentCars/RentCarsTest/RentCarsTest.csproj new file mode 100644 index 0000000..7e53c9f --- /dev/null +++ b/RentCars/RentCarsTest/RentCarsTest.csproj @@ -0,0 +1,22 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + + + + + + + + diff --git a/RentCars/RentCarsTest/RentTest.cs b/RentCars/RentCarsTest/RentTest.cs new file mode 100644 index 0000000..b873658 --- /dev/null +++ b/RentCars/RentCarsTest/RentTest.cs @@ -0,0 +1,28 @@ +using System; +using RentCars; +using Xunit; +namespace RentCarsTest +{ + public class RentTest + { + [Fact] + public void CreateRentTest() + { + // Arrange + DateTimeOffset date1 = new DateTimeOffset(2018, 10, 1, 0, 0, 0, DateTimeOffset.Now.Offset); + DateTimeOffset date2 = new DateTimeOffset(2018, 10, 10, 0, 0, 0, DateTimeOffset.Now.Offset); + var firstInterval = new Interval(date1, date2); + var newCar = new Car("Red"); + var NewCostumer = new Costumer("CostumerName"); + // Act + var NewRent = new Rent(newCar, NewCostumer, firstInterval); + bool result = false; + if(NewRent.RentedCar.Id == "Red" && NewRent.CostumerRenting.CostumerID == "CostumerName"){ + result = true; + } + bool expected = true; + //Asert + Assert.True(result == expected); + } + } +}