Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2db98ed
v1
Sep 12, 2019
9acf321
Initial app
Oct 3, 2019
aeb27bc
Sample of 1st lab
Oct 10, 2019
a0c9c7e
Delete dkjg
localconst Oct 13, 2019
0247220
Tests samples
Oct 17, 2019
beae407
Update README.md
localconst Oct 23, 2019
d514055
Added actions file
jskonst Oct 24, 2019
b29aa60
Fixed run steps (#28)
jskonst Oct 24, 2019
dbae387
Test actions on PR (#30)
jskonst Oct 24, 2019
953427e
Added tests and sample A|B tasks
jskonst Oct 24, 2019
098e5e1
v1.1
Oct 31, 2019
62b5d9e
Added class task example, added vscode conf
Nov 7, 2019
aa0b4b1
Merge branch 'master' of https://github.com/ISUCT/Tprogramming_147_2019
Nov 7, 2019
a8ff28b
Merge branch 'master' into Konstantin_Tyukalov
localconst Nov 17, 2019
1005403
Delete prog.cs
localconst Nov 17, 2019
8ecbcc7
added table function
localconst Nov 17, 2019
ef4495c
Merge branch 'Konstantin_Tyukalov' of https://github.com/QinamruG/Tpr…
localconst Nov 17, 2019
baae003
Update README.md
localconst Nov 20, 2019
25e32f6
Merge branch 'Konstantin_Tjukalov' into Konstantin_Tyukalov
localconst Nov 20, 2019
955f7e4
Still 1st lab
localconst Nov 20, 2019
e427906
Merge branch 'Konstantin_Tyukalov' of https://github.com/QinamruG/Tpr…
localconst Nov 20, 2019
671bff7
v2.2
Nov 21, 2019
f6bd62e
Deleted View mothog from Film
localconst Nov 21, 2019
d306d33
added testsv2
localconst Nov 24, 2019
d67d45c
Added methods for Class
localconst Nov 27, 2019
f25ec02
Fixed some cosmetic issues in Film and DemoTest
localconst Nov 28, 2019
4dd0bcf
Changed tests
localconst Nov 30, 2019
90ff6fd
added ArgumentException(not tested)
localconst Nov 30, 2019
b605ab6
Added override ToString
localconst Nov 30, 2019
58ece7c
Added tests for Film, minor changes in Film.cs
localconst Nov 30, 2019
d3976f3
kicked the platypus out of my swamp
localconst Nov 30, 2019
160b6c6
Renamed DemoTest to ProgTest, added test for Film
localconst Nov 30, 2019
b566509
Case changed for return
qwreq Dec 2, 2019
7406eee
Added Exception, minor fixes
localconst Dec 3, 2019
7ff3a64
added lists (not final), commented 2 tests
localconst Dec 4, 2019
3e3ee23
Tests was changed for collections
localconst Dec 5, 2019
78d7914
Added SuperClass
localconst Dec 10, 2019
7eea7db
Added constructor for SuperClass
localconst Dec 10, 2019
92f6b75
Added class Picture, fixed issues
localconst Dec 12, 2019
20a2e35
Added massive of objects
localconst Dec 13, 2019
990b490
Added 2 tests for polimorhp
localconst Dec 15, 2019
7325764
age calculation
localconst Dec 16, 2019
db2f14c
Tests for age calculation
localconst Dec 16, 2019
fa811ec
Merge branch 'Konstantin_Tjukalov' into Konstantin_Tyukalov
localconst Dec 16, 2019
b2ce0a5
+1(2) test for CalcAge
localconst Dec 17, 2019
2131c56
Merge branch 'Konstantin_Tyukalov' of https://github.com/QinamruG/Tpr…
localconst Dec 17, 2019
b52e192
rewrite age method and tests
localconst Dec 19, 2019
daf7caa
Rewrited AgeCalc for overload
localconst Dec 26, 2019
37a6e0e
Rewrited test
localconst Dec 26, 2019
5d88c97
Fixes
localconst Jan 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions CourseApp.Tests/CalcAgeTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using Xunit;

namespace CourseApp.Tests
{
public class CalcAgeTest
{
[Fact]
public void CorrectAgeInputTest()
{
Assert.Equal(CalcAge.CalculateAge(18, 12, 2000, 19, 12, 2019, true), $"Возраст:19 лет, 0 месяцев, 1 дней");
}

[Fact]
public void FutureDateInputTest()
{
try
{
CalcAge.CalculateAge(16, 6, 2021, true);
}
catch
{
Assert.True(true);
}
}

[Fact]
public void CurrentDayIsBirthdayTest()
{
var day = DateTime.Today.Day;
var month = DateTime.Today.Month;
var year = DateTime.Today.Year;
try
{
Assert.Equal(CalcAge.CalculateAge(12, 12, 2019, 12, 12, 2019, true), $"Возраст:0 лет, 0 месяцев, 0 дней");
}
catch
{
Assert.True(true);
}
}

[Theory]
[InlineData(30, 12, 2000, 18)]
[InlineData(16, 12, 2000, 19)]
public void CurrectYearCountTest(int d, int m, int y, int exp)
{
Assert.Equal($"Возраст:{exp} лет", CalcAge.CalculateAge(d, m, y, 19, 12, 2019, false));
}
}
}
40 changes: 40 additions & 0 deletions CourseApp/CalcAge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;

namespace CourseApp
{
public static class CalcAge
{
public static string CalculateAge(int day, int month, int year, bool fullAge)
{
var today = DateTime.Today;
return CalcAge.CalculateAge(day, month, year, today.Day, today.Month, today.Year, fullAge);
}

public static string CalculateAge(int day, int month, int year, int currDay, int currMonth, int currYear, bool fullAge)
{
var birthday = new DateTime(year, month, day);
var today = new DateTime(currYear, currMonth, currDay);

if (birthday.Ticks > today.Ticks)
{
throw new Exception("you cannot enter a date that did not occur");
}
else if (birthday.Ticks == today.Ticks)
{
throw new Exception("he/she/you was born today");
}
else
{
var age = new DateTime(today.Ticks - birthday.Ticks);
if (fullAge == true)
{
return $"Возраст:{age.Year - 1} лет, {age.Month - 1} месяцев, {age.Day - 1} дней";
}
else
{
return $"Возраст:{age.Year - 1} лет";
}
}
}
}
}
2 changes: 2 additions & 0 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static void Main(string[] args)
Console.WriteLine($"y={item}");
}

Console.WriteLine(CalcAge.CalculateAge(28, 6, 2000, true));

Console.ReadLine();
}
}
Expand Down