Exemplo n.º 1
0
        public void AClassIsNotIgnoredWhenItIsntDiffed()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] { typeof(decimal) });
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 3.1, 4.1 };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
Exemplo n.º 2
0
        public void AClassIsIgnored()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] {typeof (double)});
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 3.1, 4.1 };

            var result = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;
            Assert.True(resultMatch);
        }
Exemplo n.º 3
0
        public void NothingIsIgnoredWhenNothingIsSpecified()
        {
            var calculator = new DiffCalculator();
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 3.1, 4.1 };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
Exemplo n.º 4
0
        public void IgnoresFieldsContainingByType()
        {
            var calculator = new DiffCalculator(ignoreFieldsContainingByType: new Dictionary<Type, string[]> { { typeof(SlightlyDifferentObject), new[] { "String" } } });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
Exemplo n.º 5
0
        public void IgnoresFieldsContaining()
        {
            var calculator = new DiffCalculator(
    ignoreFieldsContaining: new[] { "String" });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
Exemplo n.º 6
0
        public void IgnoresFieldsContaining()
        {
            var calculator = new DiffCalculator(
                ignoreFieldsContaining: new[] { "String" });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
Exemplo n.º 7
0
        private static void Main(string[] args)
        {
            DiffOptions optionValue;
            var         argumentParser = new ArgumentParser();

            if (argumentParser.TryParseArgs(args, out optionValue))
            {
                var diffCalculatorEngine =
                    new DiffCalculator(DiffResultOptionFactory.Instance.Create(optionValue));
                var result = diffCalculatorEngine.Run(optionValue.SourceFile, optionValue.TargetFile);
                result.Print(Console.WriteLine);
            }
        }
Exemplo n.º 8
0
        public void AllMatchesAreIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 2.1, 4.1 };

            var result = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;
            var items = ((ObjectDiff)result).Items;

            Assert.False(resultMatch);
            Assert.Equal(2, items.Count());
        }
Exemplo n.º 9
0
        public void IgnoresFieldsContainingByType()
        {
            var calculator = new DiffCalculator(ignoreFieldsContainingByType: new Dictionary <Type, string[]> {
                { typeof(SlightlyDifferentObject), new[] { "String" } }
            });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
Exemplo n.º 10
0
        public void ItemsFieldIsEmptySet()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 1.1, 2.1, 3.1 };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            Assert.False(items.Any());
        }
Exemplo n.º 11
0
        public void NothingIsIgnoredWhenNothingIsSpecified()
        {
            var calculator = new DiffCalculator();
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 3.1, 4.1
            };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
Exemplo n.º 12
0
        public void AClassIsNotIgnoredWhenItIsntDiffed()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] { typeof(decimal) });
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 3.1, 4.1
            };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
Exemplo n.º 13
0
        public void MatchesAreNotIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: false);
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 1.1, 2.1, 3.1 };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            // Currently <= because there are some hidden fields included
            Assert.True(3 <= items.Count());
        }
Exemplo n.º 14
0
        public void AClassIsIgnored()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] { typeof(double) });
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 3.1, 4.1
            };

            var result      = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;

            Assert.True(resultMatch);
        }
Exemplo n.º 15
0
        public void ItemsFieldIsEmptySet()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                1.1, 2.1, 3.1
            };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            Assert.False(items.Any());
        }
Exemplo n.º 16
0
        public void AllMatchesAreIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 2.1, 4.1
            };

            var result      = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;
            var items       = ((ObjectDiff)result).Items;

            Assert.False(resultMatch);
            Assert.Equal(2, items.Count());
        }
Exemplo n.º 17
0
        public void MatchesAreNotIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: false);
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                1.1, 2.1, 3.1
            };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            // Currently <= because there are some hidden fields included
            Assert.True(3 <= items.Count());
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            BlobClient     blobClient  = new BlobClient(Configuration["Azure:Storage:Blob:ContainerName"], Configuration["Azure:Storage:Blob:ConnectionString"]);
            IndexClient    indexClient = new IndexClient(Configuration["Azure:Search:ServiceName"], Configuration["Azure:Search:IndexName"], Configuration["Azure:Search:IndexerName"], Configuration["Azure:Search:AdminApiKey"]);
            DiffCalculator diffService = new DiffCalculator();

            DocumentsService documentsService = new DocumentsService(blobClient, indexClient, diffService);

            services.AddSingleton <DocumentsService>(documentsService);

            InformationService informationService = new InformationService(Configuration.GetSection("Azure"));

            services.AddSingleton <InformationService>(informationService);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemplo n.º 19
0
 public void Initialize()
 {
     _calculator = new DiffCalculator();
 }
Exemplo n.º 20
0
 public FieldDiffTest()
 {
     _calculator = new DiffCalculator();
 }
Exemplo n.º 21
0
 public override void Given()
 {
     _diffCalculator = new DiffCalculator(new ShowOnlyDifferencesInPerLineStyleResultOption());
 }
Exemplo n.º 22
0
 public ListDiffTest()
 {
     _calculator = new DiffCalculator();
 }
Exemplo n.º 23
0
        public static BaseDiff DiffAgainst(this object baseObject, object antagonist)
        {
            var calculator = new DiffCalculator();

            return(calculator.Diff(baseObject, antagonist));
        }
Exemplo n.º 24
0
 public ObjectDiffTest()
 {
     _calculator = new DiffCalculator();
 }
Exemplo n.º 25
0
 public static BaseDiff DiffAgainst(this object baseObject, object antagonist)
 {
     var calculator = new DiffCalculator();
     return calculator.Diff(baseObject, antagonist);
 }
Exemplo n.º 26
0
 public ObjectDiffTest()
 {
     _calculator = new DiffCalculator();
 }
Exemplo n.º 27
0
 public void Initialize()
 {
     _calculator = new DiffCalculator();
 }
Exemplo n.º 28
0
 public override void Given()
 {
     _diffCalculator = new DiffCalculator(new DefaultDiffResultOption());
 }
Exemplo n.º 29
0
 public FieldDiffTest()
 {
     _calculator = new DiffCalculator();
 }
Exemplo n.º 30
0
 public ListDiffTest()
 {
     _calculator = new DiffCalculator();
 }
 public DocumentsService(BlobClient blobClient, IndexClient indexClient, DiffCalculator diffCalculator)
 {
     this.blobClient     = blobClient;
     this.indexClient    = indexClient;
     this.diffCalculator = diffCalculator;
 }