public void SaveDescriptorDoesntDuplicate()
        {
            AssemblyManagementRepository repo = GetTestRepo(nameof(SaveDescriptorDoesntDuplicate));

            AssemblyDescriptor descriptor = new AssemblyDescriptor(Assembly.GetExecutingAssembly());

            AssemblyDescriptor one = repo.Save(descriptor);
            AssemblyDescriptor two = repo.Save(descriptor);

            Expect.IsNotNull(one, "first save returned null");
            Expect.IsNotNull(two, "second save returned null");
            Expect.AreEqual(one.Id, two.Id, "Ids didn't match");
            Expect.AreEqual(one.Uuid, two.Uuid, "Uuids didn't match");

            Dao.AssemblyDescriptorCollection descriptors = Dao.AssemblyDescriptor
                                                           .Where(q =>
                                                                  q.AssemblyFullName == descriptor.AssemblyFullName &&
                                                                  q.FileHash == descriptor.FileHash &&
                                                                  q.Name == descriptor.Name, repo.Database);

            Expect.AreEqual(1, descriptors.Count);
        }
        public void SaveDescriptorSavesReferences()
        {
            AssemblyManagementRepository repo = GetAssemblyManagementRepository(GetConsoleLogger(), nameof(SaveDescriptorSavesReferences));

            repo.Database.TryEnsureSchema <Dao.AssemblyDescriptor>();
            AssemblyDescriptor[] descriptors = AssemblyDescriptor.GetCurrentAppDomainDescriptors().ToArray();

            foreach (AssemblyDescriptor descriptor in descriptors)
            {
                int?referenceCount = descriptor.AssemblyReferenceDescriptors?.Count;
                if (referenceCount > 0)
                {
                    AssemblyDescriptor wrapped   = repo.Save(descriptor);
                    AssemblyDescriptor retrieved = repo.Retrieve <AssemblyDescriptor>(wrapped.Id);
                    Expect.AreEqual(referenceCount, retrieved.AssemblyReferenceDescriptors?.Count);
                    Pass(descriptor.AssemblyFullName + " " + referenceCount.ToString());
                }
                else
                {
                    Message.PrintLine("No references: {0}", ConsoleColor.Cyan, descriptor.AssemblyFullName);
                }
            }
        }