Пример #1
0
        public void TEMPLATE_IS_PUT_WHEN_IS_VALID()
        {
            //Arrange
            var template = new TemplateInfo(_fileAccessor, _eventWriter)
            {
                FileName = "file",
                Name     = "template"
            };
            var rawBody = "body";

            _fileAccessor.Exists("file").Returns(true);
            _fileAccessor.ReadAllText(template.FileName).Returns(rawBody);
            template.ActivateOptions();
            var appender = new ElasticSearchAppender(_elasticClientFactory, "index", "type", _timer,
                                                     _tolerateCallsFactory,
                                                     _bulk, _logEventConverterFactory, _elasticFilters, _fileAccessor, _eventWriter)
            {
                Template = template
            };

            //Act
            appender.ActivateOptions();

            //Assert
            _elasticClient.Received().PutTemplateRaw(template.Name, rawBody);
        }
Пример #2
0
        public void TEMPLATE_IS_NOT_VALID_WHEN_NAME_IS_NULL()
        {
            //Arrange
            var template = new TemplateInfo(_fileAccessor, _eventWriter)
            {
                Name = null, FileName = "file"
            };

            //Act
            template.ActivateOptions();

            //Assert
            template.IsValid.Should().BeFalse();
        }
Пример #3
0
        public void TEMPLATE_IS_NOT_VALID_WHEN_FILENAME_IS_EMPTY()
        {
            //Arrange
            var template = new TemplateInfo(_fileAccessor, _eventWriter)
            {
                Name = "name", FileName = string.Empty
            };

            //Act
            template.ActivateOptions();

            //Assert
            template.IsValid.Should().BeFalse();
        }
Пример #4
0
        public void TEMPLATE_IS_NOT_VALID_WHEN_FILE_DOES_NOT_EXIST()
        {
            //Arrange
            var template = new TemplateInfo(_fileAccessor, _eventWriter)
            {
                Name = "name", FileName = "file"
            };

            _fileAccessor.Exists(template.FileName).Returns(false);
            //Act
            template.ActivateOptions();

            //Assert
            template.IsValid.Should().BeFalse();
        }
Пример #5
0
        public void TEMPLATE_IS_VALID_WHEN_ALL_PARAMETERS_ARE_VALID()
        {
            //Arrange
            var template = new TemplateInfo(_fileAccessor, _eventWriter)
            {
                Name = "name", FileName = "file"
            };

            _fileAccessor.Exists(template.FileName).Returns(true);
            //Act
            template.ActivateOptions();

            //Assert
            template.IsValid.Should().BeTrue();
        }