<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Manu Radhakrishnan</title>
    <description>The latest articles on DEV Community by Manu Radhakrishnan (@manu_vr).</description>
    <link>https://dev.to/manu_vr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F641999%2F1c5e698b-e17f-42ea-af32-064ae423e082.jpg</url>
      <title>DEV Community: Manu Radhakrishnan</title>
      <link>https://dev.to/manu_vr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manu_vr"/>
    <language>en</language>
    <item>
      <title>Is there any option for Mock EncryptAsync() in Azure.Security.KeyVault.Keys.Cryptography</title>
      <dc:creator>Manu Radhakrishnan</dc:creator>
      <pubDate>Tue, 11 Jun 2024 10:45:40 +0000</pubDate>
      <link>https://dev.to/manu_vr/how-to-mock-encryptasync-in-azuresecuritykeyvaultkeyscryptography-16kg</link>
      <guid>https://dev.to/manu_vr/how-to-mock-encryptasync-in-azuresecuritykeyvaultkeyscryptography-16kg</guid>
      <description>&lt;p&gt;I am trying to mock the functionality of the EncryptAsync method in Azure.Security.KeyVault.Keys.Cryptography.CryptographyClient. &lt;/p&gt;

&lt;p&gt;This is the method I am trying to cover in my unit test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public KeyVaultClientWrapper(KeyClient keyClient, SecretClient secretClient, CryptographyClient cryptographyClient)
    {
        _keyClient = keyClient;
        _cryptographyClient = cryptographyClient;
        _secretClient = secretClient;
    }

    public async Task&amp;lt;EncryptResult&amp;gt; EncryptAsync(string keyName, string algorithm, byte[] plainText, CancellationToken cancellationToken = default)
    {
        return await _cryptographyClient.EncryptAsync(algorithm, plainText, cancellationToken);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm unable to create new object of EncryptResult that needs to returned from the mock EncryptAsync method because there is no &lt;strong&gt;Set&lt;/strong&gt; for EncryptResult&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var _mockKeyVaultClient = new Mock&amp;lt;IKeyVaultClient&amp;gt;();
    var _mockCryptoClient = new Mock&amp;lt;CryptographyClient&amp;gt;();
    mockCryptoClient
            .Setup(client =&amp;gt; client.EncryptAsync(EncryptionAlgorithm.AES, plaintext, default))
            .ReturnsAsync(new EncryptResult { Ciphertext = ciphertext });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How can I change this mock class so that EncryptAsync returns a valid EncryptResult object while running the test method?&lt;/p&gt;

&lt;p&gt;Is there any alternate option for testing the same?&lt;/p&gt;

&lt;p&gt;.NETCore &lt;/p&gt;

</description>
      <category>azure</category>
      <category>keyvault</category>
      <category>dotnetcore</category>
      <category>mock</category>
    </item>
    <item>
      <title>Is there any way to compress the data while using mongo persistence with NEventStore?</title>
      <dc:creator>Manu Radhakrishnan</dc:creator>
      <pubDate>Tue, 19 Jul 2022 04:27:44 +0000</pubDate>
      <link>https://dev.to/manu_vr/is-there-any-way-to-compress-the-data-while-using-mongo-persistence-with-neventstore-41ol</link>
      <guid>https://dev.to/manu_vr/is-there-any-way-to-compress-the-data-while-using-mongo-persistence-with-neventstore-41ol</guid>
      <description>&lt;p&gt;I'm working with C#, Dotnet core, and NeventStore( version- 9.0.1), trying to evaluate various persistence options that it supports out of the box.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More specifically, when trying to use the mongo persistence, the payload is getting stored without any compression being applied.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Note: &lt;strong&gt;Payload compression is happening perfectly when using the SQL persistence of NEventStore whereas not with the mongo persistence.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm using the below code to create the event store and initialize:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private IStoreEvents CreateEventStore(string connectionString) 
    { 
        var store = Wireup.Init() 
                        .UsingMongoPersistence(connectionString,  
                                  new NEventStore.Serialization
                                  .DocumentObjectSerializer()) 
                        .InitializeStorageEngine() 
                        .UsingBsonSerialization() 
                        .Compress() 
                        .HookIntoPipelineUsing() 
                        .Build(); 
        return store; 
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And, I'm using the below code for storing the events:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public async Task AddMessageTostore(Command command) 
{ 
    using (var stream = _eventStore.CreateStream(command.Id)) 
         { 
                stream.Add(new EventMessage { Body = command }); 
                stream.CommitChanges(Guid.NewGuid()); 
         }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The workaround did:&lt;/strong&gt; Implementing the PreCommit(CommitAttempt attempt) and Select methods in IPipelineHook and by using gzip compression logic the compression of events was achieved in MongoDB.&lt;/p&gt;

&lt;p&gt;Attaching data store image of both SQL and mongo persistence:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftnxh6rnjvxc6ao3p9sjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftnxh6rnjvxc6ao3p9sjs.png" alt="Image description" width="555" height="368"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg8felwt59dlzpxfbw0o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg8felwt59dlzpxfbw0o.png" alt="Image description" width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, the questions are&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Is there some other option or setting I'm missing so that the events get compressed while saving(fluent way of calling compress method) ?&lt;/li&gt;
&lt;li&gt;Is the workaround mentioned above sensible to do or is it a performance overhead?&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>neventstore</category>
      <category>mongodb</category>
      <category>compression</category>
      <category>dotnetcore</category>
    </item>
    <item>
      <title>How to effectively do dynamic query using LINQ against a Azure Cosmos Document DB SQL API?</title>
      <dc:creator>Manu Radhakrishnan</dc:creator>
      <pubDate>Wed, 02 Jun 2021 06:09:06 +0000</pubDate>
      <link>https://dev.to/manu_vr/how-to-effectively-do-dynamic-query-using-linq-against-a-azure-cosmos-document-db-sql-api-52nh</link>
      <guid>https://dev.to/manu_vr/how-to-effectively-do-dynamic-query-using-linq-against-a-azure-cosmos-document-db-sql-api-52nh</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AoTUKOcU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/67799375/how-to-effectively-do-dynamic-query-using-linq-against-a-azure-cosmos-document-d" rel="noopener noreferrer"&gt;
            How to effectively do dynamic query using LINQ against a Azure Cosmos Document DB SQL API?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Jun  2 '21&lt;/span&gt;
            &lt;span&gt;Comments: 2&lt;/span&gt;
            &lt;span&gt;Answers: 1&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/67799375/how-to-effectively-do-dynamic-query-using-linq-against-a-azure-cosmos-document-d" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oeieW07A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          0
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h2-sXgSn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I know that Azure Cosmos DB SQL API allows using SQL syntax to query the documents from it and working for me.&lt;/p&gt;
&lt;p&gt;For eg: &lt;code&gt;SELECT * FROM c WHERE c.DynamicContent.MailingAddress.City LIKE '%PORT%'&lt;/code&gt; is working well.&lt;/p&gt;
&lt;p&gt;The data I'm trying to save is like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  "Id": 1001
  "AttentionName": "Keyword list",&lt;/code&gt;&lt;/pre&gt;…
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/67799375/how-to-effectively-do-dynamic-query-using-linq-against-a-azure-cosmos-document-d" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
  </channel>
</rss>
