public void UseFsharpOO() { var person = new Person("Bo", "Ipsen", DateTime.Today.AddYears(-33)); var ageCalculator = new AgeCalculator(); var age = ageCalculator.GetAge(person.Birthday); }
static void Main(string[] args) { DateTimeProvider dateTimeProvider = new DateTimeProvider(); AgeCalculator ageCalculator = new AgeCalculator(dateTimeProvider); DateTime BirthDay = new DateTime(2005, 05, 10); int Age = ageCalculator.GetAge(BirthDay); Console.WriteLine(Age); Console.ReadKey(); }
public void Test() { var currentDate = new DateTime(2015, 1, 1); var dateTimeProvider = Mock.Of <IDateTimeProvider>(provider => provider.GetDateTime() == currentDate); var ageCalculator = new AgeCalculator(dateTimeProvider); var dateOfBirth = new DateTime(1990, 1, 1); int age = ageCalculator.GetAge(dateOfBirth); age.Should().Be(25); }
public void AttackArmourBreakTest() { // Arrange: var currentDate = new DateTime(2015, 1, 1); var dateOfBirth = new DateTime(1990, 1, 1); var dateTimeProvider = Mock.Of <IDateTimeProvider>(provider => provider.GetDateTime() == currentDate); var ageCalculator = new AgeCalculator(dateTimeProvider); // Act: int age = ageCalculator.GetAge(dateOfBirth); // Assert: Assert.AreEqual(25, age); }