public void TestShoulReturnTwoParticipations() { var employee = Stubs.ValidEmployee(); var request = Stubs.ValidRequest(); _employeeGatewayMock.List().Returns(new List <Employee>() { employee, employee }); var useCase = new UseCase( _loggerGatewayMock, _employeeGatewayMock, _calculationInfluenceGateway ); var response = useCase.Execute(request); var participations = response.Distribution.Participations; Assert.Equal(36565056, response.Distribution.TotalDistributed); Assert.Same(employee, participations[0].Employee); Assert.Equal(request.AvailableValue, response.Distribution.TotalAvailable); Assert.Equal(2, participations.Count); }
public void TestShouldReturnFindEmployeeException() { _employeeGatewayMock.List().Returns(x => { throw new Exception(); }); var useCase = new UseCase( _loggerGatewayMock, _employeeGatewayMock, _calculationInfluenceGateway ); Assert.Throws <FindEmployeeException>(() => useCase.Execute(Stubs.ValidRequest())); }
public void TestShouldReturnGenericException() { _employeeGatewayMock.List().Returns(new List <Employee>() { Stubs.ValidEmployee() }); _loggerGatewayMock.When(fake => fake.Info(Arg.Any <string>())).Do(call => { throw new Exception("Generic exception"); }); var useCase = new UseCase( _loggerGatewayMock, _employeeGatewayMock, _calculationInfluenceGateway ); Assert.Throws <Exception>(() => useCase.Execute(Stubs.ValidRequest())); }
public void TestShouldReturnGetCalculationInfluenceException() { var employee = Stubs.ValidEmployee(); _employeeGatewayMock.List().Returns(new List <Employee>() { employee }); var calculationInfluenceGatewayMock = Substitute.For <CalculationInfluenceGateway>(); calculationInfluenceGatewayMock.GetCalculationInfluence(employee).Returns(x => { throw new Exception(); }); var useCase = new UseCase( _loggerGatewayMock, _employeeGatewayMock, calculationInfluenceGatewayMock ); Assert.Throws <GetCalculationInfluenceException>(() => useCase.Execute(Stubs.ValidRequest())); }
public void TestShouldReturnCalculationInfluenceAreaNotFoundException() { _employeeGatewayMock.List().Returns(new List <Employee>() { Stubs.EmployeeWithInvalidArea() }); var useCase = new UseCase( _loggerGatewayMock, _employeeGatewayMock, _calculationInfluenceGateway ); Assert.Throws <CalculationInfluenceAreaNotFoundException>(() => useCase.Execute(Stubs.ValidRequest())); }