public void Finance_ReturnsCorrectTotalEmployeesSalaries() { var employees = new List<Employee> { new Employee {Id = 1, Salary = 1000}, new Employee {Id = 2, Salary = 3}, new Employee {Id = 3, Salary = 5000} }; var mockContext = new Mock<InstantDeliveryContext>(); mockContext.Setup(c => c.Employees).ReturnsDbSet(employees); mockContext.Setup(c => c.Packages).ReturnsDbSet(new List<Package>()); var controller = new StatisticsController(mockContext.Object); var result = controller.Finance() as OkNegotiatedContentResult<FinancialStatisticsDto>; Assert.Equal(result?.Content.TotalEmployeesSalaries, 6003); }
public void Finance_ReturnCorrectTotalPackagesValue() { var packages = new List<Package> { new Package {Id = 1, Cost = 1}, new Package {Id = 2, Cost = 3}, new Package {Id = 3, Cost = 5} }; var mockContext = new Mock<InstantDeliveryContext>(); mockContext.Setup(c => c.Packages).ReturnsDbSet(packages); mockContext.Setup(c => c.Employees).ReturnsDbSet(new List<Employee>()); var controller = new StatisticsController(mockContext.Object); var result = controller.Finance() as OkNegotiatedContentResult<FinancialStatisticsDto>; Assert.Equal(result?.Content.TotalPackagesValue, 9); }