Exemplo n.º 1
0
        public void is_large_test_data_conflict_free()
        {
            const string fileName = @"..\..\..\..\..\test\sample-large.csv";

            var reportLoader = new ReportLoader.ReportLoader();

            var mappingResults = reportLoader.LoadReportData(fileName);

            var reportToModelConverter = new ReportToModelConverter();

            var installations = reportToModelConverter.ConvertReportData(mappingResults);


            var installationIndexMap = new InstallationIndexMap();
            // This is a variant catalog, where we index by ComputerID.
            var installationCatalog = new InstallationCatalogByComputer(installationIndexMap);


            installationCatalog.AddInstallationsByComputer(installations);

            foreach (var installationSet in installationIndexMap.Values)
            {
                // As the set contains only items with the same ComputerId, if we have multiple ComputerTypes, it's a concern.

                if (installationSet.Any())
                {
                    var firstComputerType = installationSet.First().ComputerType;

                    Assert.That(installationSet.Any(ii => ii.ComputerType != firstComputerType), Is.False);
                }
            }
        }
Exemplo n.º 2
0
        public void convert_report_data__all_valid_input__returns__expected_result_count()
        {
            var converter = new ReportToModelConverter();

            var output = converter.ConvertReportData(_allValid);

            Assert.That(output, Is.Not.Null);
            Assert.That(output.Count, Is.EqualTo(_allValid.Count));
        }
Exemplo n.º 3
0
        public void convert_report_data__empty_input__returns__empty_output()
        {
            var converter = new ReportToModelConverter();

            var emptyInput = new List <CsvMappingResult <InstallationData> >();

            var output = converter.ConvertReportData(emptyInput);

            Assert.That(output, Is.Not.Null);
            Assert.That(output, Is.Empty);
        }
Exemplo n.º 4
0
        public void convert_report_data__some_invalid_input__returns__only_valid_items()
        {
            var converter = new ReportToModelConverter();

            var output = converter.ConvertReportData(_invalidIndex1);

            Assert.That(output, Is.Not.Null);
            Assert.That(output.Count, Is.EqualTo(_invalidIndex1.Count - 1));

            Assert.That(output.First().ComputerId, Is.Not.EqualTo(_data1.ComputerId));
            Assert.That(output.Last().ComputerId, Is.Not.EqualTo(_data1.ComputerId));
        }
Exemplo n.º 5
0
        public void convert_report_data__all_valid_input__returns__last_converted_row_as_expected()
        {
            var converter = new ReportToModelConverter();

            var output = converter.ConvertReportData(_allValid);

            Assert.That(output, Is.Not.Null);
            Assert.That(output.Any());

            var installation = output.Last();

            Assert.That(installation.ComputerId, Is.EqualTo(_data2.ComputerId));
            Assert.That(installation.UserId, Is.EqualTo(_data2.UserId));
            Assert.That(installation.ApplicationId, Is.EqualTo(_data2.ApplicationId));
            Assert.That(installation.ComputerType, Is.EqualTo(_data2.ComputerType));
        }