public async Task AddOrUpdate_Should_ReturnBadRequest() { //Arrange var mockRepository = Substitute.For <IRepository <Funcionario> >(); mockRepository.CreateList(Arg.Any <IEnumerable <Funcionario> >()).Returns(true); var mockLog = Substitute.For <ILogger>(); var mockRequest = NSubstituteHttpRequest.CreateMockRequest(string.Empty); var funcionariosService = new FuncionariosService(mockRepository); //Act var result = await Funcionarios.AddorUpdate(mockRequest, mockLog, funcionariosService); //Assert result.StatusCode.Should().Be(400); }
public async Task GetAll_Should_ReturnOk() { //Arrange var mockRepository = Substitute.For <IRepository <Funcionario> >(); IList <Funcionario> lFuncionarios = new FuncionarioUnitModel().getDefaultFuncionarios(); mockRepository.GetAll().Returns(lFuncionarios); var mockLog = Substitute.For <ILogger>(); var mockRequest = NSubstituteHttpRequest.CreateMockRequest(string.Empty); var funcionariosService = new FuncionariosService(mockRepository); //Act var result = await Funcionarios.GetAll(mockRequest, mockLog, funcionariosService); //Assert result.StatusCode.Should().Be(200); }
public async Task GetAll_Should_ReturnOk() { //Arrange var mockLog = Substitute.For <ILogger>(); var mockRequest = NSubstituteHttpRequest.CreateMockRequest(string.Empty); var mockExecution = new ExecutionContext(); var currentDirectory = new DirectoryInfo(Environment.CurrentDirectory).ToString(); mockExecution.FunctionAppDirectory = currentDirectory; //Act var result = await OpenApi.GetAll(mockRequest, mockLog, mockExecution); //Assert result.StatusCode.Should().Be(200); var content = await result.Content.ReadAsStringAsync(); string.IsNullOrEmpty(content).Should().BeFalse(); content.Should().NotBe("null"); }
public async Task AddOrUpdate_Should_ReturnOk() { //Arrange var mockRepository = Substitute.For <IRepository <Funcionario> >(); mockRepository.CreateList(Arg.Any <IEnumerable <Funcionario> >()).Returns(true); var mockLog = Substitute.For <ILogger>(); IList <Funcionario> lFuncionarios = new FuncionarioUnitModel().getDefaultFuncionarios(); var mockRequest = NSubstituteHttpRequest.CreateMockRequest(lFuncionarios); var funcionariosService = new FuncionariosService(mockRepository); //Act var result = await Funcionarios.AddorUpdate(mockRequest, mockLog, funcionariosService); //Assert result.StatusCode.Should().Be(200); var content = await result.Content.ReadAsStringAsync(); content.Should().Be(lFuncionarios.Count.ToString()); }
public async Task CalculaLucros_Should_ReturnOk() { //Arrange decimal totalDisponibilizado = 100000; var mockRepository = Substitute.For <IRepository <Funcionario> >(); IList <Funcionario> lFuncionarios = new FuncionarioUnitModel().getDefaultFuncionarios(); mockRepository.GetAll().Returns(lFuncionarios); var mockLog = Substitute.For <ILogger>(); var mockRequest = NSubstituteHttpRequest.CreateMockRequest(string.Empty); var funcionariosService = new FuncionariosService(mockRepository); //Act var result = await Funcionarios.CalculaLucros(mockRequest, totalDisponibilizado, mockLog, funcionariosService); //Assert result.StatusCode.Should().Be(200); var content = await result.Content.ReadAsStringAsync(); string.IsNullOrEmpty(content).Should().BeFalse(); content.Should().NotBe("null"); }