コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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");
        }