BreakCalculatorExtensionText.cs (2634B)
1 // BSD 3-Clause License 2 // Copyright(c) 2018-2020 René Wagner 3 // https://git.sr.ht/~rwa/worktimehero 4 5 using System; 6 using Microsoft.VisualStudio.TestTools.UnitTesting; 7 using WorkTimeHero; 8 9 namespace WorkTimeHeroTest 10 { 11 [TestClass] 12 public class BreakCalculatorExtensionText 13 { 14 [TestMethod] 15 public void CalculateBreak_CalledOnWorkTime1Hour_ReturnsTimeSpan() 16 { 17 TimeSpan result = new TimeSpan( 1, 0, 0 ).CalculateBreak(); 18 19 Assert.AreEqual( new TimeSpan(), result ); 20 } 21 22 [TestMethod] 23 public void CalculateBreak_CalledOnWorkTime30Minutes_ReturnsTimeSpan() 24 { 25 TimeSpan result = new TimeSpan( 0, 30, 0 ).CalculateBreak(); 26 27 Assert.AreEqual( new TimeSpan(), result ); 28 } 29 30 [TestMethod] 31 public void CalculateBreak_CalledOnWorkTime2Hours30Minutes_ReturnsTimeSpan() 32 { 33 TimeSpan result = new TimeSpan( 2, 30, 0 ).CalculateBreak(); 34 35 Assert.AreEqual( new TimeSpan(0, 15, 0), result ); 36 } 37 38 [TestMethod] 39 public void CalculateBreak_CalledOnWorkTime2Hours5Minutes_ReturnsTimeSpan() 40 { 41 TimeSpan result = new TimeSpan( 2, 05, 0 ).CalculateBreak(); 42 43 Assert.AreEqual( new TimeSpan( 0, 5, 0 ), result ); 44 } 45 46 [TestMethod] 47 public void CalculateBreak_CalledOnWorkTime4Hours10Minutes_ReturnsTimeSpan() 48 { 49 TimeSpan result = new TimeSpan( 4, 10, 0 ).CalculateBreak(); 50 51 Assert.AreEqual( new TimeSpan( 0, 15, 0 ), result ); 52 } 53 54 [TestMethod] 55 public void CalculateBreak_CalledOnWorkTime4Hours24Minutes_ReturnsTimeSpan() 56 { 57 TimeSpan result = new TimeSpan( 4, 24, 0 ).CalculateBreak(); 58 59 Assert.AreEqual( new TimeSpan( 0, 24, 0 ), result ); 60 } 61 62 63 [TestMethod] 64 public void CalculateBreak_CalledOnWorkTime5Hours2Minutes_ReturnsTimeSpan() 65 { 66 TimeSpan result = new TimeSpan( 5, 2, 0 ).CalculateBreak(); 67 68 Assert.AreEqual( new TimeSpan( 0, 30, 0 ), result ); 69 } 70 71 [TestMethod] 72 public void CalculateBreak_CalledOnWorkTime10Hours_ReturnsTimeSpan() 73 { 74 TimeSpan result = new TimeSpan( 10, 0, 0 ).CalculateBreak(); 75 76 Assert.AreEqual( new TimeSpan( 0, 45, 0 ), result ); 77 } 78 79 [TestMethod] 80 public void CalculateBreak_CalledOnWorkTime6Hours35_ReturnsTimeSpan() 81 { 82 TimeSpan result = new TimeSpan( 6, 35, 0 ).CalculateBreak(); 83 84 Assert.AreEqual( new TimeSpan( 0, 35, 0 ), result ); 85 } 86 } 87 }