[InternalsVisibleToAttribute] for Unit Testing Private Methods

One of the unit testing challenge developers face is – How to Test a Private Method?

Solution: Use InternalsVisibleToAttribute method in .Net Core

// Enter the Assembly Name of the Unit Test project

// Use internal modifier instead of private

[assembly: InternalsVisibleToAttribute(“UnitTestProject1”)]

namespace ConsoleApp7


public class IndustryBL
internal int InternalMethod(int x, int y)
return x + y;


Now we can Invoke the method from Unit Test.

namespace UnitTestProject1

public class UnitTest1
public void TestMethod1()
IndustryBL bl = new IndustryBL();
bl.InternalMethod(2, 3);


Event Hub vs Event Grid vs Service Bus

In this post we can see the different use cases of:

  • Event Hub
  • Event Grid
  • Service Bus

Service Purpose Type Use Case
Event Hub Big Data Handling Event Distribution (Discrete)

Telemetry Data

Eg: Application Insights, Logs

Event Grid Reactive Programming Event Streaming (Series)

Status Changes Reaction

Eg: Approval, Rejection

Service Bus Enterprise Messaging Messaging Order Processing & Financial Transactions


In the below Microsoft example, Event Hub will capture the Big Data, pass to Azure Storage.

An even tis sent to Event Grid which will process the Meta Data.

Azure Function will perform the data migration to SQL Data Warehouse.

Tutorial: Migrate event data to SQL Data Warehouse - Azure Event ...

Computer Vision API–Testing SRK Photo

Computer Vision API provides ready algorithms for processing images – It can classify a picture as object, animal etc.  It can also validate it with Celebrities – all through the machine learning infrastructure of Azure under the hood.


Azure Service

For testing this you need to create the Computer Vision service from Azure > Marketplace.


Choose the S1 tier as most of the capabilities are residing there.


Console Application in C#

Create a Console Application in C# and add the following Nuget package.



As a test I am going to upload above SRK picture & let the Computer Vision API identify him.


The API is successfully identifying SRK! Smile


The Code

using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
using Microsoft.Rest;
using System;
using System.IO;
using System.Net.Http;

namespace ComputerVisionAPI
     class Program
         static void Main(string[] args)
             var features = new VisualFeatureTypes[] { VisualFeatureTypes.Tags, VisualFeatureTypes.Description };

            ComputerVisionClient computerVisionClient = new ComputerVisionClient(
                 new ApiKeyServiceClientCredentials(“YOUR KEY”),
                 new DelegatingHandler[] { }
                 Endpoint = https://URL.cognitiveservices.azure.com/

            using (var fs = new FileStream(@”C:\temp\ShahrukhKhan.png”, FileMode.Open))
                 ImageAnalysis result = computerVisionClient.AnalyzeImageInStreamAsync(fs, features).Result;

                Console.WriteLine(“TAGS >> “);
                 foreach (string tag in result.Description.Tags)
                     Console.Write($” {tag} “);

                Console.WriteLine(Environment.NewLine + Environment.NewLine + “CAPTION >>”);
                 foreach (ImageCaption caption in result.Description.Captions)
                     Console.WriteLine($”{caption.Text} – Confidence: {caption.Confidence} “);




Create an Angular App & Protect with Azure Easy Auth

In this post we can explore how to create an Angular App and Protect it with Azure Authentication Easy Auth without writing any line of code Nor making any configuration changes.

Create Angular App

  1. Install Node.js from https://nodejs.org/en/download/
  2. Open Command Prompt
  3. Run command npm install -g @angular/cli
  4. Create Project ng new AngularAAD
  5. Go inside folder & Run command ng serve
  6. Open the website http://localhost:4200


Publish to Azure

  1. Open Azure Portal
  2. Create new App Service
  3. Publish the Source
  4. Ensure Application accessible through URL

For Detailed Steps use this LINK

Azure AD – Easy Auth Protection

Go to App Service > Authentication Tab

Choose the following options.


Choose the Express settings.


Save Changes!

Now your Angular Application is protected with Azure AD Authentication.

Test Authentication

Go to the App Service > URL > Click to launch it

You will be prompted for Authentication.


This confirms Angular App protection with Azure Easy Auth.


For advanced Configurations like Adding Users, Controlling Rules etc. you should use Azure AD Enterprise Applications page.

How to Disable Outbound Internet from a VM?

In this post we can see how to disable Outbound Internet Connectivity from a VM.

  • Outbound Connections are Originated From the system

Step1 : Create an NSG (Network Security Group)


Step 2: Disable Internet

Go to the Outbound Security Rules.  By default there will be 3 rules which enables Internet. 

We need to create a new rule with Lower Priority Number so it will be picked first.

Click the Add Rule button.  Make the following changes.


Save changes.

Step 3: Associate NSG with VM

Now go to the VM > Change the NSG to the new one.

Step 4: Test Connectivity

Restart the VM > Go to RDP > Open Internet Explorer > Try www.bing.com

You should not get the page displayed.  It ensures Internet Connectivity is disabled now.