Пример #1
0
        public void GetAgeReturnsCorrectValueFulentBuilder()
        {
            // Arrange
            Employee emp = new EmployeeBuilder().WithBirthDate(new DateTime(1983, 1, 1));

            // Act
            var age = emp.GetAge();

            // Assert
            Assert.AreEqual(age, DateTime.Today.Year - 1983);
        }
        public void TestDataUsingBuilder()
        {
            var birthDate = new DateTime(2000, 11, 30);
            var today     = new DateTime(2020, 11, 30);

            var employee = new EmployeeBuilder().WithFirstName("test").Build();

            Assert.AreEqual("test", employee.FirstName);

            employee = new EmployeeBuilder().WithLastName("test").WithBirthDate(birthDate).Build();
            Assert.AreEqual("", employee.FirstName);
            Assert.AreEqual("test", employee.LastName);
            Assert.AreEqual(birthDate, employee.BirthDate);
            Assert.AreEqual(20, employee.GetAge(today));
        }