public void ByFriendlyName_NoneMatching_ReturnsNull()
        {
            Mock<IX509Store> storeMock = new Mock<IX509Store>();
            storeMock.Setup(mock => mock.Certificates).Returns(new X509Certificate2CollectionFake { new X509Certificate2Fake() });

            Certificate result = new CertificateLookup("FindMe", new[] { StoreName.My }, name => storeMock.Object)
                .ByFriendlyName();

            Assert.Null(result);
        }
        public void ByFriendlyName_OneMatching_ReturnsCertificate()
        {
            Mock<IX509Store> storeMock = new Mock<IX509Store>();
            storeMock.Setup(mock => mock.Certificates).Returns(new X509Certificate2CollectionFake
            {
                new X509Certificate2Fake(),
                new X509Certificate2Fake(),
                new X509Certificate2Fake(friendlyName: "FindMe", thumbprint: "FindMe")
            });

            Certificate result = new CertificateLookup("FindMe", new[] { StoreName.My }, name => storeMock.Object)
                .ByFriendlyName();

            Assert.Equal(result.FriendlyName, "FindMe");
            Assert.Equal(result.Thumbprint, "FindMe");
        }
        public void ByFriendlyName_OneMatchingInSecondaryStore_ReturnsCertificate()
        {
            Dictionary<StoreName, Mock<IX509Store>> storeMocks = new Dictionary<StoreName, Mock<IX509Store>>();
            storeMocks[StoreName.My] = CreateX509StoreMock(new X509Certificate2CollectionFake
            {
                new X509Certificate2Fake(),
                new X509Certificate2Fake()
            });
            storeMocks[StoreName.Root] = CreateX509StoreMock(new X509Certificate2CollectionFake
            {
                new X509Certificate2Fake(),
                new X509Certificate2Fake(friendlyName: "FindMe", thumbprint: "FindMe")
            });

            Certificate result = new CertificateLookup("FindMe", new[] { StoreName.My, StoreName.Root }, name => storeMocks[name].Object)
                .ByFriendlyName();

            Assert.Equal(result.FriendlyName, "FindMe");
            Assert.Equal(result.Thumbprint, "FindMe");
        }