public void Should_Be_Show_Report_When_Get_All_Customer() { var fakeCustomerRepository = new FakeCustomerRepository( new List <Customer>() { new Customer() { Id = 1, FirstName = "Fake Firstname1", LastName = "Fake Lastname1", BirthDate = new DateTime(1994, 01, 11), Gender = "Fake Male", Age = new DateTime(1994, 01, 11).CalculateAge() }, new Customer() { Id = 2, FirstName = "Fake Firstname2", LastName = "Fake Lastname2", BirthDate = new DateTime(1975, 07, 02), Gender = "Fake Male", Age = new DateTime(1975, 07, 02).CalculateAge() }, new Customer() { Id = 3, FirstName = "Fake Firstname3", LastName = "Fake Lastname3", BirthDate = new DateTime(1987, 11, 04), Gender = "Fake Female", Age = new DateTime(1987, 11, 04).CalculateAge() }, new Customer() { Id = 4, FirstName = "Fake Firstname4", LastName = "Fake Lastname4", BirthDate = new DateTime(1997, 04, 02), Gender = "Fake Female", Age = new DateTime(1997, 04, 02).CalculateAge() } }, null); reportService = new ReportService(fakeCustomerRepository); Report report = reportService.ShowCustomerReport(); Assert.NotNull(report); Assert.Equal(4, report.Customers.Count()); Assert.Equal(31.25, report.AverageDatas.AverageAge); Assert.Equal(35, report.AverageDatas.AverageAgeMale); Assert.Equal(27.5, report.AverageDatas.AverageAgeFemale); Assert.Equal(4, report.AverageDatas.Total); Assert.Equal(2, report.AverageDatas.TotalMale); Assert.Equal(2, report.AverageDatas.TotalFemale); }
public void Should_Be_Calculate_Age_When_Get_All_Customer() { var fakeCustomerRepository = new FakeCustomerRepository( new List <Customer>() { new Customer() { Id = 1, FirstName = "Fake Firstname1", LastName = "Fake Lastname1", BirthDate = new DateTime(1994, 01, 11), Gender = "Fake Male", Age = new DateTime(1994, 01, 11).CalculateAge() }, new Customer() { Id = 2, FirstName = "Fake Firstname2", LastName = "Fake Lastname2", BirthDate = new DateTime(1975, 07, 02), Gender = "Fake Male", Age = new DateTime(1975, 07, 02).CalculateAge() }, new Customer() { Id = 3, FirstName = "Fake Firstname3", LastName = "Fake Lastname3", BirthDate = new DateTime(1987, 11, 04), Gender = "Fake Female", Age = new DateTime(1987, 11, 04).CalculateAge() }, new Customer() { Id = 4, FirstName = "Fake Firstname4", LastName = "Fake Lastname4", BirthDate = new DateTime(1997, 04, 02), Gender = "Fake Female", Age = new DateTime(1997, 04, 02).CalculateAge() } }, null); reportService = new ReportService(fakeCustomerRepository); var customers = reportService.GetCustomers().ToList(); Assert.NotNull(customers); Assert.Equal(4, customers.Count()); Assert.Equal(3, customers[2].Id); Assert.Equal("Fake Firstname3", customers[2].FirstName); Assert.Equal("1987-11-04", customers[2].BirthDate.FormatShortDate()); Assert.Equal("Fake Female", customers[2].Gender); Assert.Equal(32, customers[2].Age); }
public void Should_False_When_Incorrect_Add_Customer() { var fakeCustomerRepository = new FakeCustomerRepository(null, null); customerService = new CustomerService(fakeCustomerRepository); var customer = customerService.AddCustomer(null); Assert.False(customer); }
public void Should_Null_Customer_When_No_Data_From_Get_Customer_By_Id() { var fakeCustomerRepository = new FakeCustomerRepository(null, null); customerService = new CustomerService(fakeCustomerRepository); var customer = customerService.GetCustomerById(999); Assert.Null(customer); }
public void Should_True_When_Incorrect_Delete_Customer() { var fakeCustomerRepository = new FakeCustomerRepository(null, null, true); customerService = new CustomerService(fakeCustomerRepository); var customer = customerService.DeleteCustomer(999); Assert.True(customer); }
public void Should_Blank_List_Customer_When_No_Data_From_Get_All_Customer() { var fakeCustomerRepository = new FakeCustomerRepository(new List <Customer>(), null); customerService = new CustomerService(fakeCustomerRepository); var customers = customerService.GetCustomers(); Assert.NotNull(customers); Assert.Equal(0, customers?.Count() ?? 0); }
public void Should_Customer_When_Get_Customer_By_Id() { var fakeCustomerRepository = new FakeCustomerRepository(null, new Customer() { Id = 999 }); customerService = new CustomerService(fakeCustomerRepository); var customer = customerService.GetCustomerById(999); Assert.NotNull(customer); Assert.Equal(999, customer.Id); }
public void Should_List_Customer_When_Get_All_Customer() { var fakeCustomerRepository = new FakeCustomerRepository( new List <Customer>() { new Customer() { Id = 1, FirstName = "Fake Firstname", LastName = "Fake Lastname", BirthDate = DateTime.MinValue } }, null); customerService = new CustomerService(fakeCustomerRepository); var customers = customerService.GetCustomers(); var customer = customers.FirstOrDefault(); Assert.NotNull(customers); Assert.Equal(1, customers?.Count() ?? 0); Assert.Equal("Fake Firstname", customer.FirstName); Assert.Equal("Fake Lastname", customer.LastName); Assert.Equal(DateTime.MinValue, customer.BirthDate); }