public void FatherIsInitilizedAsnull() { Person person = new Person(); Assert.IsNull(person.Father); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Person> _person = test.CreateVariable <Person>(nameof(_person)); test.Arrange(_person, Expr(() => new Person())); test.Assert.IsNull(Expr(_person, p => p.Father)); test.Execute(); }
public void PersonWeightIgnoresAssignmentOfMinusOne() { Person person = new Person("abc"); Assert.ThrowsException <ArgumentException>(() => person.Weight = -0.1); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Person> _person = test.CreateVariable <Person>(nameof(_person)); test.Arrange(_person, Expr(() => new Person("abc"))); test.Assert.ThrowsExceptionOn <ArgumentException>(Expr(_person, p => p.SetWeight(-1.0))); test.Execute(); }
public void AgeIsInitilizedAs0() { Person person = new Person(); Assert.AreEqual(0, person.Age); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Person> _person = test.CreateVariable <Person>(nameof(_person)); test.Arrange(_person, Expr(() => new Person())); test.Assert.AreEqual(Const(0), Expr(_person, p => p.Age)); test.Execute(); }
public void PersonConstructorAssignsNameProperty() { Person person = new Person("abc"); Assert.AreEqual("abc", person.Name); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Person> _person = test.CreateVariable <Person>(nameof(_person)); test.Arrange(_person, Expr(() => new Person("abc"))); test.Assert.AreEqual(Const("abc"), Expr(_person, p => p.Name)); test.Execute(); }
public void CarSorterComparerInitializesToNull() { CarSorter sorter = new CarSorter(); Assert.IsNull(sorter.Comparer); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <CarSorter> _sorter = test.CreateVariable <CarSorter>(); test.Arrange(_sorter, Expr(() => new CarSorter())); test.Assert.IsNull(Expr(_sorter, s => s.Comparer)); test.Execute(); }
public void PairConstructorSetsSnd() { Pair <string, int> pair = new Pair <string, int>("abc", 5); Assert.AreEqual(5, pair.Snd); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Pair <string, int> > _pair = test.CreateVariable <Pair <string, int> >(); test.Arrange(_pair, Expr(() => new Pair <string, int>("abc", 5))); test.Assert.AreEqual(Const(5), Expr(_pair, p => p.Snd)); test.Execute(); }
public void LastNameIsInitializedAsUnnamed() { Person person = new Person(); Assert.AreEqual("Unknown", person.LastName); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Person> _person = test.CreateVariable <Person>(nameof(_person)); test.Arrange(_person, Expr(() => new Person())); test.Assert.AreEqual(Const("Unknown"), Expr(_person, p => p.LastName)); test.Execute(); }
public void EmployeeConstructorNameSetsNameProperty() { Employee employee = new Employee("abc"); Assert.AreEqual("abc", employee.Name); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Employee> _employee = test.CreateVariable <Employee>(nameof(_employee)); test.Arrange(_employee, Expr(() => new Employee("abc"))); test.Assert.AreEqual(Const("abc"), Expr(_employee, e => e.Name)); test.Execute(); }
public void PersonConstructorAssignsMessageProperty() { NotOldEnoughException exception = new NotOldEnoughException("do something"); Assert.AreEqual("Person is too young to do something", exception.Message); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <NotOldEnoughException> _exception = test.CreateVariable <NotOldEnoughException>(); test.Arrange(_exception, Expr(() => new NotOldEnoughException("do something"))); test.Assert.AreEqual(Const("Person is too young to do something"), Expr(_exception, e => e.Message)); test.Execute(); }
public void SenorityIsInitializedAs1() { Employee employee = new Employee("abc"); Assert.AreEqual(1, employee.Seniority); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Employee> _employee = test.CreateVariable <Employee>(nameof(_employee)); test.Arrange(_employee, Expr(() => new Employee("abc"))); test.Assert.AreEqual(Const(1), Expr(_employee, e => e.Seniority)); test.Execute(); }
public void MyQueueConstructorSetsMaxCount() { MyQueue <int> queue = new MyQueue <int>(5); Assert.AreEqual(5, queue.MaxCount); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <MyQueue <int> > _queue = test.CreateVariable <MyQueue <int> >(); test.Arrange(_queue, Expr(() => new MyQueue <int>(5))); test.Assert.AreEqual(Const(5), Expr(_queue, q => q.MaxCount)); test.Execute(); }
public void RegtangleConstructorIgnoresP2ValueNull() { Rectangle rectangle = new Rectangle(new Point(0, 0), null); Assert.IsNotNull(rectangle.P2); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Rectangle> _rectangle = test.CreateVariable <Rectangle>(nameof(_rectangle)); test.Arrange(_rectangle, Expr(() => new Rectangle(new Point(0, 0), null))); test.Assert.IsNotNull(Expr(_rectangle, r => r.P2)); test.Execute(); }
public void MyQueueCountIsInitializedAs0() { MyQueue <int> queue = new MyQueue <int>(5); Assert.AreEqual(0, queue.Count); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <MyQueue <int> > _queue = test.CreateVariable <MyQueue <int> >(); test.Arrange(_queue, Expr(() => new MyQueue <int>(5))); test.Assert.AreEqual(Const(0), Expr(_queue, q => q.Count)); test.Execute(); }
public void CenterIgnoresAssigmentOfNull() { Circle circle = new Circle(null, 1.0); Assert.IsNotNull(circle.Center); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Circle> _circle = test.CreateVariable <Circle>(nameof(_circle)); test.Arrange(_circle, Expr(() => new Circle(null, 1.0))); test.Assert.IsNotNull(Expr(_circle, c => c.Center)); test.Execute(); }
public void RadiusIgnoresAssigmentOfMinusOne() { Circle circle = new Circle(new Point(0, 0), -1.0); Assert.AreNotEqual(-1.0, circle.Radius, 0.001); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Circle> _circle = test.CreateVariable <Circle>(nameof(_circle)); test.Arrange(_circle, Expr(() => new Circle(new Point(0, 0), -1.0))); test.Assert.AreNotEqual(Const(-1.0), Expr(_circle, c => c.Radius), 0.001); test.Execute(); }
public void CarPriceThrowsArgumentExceptionOnAssignmentOfMinusOne() { Car car = new Car(); Assert.ThrowsException <ArgumentException>(() => car.Price = -1M); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Car> _car = test.CreateVariable <Car>(); test.Arrange(_car, Expr(() => new Car())); test.Assert.ThrowsExceptionOn <ArgumentException>(Expr(_car, c => c.SetPrice(-1M))); test.Execute(); }
public void SavingsRateIsInitilizedAs0Point2() { BankAccount account = new BankAccount(); Assert.AreEqual(0.02M, account.SavingsRate); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <BankAccount> _account = test.CreateVariable <BankAccount>(nameof(_account)); test.Arrange(_account, Expr(() => new BankAccount())); test.Assert.AreEqual(Const(0.02M), Expr(_account, a => a.SavingsRate)); test.Execute(); }
public void ImmutableNumberConstructorWithIntAsArgumentSetsValueProperty() { ImmutableNumber number = new ImmutableNumber(2); Assert.AreEqual(2, number.Value); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <ImmutableNumber> _number = test.CreateVariable <ImmutableNumber>(nameof(_number)); test.Arrange(_number, Expr(() => new ImmutableNumber(2))); test.Assert.AreEqual(Const(2), Expr(_number, n => n.Value)); test.Execute(); }
public void DogAgeAssignmentOfMinus1ThrowsArgumentException() { Dog dog = new Dog(); Assert.ThrowsException <ArgumentException>(() => dog.Age = -1); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Dog> _dog = test.CreateVariable <Dog>(); test.Arrange(_dog, Expr(() => new Dog())); test.Assert.ThrowsExceptionOn <ArgumentException>(Expr(_dog, d => d.SetAge(-1))); test.Execute(); }
public void CarCompareToSortsNullFirst() { Car car = new Car(); Assert.IsTrue(car.CompareTo(null) > 0); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Car> _car = test.CreateVariable <Car>(); test.Arrange(_car, Expr(() => new Car())); test.Assert.IsTrue(Expr(_car, c => c.CompareTo(null) > 0)); test.Execute(); }
public void MyQueueDequeueThrowsInvalidOperationException() { MyQueue <int> queue = new MyQueue <int>(5); Assert.ThrowsException <InvalidOperationException>(() => queue.Dequeue()); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <MyQueue <int> > _queue = test.CreateVariable <MyQueue <int> >(); test.Arrange(_queue, Expr(() => new MyQueue <int>(5))); test.Assert.ThrowsExceptionOn <InvalidOperationException, int>(Expr(_queue, q => q.Dequeue())); test.Execute(); }
public void MonthlySalaryIsInitializedAs0() { Employee employee = new Employee("abc"); Assert.AreEqual(0M, employee.MonthlySalary); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Employee> _employee = test.CreateVariable <Employee>(nameof(_employee)); test.Arrange(_employee, Expr(() => new Employee("abc"))); test.Assert.AreEqual(Const(0M), Expr(_employee, e => e.MonthlySalary));; test.Execute(); }
public void BankBalanceIsInitializedAs0M() { BankAccount account = new BankAccount(); Assert.AreEqual(account.Balance, 0M); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <BankAccount> _account = test.CreateVariable <BankAccount>(); test.Arrange(_account, Expr(() => new BankAccount())); test.Assert.AreEqual(Expr(_account, a => a.Balance), Const(0M)); test.Execute(); }
public void CompanyCalculateYearlySalaryCostsReturnsZeroForCompanyWithoutEmployees() { Company company = new Company(); Assert.AreEqual(0M, company.CalculateYearlySalaryCosts()); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Company> _company = test.CreateVariable <Company>(nameof(_company)); test.Arrange(_company, Expr(() => new Company())); test.Assert.AreEqual(Const(0M), Expr(_company, c => c.CalculateYearlySalaryCosts())); test.Execute(); }
public void BonusIsInitializedAs0() { Manager manager = new Manager("abc"); Assert.AreEqual(0M, manager.Bonus); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Manager> _manager = test.CreateVariable <Manager>(nameof(_manager)); test.Arrange(_manager, Expr(() => new Manager("abc"))); test.Assert.AreEqual(Const(0M), Expr(_manager, e => e.Bonus)); test.Execute(); }
public void CourseGetAverageStudentAgeReturnsCorrectly() { Course course = new Course(); Student youngestStudent = new Student() { Age = 19 }; Student oldestStudent = new Student() { Age = 23 }; course.Enroll(youngestStudent); course.Enroll(oldestStudent); Assert.AreEqual(21.0, course.GetAverageStudentAge()); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Course> _course = test.CreateVariable <Course>(); TestVariable <Student> _youngestStudent = test.CreateVariable <Student>(); TestVariable <Student> _oldestStudent = test.CreateVariable <Student>(); test.Arrange(_course, Expr(() => new Course())); test.Arrange(_youngestStudent, Expr(() => new Student() { Age = 19 })); test.Arrange(_oldestStudent, Expr(() => new Student() { Age = 23 })); test.Act(Expr(_course, _youngestStudent, (c, s) => c.Enroll(s))); test.Act(Expr(_course, _oldestStudent, (c, s) => c.Enroll(s))); test.Assert.AreEqual(Const(21.0), Expr(_course, _youngestStudent, (c, s) => c.GetAverageStudentAge())); test.Execute(); }
public void TitleIgnoresAssignmentOfNull() { Employee employee = new Employee("abc"); Assert.AreEqual("Unknown", employee.Title); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Employee> _employee = test.CreateVariable <Employee>(nameof(_employee)); test.Arrange(_employee, Expr(() => new Employee("abc"))); test.Act(Expr(_employee, e => e.SetTitle(null))); test.Assert.AreEqual(Const("Unknown"), Expr(_employee, e => e.Title));; test.Execute(); }
public void CircleCalculateAreaReturnsExpectedOutput() { double expectedValue = 42.3 * 42.3 * Math.PI; Circle circle = new Circle(new Point(0, 0), 42.3); Assert.AreEqual(expectedValue, circle.CalculateArea(), 0.001); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Circle> _circle = test.CreateVariable <Circle>(nameof(_circle)); test.Arrange(_circle, Expr(() => new Circle(new Point(0, 0), 42.3))); test.Assert.AreEqual(Const(expectedValue), Expr(_circle, c => c.CalculateArea()), 0.001); test.Execute(); }
public void ConsoleLoggerWritesToConsole() { ConsoleLogger logger = new ConsoleLogger(); string expectedWriteout = "Customer Ryan Johnson was deleted"; ConsoleAssert.WritesOut(() => logger.Log("Customer Ryan Johnson was deleted"), expectedWriteout); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <ConsoleLogger> _logger = test.CreateVariable <ConsoleLogger>(); test.Arrange(_logger, Expr(() => new ConsoleLogger())); test.ConsoleAssert.WritesOut(Lambda(Expr(_logger, l => l.Log("Customer Ryan Johnson was deleted"))), Const(expectedWriteout)); test.Execute(); }
public void FirstNameIgnoresAssignmentOfNull() { Person person = new Person(); person.FirstName = null; Assert.AreEqual("Unknown", person.FirstName); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Person> _person = test.CreateVariable <Person>(nameof(_person)); test.Arrange(_person, Expr(() => new Person())); test.Act(Expr(_person, p => p.SetFirstName(null))); test.Assert.AreEqual(Const("Unknown"), Expr(_person, p => p.FirstName)); test.Execute(); }