Ejemplo n.º 1
0
        public void GivinAMissingNestedPropertyObject_WhenMatching_ShouldReturnFalse()
        {
            var expectedRequest = GetRequestDefinition(new { object1 = new { prop1 = "value1" } });
            var actualRequest   = GetRequestDefinition(new { object1 = new { prop2 = "value2" } });

            var bodyComparer = new BodyComparer(expectedRequest, _configurationMock.Object);

            bodyComparer.Matches(actualRequest).Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void GivingObjectsWithDifferentValues_WhenMatching_ShouldReturnFalse()
        {
            var expectedRequest = GetRequestDefinition(new { object1 = new { prop1 = "value-expected" } });
            var actualRequest   = GetRequestDefinition(new { object1 = new { prop1 = "value-actual" } });

            var bodyComparer = new BodyComparer(expectedRequest, _configurationMock.Object);

            bodyComparer.Matches(actualRequest).Should().BeFalse();
        }
Ejemplo n.º 3
0
        public void GivingTwoEqualsANestedObjects_WhenDiffing_ShouldReturnNull()
        {
            var expectedRequest = GetRequestDefinition(new { object1 = new { prop1 = "value1" } });
            var actualRequest   = GetRequestDefinition(new { object1 = new { prop1 = "value1" } });

            var bodyComparer = new BodyComparer(expectedRequest, _configurationMock.Object);

            bodyComparer.DiffGram(actualRequest).Should().BeNull();
        }
Ejemplo n.º 4
0
 public BaseScrapperClient(ScrapperContext context, BodyComparer
                           comparer, string url, int resultId, int interval, int configurationId)
 {
     _comparer       = comparer;
     _url            = url;
     _resultId       = resultId;
     _context        = context;
     _interval       = interval;
     ConfigurationId = configurationId;
     Initialize();
 }
Ejemplo n.º 5
0
        public void GivinAMissingPropertyObject_WhenDiffing_ShouldReturnDifferenceDescription()
        {
            var expectedRequest = GetRequestDefinition(new { object1 = new { prop1 = "value1", prop2 = "value2" } });
            var actualRequest   = GetRequestDefinition(new { object2 = new { otherStuff = "otherValue" } });

            var bodyComparer = new BodyComparer(expectedRequest, _configurationMock.Object);

            bodyComparer.DiffGram(actualRequest)
            .Should().ContainKey("object1")
            .WhichValue?.ToString()
            .Should().BeEquivalentTo(@"{
  ""expected"": ""{\n  \""prop1\"": \""value1\"",\n  \""prop2\"": \""value2\""\n}"",
  ""actual"": ""<Member missing>""
}");
        }
Ejemplo n.º 6
0
        public void GivingObjectsWithDifferentValues_WhenDiffing_ShouldReturnDifferenceDescription()
        {
            var expectedRequest = GetRequestDefinition(new { object1 = new { prop1 = "value-expected" } });
            var actualRequest   = GetRequestDefinition(new { object1 = new { prop1 = "value-actual" } });

            var bodyComparer = new BodyComparer(expectedRequest, _configurationMock.Object);

            bodyComparer.DiffGram(actualRequest)
            .Should().ContainKey("object1.prop1")
            .WhichValue?.ToString()
            .Should().BeEquivalentTo(@"{
  ""expected"": ""value-expected"",
  ""actual"": ""value-actual""
}");
        }
Ejemplo n.º 7
0
        public void AddAndStartOperation(int configurationId)
        {
            var scrappingConfiguration =
                _context.ScrappingConfigurations.Include(item => item.ScrappingResult).Include(item => item.UrlLibrary).Single(item => item.ScrappingConfigurationId == configurationId);
            var scope          = _scopeFactory.CreateScope();
            var taskContext    = scope.ServiceProvider.GetService <ScrapperContext>();
            var bodyComparer   = new BodyComparer(taskContext);
            var scrapperClient = new BaseScrapperClient(taskContext, bodyComparer,
                                                        scrappingConfiguration.UrlLibrary.Url, scrappingConfiguration.ScrappingResult.ScrappingResultId,
                                                        scrappingConfiguration.Interval, scrappingConfiguration.ScrappingConfigurationId);

            if (scrappingConfiguration.ScrappingEnabled)
            {
                scrapperClient.StartScrapping();
            }
            _scrappingTask.Add(scrapperClient);
        }
Ejemplo n.º 8
0
        public void Initialize()
        {
            var toDoList = _context.ScrappingConfigurations.Include(item => item.ScrappingResult)
                           .Include(item => item.UrlLibrary);

            _scrappingTask = new List <BaseScrapperClient>();
            foreach (var scrappingConfiguration in toDoList)
            {
                //Resolving a new context
                var scope          = _scopeFactory.CreateScope();
                var taskContext    = scope.ServiceProvider.GetService <ScrapperContext>();
                var bodyComparer   = new BodyComparer(taskContext);
                var scrapperClient = new BaseScrapperClient(taskContext, bodyComparer,
                                                            scrappingConfiguration.UrlLibrary.Url, scrappingConfiguration.ScrappingResult.ScrappingResultId,
                                                            scrappingConfiguration.Interval, scrappingConfiguration.ScrappingConfigurationId);
                if (scrappingConfiguration.ScrappingEnabled)
                {
                    scrapperClient.StartScrapping();
                }
                _scrappingTask.Add(scrapperClient);
            }
        }