public void Thumbprint_without_bom_should_not_change()
            {
                //Arrange
                var keyStoreMock       = KeyStoreMock;
                var certificateFactory = new CertificateUtility {
                    KeyStoreUtility = keyStoreMock.Object
                };

                //Act
                var certificate = certificateFactory.CreateReceiverCertificate(StringWithoutBom);

                //Assert
                Assert.NotNull(certificate);
                keyStoreMock.Verify(utility => utility.FindCertificate(StringWithoutBom, It.IsAny <X509Store>()));
            }
            public void Calls_remove_bom()
            {
                //Arrange
                var bomUtilityMock     = BomUtilMock;
                var keyStoreMock       = KeyStoreMock;
                var certificateFactory = new CertificateUtility
                {
                    BomUtility      = bomUtilityMock.Object,
                    KeyStoreUtility = keyStoreMock.Object
                };

                //Act
                var certificate = certificateFactory.CreateReceiverCertificate(StringWithBom);

                //Assert
                Assert.NotNull(certificate);
                bomUtilityMock.Verify(utility => utility.RemoveBom(It.IsAny <string>()), Times.Once());
            }
        private static X509Certificate2 GetCertificateFromMockedStore(StoreName storeName, StoreLocation storeLocation,
                                                                      bool isSenderCertificate)
        {
            const string thumbprint = "someUniqueThumbprint";

            var keyStoreUtilityMock = new Mock <KeyStoreUtility>();

            keyStoreUtilityMock
            .Setup(utility => utility
                   .FindCertificate(
                       It.Is <string>(p => p == thumbprint),
                       It.Is <X509Store>(p => p.Location == storeLocation && p.Name == storeName.ToString()))
                   )
            .Returns(new X509Certificate2());

            var certificateUtility = new CertificateUtility {
                KeyStoreUtility = keyStoreUtilityMock.Object
            };

            return(isSenderCertificate
                ? certificateUtility.CreateSenderCertificate(thumbprint)
                : certificateUtility.CreateReceiverCertificate(thumbprint));
        }