public void RetrieveAllEmployeeMetricsSuccess() { System.DateTime dt = new System.DateTime(); List <EmployeeMetrics> dbRetVal = new List <EmployeeMetrics>() { new EmployeeMetrics("lol1", "lol2", "lol3", 1.0, 2.0, 3.0, 4.0, 5.0, dt), new EmployeeMetrics("lul", "lul", "lul", 2.0, 2.0, 2.0, 2.0, 2.0, dt) }; MockServiceProvider serviceProvider = new MockServiceProvider() .AddMockDBConnection(); serviceProvider.MockDBConnection .Setup(_ => _.ExecuteQuery <EmployeeMetrics>(QueryGenerator.GetEmployeeMetricsHeader() + QueryGenerator.WhereRole("Developer"))) .Returns(dbRetVal); EmployeeService employeeService = new EmployeeService(serviceProvider.Build()); List <EmployeeResponse> response = employeeService.RetrieveAllEmployeeMetrics(); Assert.Equal("lol1", response[0].EmployeeId); Assert.Equal(3.0, response[0].Billable.CurrentHours); Assert.Equal(2.0, response[0].Billable.CurrentTarget); Assert.Equal(1.0, response[0].Billable.TotalTarget); Assert.Equal(-1.0, response[0].Growth.HoursRemaining); Assert.Equal(5.0, response[0].Growth.HoursUsed); Assert.Equal(4.0, response[0].Growth.TotalGrowth); Assert.Equal("lul", response[1].EmployeeId); Assert.Equal(2.0, response[1].Billable.CurrentHours); Assert.Equal(2.0, response[1].Billable.CurrentTarget); Assert.Equal(2.0, response[1].Billable.TotalTarget); Assert.Equal(0, response[1].Growth.HoursRemaining); Assert.Equal(2.0, response[1].Growth.HoursUsed); Assert.Equal(2.0, response[1].Growth.TotalGrowth); }
public void RetrieveEmployeeMetricsNoResults() { List <EmployeeMetrics> dbRetVal = new List <EmployeeMetrics>(); MockServiceProvider serviceProvider = new MockServiceProvider() .AddMockDBConnection(); serviceProvider.MockDBConnection .Setup(_ => _.ExecuteQuery <EmployeeMetrics>(QueryGenerator.GetEmployeeMetricsHeader() + QueryGenerator.WhereEmail("*****@*****.**"))) .Returns(dbRetVal); EmployeeService employeeService = new EmployeeService(serviceProvider.Build()); EmployeeResponse response = employeeService.RetrieveEmployeeMetrics("*****@*****.**"); Assert.Null(response); }
public void RetrieveEmployeeInfoNoResults() { List <EttEmployee> dbRetVal = new List <EttEmployee>(); MockServiceProvider serviceProvider = new MockServiceProvider() .AddMockDBConnection(); serviceProvider.MockDBConnection .Setup(_ => _.ExecuteQuery <EttEmployee>(QueryGenerator.GetEmployeeInfo("*****@*****.**"))) .Returns(dbRetVal); EmployeeService employeeService = new EmployeeService(serviceProvider.Build()); EttEmployee response = employeeService.RetrieveEmployeeInfo("*****@*****.**"); Assert.Null(response); }
public void RetrieveAllEmployeeMetricsFail() { List <EmployeeMetrics> dbRetVal = new List <EmployeeMetrics>(); MockServiceProvider serviceProvider = new MockServiceProvider() .AddMockDBConnection(); serviceProvider.MockDBConnection .Setup(_ => _.ExecuteQuery <EmployeeMetrics>(QueryGenerator.GetEmployeeMetricsHeader() + QueryGenerator.WhereRole("Developer"))) .Returns(dbRetVal); EmployeeService employeeService = new EmployeeService(serviceProvider.Build()); var response = employeeService.RetrieveAllEmployeeMetrics(); Assert.Null(response); }
public void RetrieveEmployeeInfoSuccess() { List <EttEmployee> dbRetVal = new List <EttEmployee>() { new EttEmployee("test", "name", "Developer") }; MockServiceProvider serviceProvider = new MockServiceProvider() .AddMockDBConnection(); serviceProvider.MockDBConnection .Setup(_ => _.ExecuteQuery <EttEmployee>(QueryGenerator.GetEmployeeInfo("*****@*****.**"))) .Returns(dbRetVal); EmployeeService employeeService = new EmployeeService(serviceProvider.Build()); EttEmployee response = employeeService.RetrieveEmployeeInfo("*****@*****.**"); Assert.Equal("test", response.FirstName); Assert.Equal("name", response.LastName); Assert.Equal("Developer", response.Role); }
public void InsertRowsSuccess() { MockServiceProvider serviceProvider = new MockServiceProvider() .AddMockDBConnection(); var expectedInsertValue = "INSERT INTO employees(name,office,hours,callibrity_email) VALUES ('testName','Cincinnati',12.5,'*****@*****.**'),('anotherTest','Cincinnati',30,'*****@*****.**')" + " ON CONFLICT (callibrity_email) DO UPDATE SET name=EXCLUDED.name,office=EXCLUDED.office,hours=EXCLUDED.hours"; var testObject1 = new JObject() { { "name", "testName" }, { "office", "Cincinnati" }, { "hours", 12.5 }, { "callibrity_email", "*****@*****.**" }, }; var testObject2 = new JObject() { { "name", "anotherTest" }, { "office", "Cincinnati" }, { "hours", 30 }, { "callibrity_email", "*****@*****.**" }, }; var testList = new List <dynamic>() { testObject1.ToString(), testObject2.ToString() }; serviceProvider.MockDBConnection .Setup(_ => _.ExecuteNonQuery(expectedInsertValue)) .Returns(1); TableService tableService = new TableService(serviceProvider.Build()); var actualResponse = tableService.InsertRows("employees", testList); Assert.Equal(1, actualResponse); }