Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Blog
  • Questions
  • Learning
    • E-learning Courses
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Tutorials
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • DataMiner Insights
      • Security
      • Integration Studio
      • System Architecture
      • DataMiner Releases & Updates
      • DataMiner Apps
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
  • Downloads
  • More
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
      • General Inquiries
      • DataMiner DevOps Support
      • Commercial Requests
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Unit Testing Mocking for Protocols

Solved1.79K views7th July 2023protocol development Unit Tests
11
Rebecca Kelsall [DevOps Advocate]670 8th March 2023 0 Comments

Has anyone had success in building a Mocking Library to mimic the SLProtocol/SLProtocolExt for unit testing for protocol development?

Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 7th July 2023

3 Answers

  • Active
  • Voted
  • Newest
  • Oldest
2
Avatar photo
Jan Staelens [SLC] [DevOps Advocate]889 Posted 27th April 2023 1 Comment

There does exist a framework that allows writing unit tests and mocking SLProtocol in a way that you just provide what your expected end-result should be. It doesn't care if you used setcolumn, setrow, fillarray and will just check if your 'final table data' matches what you expect.

This was being worked on by several devops engineers when they encountered the same difficulties after we introduced unit testing for QActions.

I believe this will likely help. You'll lose some details on how you perform sets, which can also be important! But it does help a lot to avoid regression when refactoring and writing tests quicker.

That library is currently a NuGet that's still internal and in beta. But it's going through the last few steps to make it public.

I can check with our PO and the developers of the library to give it a little push.

Example

```csharp
[TestMethod()] [DeploymentItem(@"TestFiles\response_content.xml")] public void TestCallback()
{
// Arrange
var protocolModel = new ProtocolModelExt(path);
var protocolMock = new SLProtocolMock(protocolModel);

string responseContent = File.ReadAllText("response_content.xml");
var response = new HttpResponse("uri", "HTTP1.1 200 OK", responseContent);
var callback = new GetMediaUsageByUtRangeResponse();

// Act
callback.Run(protocolMock.Object, response);

// Assert
mock.Assert()
.Table(Parameter.Mediainstancesusagetable.tablePid)
.Column(Parameter.Mediainstancesusagetable.Pid.mediainstancesusagetableid_2401)
.Should()
.Contain("test");
}
```

another example:

```csharp
# AddRow
// Create a new Protocol Model
var protocolModel = new ProtocolModelExt(path);

// Create a new SLProtocolMock and pass it the Protocol Model
var mock = new SLProtocolMock(protocolModel);

// The row to be set
object[] row1 = new object[] { "one.1", "two.1", "three.1", "four.1", "five.1" };
object[] row2 = new object[] { "one.2", "two.2", "three.2", "four.2", "five.2" };

// Make a call using the mock object, here in this example we are adding two rows, row1 and row2, to the table with ID 900
mock.Object.AddRow(900, row1);
mock.Object.AddRow(900, row2);

// Define the expected column values
string[] expectedColumn1 = { "one.1", "one.2" };
string[] expectedColumn2 = { "two.1", "two.2" };
string[] expectedColumn3 = { "three.1", "three.2" };
string[] expectedColumn4 = { "four.1", "four.2" };
string[] expectedColumn5 = { "five.1", "five.2" };

// Invoke the mock assert method, select the ID of the Table and the column to check, and then compare it with the expected column
mock.Assert().Table(900).Column(901).Should().Equal(expectedColumn1);
mock.Assert().Table(900).Column(901).Should().Equal(expectedColumn2);
mock.Assert().Table(900).Column(901).Should().Equal(expectedColumn3);
mock.Assert().Table(900).Column(901).Should().Equal(expectedColumn4);
mock.Assert().Table(900).Column(901).Should().Equal(expectedColumn5);
```

Thijs Vanovenacker [SLC] [DevOps Advocate] Posted new comment 13th June 2024
Thijs Vanovenacker [SLC] [DevOps Advocate] commented 13th June 2024

Hi, Any update on this? Where can community users find the NuGet? Thank you

You are viewing 1 out of 3 answers, click here to view all answers.
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas

Recent questions

Web Applications exception in Cube due to invalid certificate 0 Answers | 0 Votes
Redundancy Groups and Alarming – Duplicate Alarms 0 Answers | 0 Votes
Correlation Engine: “Test rule” doesn’t result in a hit, despite functional rule 1 Answer | 3 Votes

Question Tags

adl2099 (115) alarm (62) Alarm Console (82) alarms (100) alarm template (83) Automation (223) automation scipt (111) Automation script (167) backup (71) Cassandra (180) Connector (109) Correlation (69) Correlation rule (52) Cube (151) Dashboard (194) Dashboards (188) database (83) DataMiner Cube (57) DIS (81) DMS (71) DOM (140) driver (65) DVE (56) Elastic (83) Elasticsearch (115) elements (80) Failover (104) GQI (159) HTTP (76) IDP (74) LCA (152) low code app (166) low code apps (93) lowcodeapps (75) MySQL (53) protocol (203) QAction (83) security (88) SNMP (86) SRM (337) table (54) trending (87) upgrade (62) Visio (539) Visual Overview (345)
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin