コード例 #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);
                }
            }
        }
コード例 #2
0
        public void add_installation__set_members__are_equivalent_to__unique_presented_installations()
        {
            // No installation is lost or gained.
            // The union of all group members should match the union of all submitted Installation.
            // The computerID is used here to make the Installation items unique.
            var indexMap = new InstallationIndexMap();

            var installations = new[]
            {
                new Installation(0, UserIdA, 0, ComputerType.Desktop),
                new Installation(1, UserIdA, 0, ComputerType.Desktop),
                new Installation(2, UserIdB, 0, ComputerType.Desktop),
                new Installation(3, UserIdB, 0, ComputerType.Desktop),
                new Installation(4, UserIdB, 0, ComputerType.Desktop),
                new Installation(5, UserIdC, 0, ComputerType.Desktop),
                new Installation(6, UserIdC, 0, ComputerType.Desktop),
                new Installation(7, UserIdD, 0, ComputerType.Desktop),
                // Duplicate of above
                new Installation(0, UserIdA, 0, ComputerType.Desktop),
                new Installation(1, UserIdA, 0, ComputerType.Desktop),
                new Installation(2, UserIdB, 0, ComputerType.Desktop),
                new Installation(3, UserIdB, 0, ComputerType.Desktop),
                new Installation(4, UserIdB, 0, ComputerType.Desktop),
                new Installation(5, UserIdC, 0, ComputerType.Desktop),
                new Installation(6, UserIdC, 0, ComputerType.Desktop),
                new Installation(7, UserIdD, 0, ComputerType.Desktop)
            };

            foreach (var installation in installations)
            {
                indexMap.AddInstallation(installation.UserId, installation);
            }

            var retrievedUniqueInstallations = new HashSet <Installation>();

            foreach (var installationSet in indexMap.Values)
            {
                retrievedUniqueInstallations.UnionWith(installationSet);
            }

            var expectedSet = new HashSet <Installation>();

            expectedSet.UnionWith(installations);

            Assert.That(retrievedUniqueInstallations, Is.EquivalentTo(expectedSet));
        }
コード例 #3
0
        public void add_installation__number_of_index_entries_presented__matches__number_of_value_sets_returned()
        {
            // No index is lost or gained.
            // The count of returned groups should match the number of unique index values presented in Installations.
            // The computerID is used here to make the Installation items unique.

            var indexMap = new InstallationIndexMap();

            const int uniqueUserIdCount = 3;

            indexMap.AddInstallation(UserIdA, new Installation(0, UserIdA, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdA, new Installation(1, UserIdA, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdB, new Installation(2, UserIdB, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdC, new Installation(2, UserIdC, 0, ComputerType.Desktop));

            Assert.That(indexMap.Values.Count(), Is.EqualTo(uniqueUserIdCount));
        }
コード例 #4
0
        public void add_installation__returned_groups__have_unique_index_values()
        {
            // Group indexes are unique.
            // There shouldn't be two or more returned groups with the same index value.
            // The computerID is used here to make the Installation items unique.
            var indexMap = new InstallationIndexMap();

            indexMap.AddInstallation(UserIdA, new Installation(0, UserIdA, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdA, new Installation(1, UserIdA, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdB, new Installation(2, UserIdB, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdB, new Installation(3, UserIdB, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdB, new Installation(4, UserIdB, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdC, new Installation(5, UserIdC, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdC, new Installation(6, UserIdC, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdD, new Installation(7, UserIdD, 0, ComputerType.Desktop));

            var expectedIds = new[] { UserIdA, UserIdB, UserIdC, UserIdD };

            Assert.That(indexMap.Values.Select(gg => gg.First().UserId), Is.EquivalentTo(expectedIds));
        }
コード例 #5
0
        public void add_installation__entries_in_group__all_have_same_index()
        {
            // Group members are determined by index value.
            // All entries in a group should have the same index value.
            // The computerID is used here to make the Installation items unique.
            var indexMap = new InstallationIndexMap();

            indexMap.AddInstallation(UserIdA, new Installation(0, UserIdA, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdA, new Installation(1, UserIdA, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdB, new Installation(2, UserIdB, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdB, new Installation(3, UserIdB, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdB, new Installation(4, UserIdB, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdC, new Installation(5, UserIdC, 0, ComputerType.Desktop));
            indexMap.AddInstallation(UserIdC, new Installation(6, UserIdC, 0, ComputerType.Desktop));

            foreach (var installationSet in indexMap.Values)
            {
                var userId = installationSet.First().UserId;
                Assert.That(installationSet.Any(ii => ii.UserId != userId), Is.False, "Found deviant UserID, doesn't match first in set.");
            }
        }
コード例 #6
0
        public void can_create()
        {
            var indexMap = new InstallationIndexMap();

            Assert.That(indexMap, Is.Not.Null);
        }