Skip to content

Added deserialization unit tests to CodeDomComponentSerializationService - #14900

Open
Rabina4363sf wants to merge 2 commits into
dotnet:mainfrom
Rabina4363sf:Fix_Issue_10135
Open

Added deserialization unit tests to CodeDomComponentSerializationService#14900
Rabina4363sf wants to merge 2 commits into
dotnet:mainfrom
Rabina4363sf:Fix_Issue_10135

Conversation

@Rabina4363sf

@Rabina4363sf Rabina4363sf commented Aug 18, 2026

Copy link
Copy Markdown

Fixes #10135

Proposed changes

  • Added 20 comprehensive unit tests for CodeDomComponentSerializationService.Deserialize() method
  • Tests cover null store and container parameter validation
  • Tests verify single and multiple object deserialization scenarios
  • Tests ensure round-trip serialization/deserialization preserves object state
  • Tests validate empty store handling
  • Tests cover DeserializeTo() method with various flag combinations (validateRecycledTypes, applyDefaults)
  • Tests include integration with IServiceProvider and IContainer
  • Tests verify proper exception handling for invalid operations

Customer Impact

  • Improves test coverage for component serialization service
  • Ensures deserialization APIs work reliably across different scenarios
  • Validates serialization/deserialization round-trip fidelity

Regression?

  • No

Risk

  • Low (tests only, no product code changes)

Test methodology

  • Unit tests using xUnit framework
  • Mock objects created with Moq for isolated testing
  • Validation of exception types and messages
  • Property assertion checks for deserialized objects
  • Control round-trip testing to verify state preservation
  • Empty and edge-case scenarios covered

Accessibility testing

NA

Test environment(s)

  • Visual Studio (Test Explorer)
  • Windows
  • .NET 11
Microsoft Reviewers: Open in CodeFlow

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds unit tests for CodeDomComponentSerializationService deserialization APIs.

Changes:

  • Covers validation, empty stores, and object round trips.
  • Exercises container, service-provider, and DeserializeTo scenarios.
  • Adds control property fidelity checks.
File summaries
File Description
CodeDomComponentSerializationServiceTests.cs Adds deserialization-focused unit tests.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 6
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


ICollection deserializedCollection = service.Deserialize(store, container);
Assert.NotEmpty(deserializedCollection);
DataClass deserializedObject = Assert.IsType<DataClass>(Assert.Single(deserializedCollection.Cast<object>()));
ICollection deserializedCollection = service.Deserialize(store, container);
Assert.Equal(2, deserializedCollection.Count);

DataClass[] deserializedObjects = deserializedCollection.Cast<DataClass>().ToArray();
Comment on lines +2047 to +2055
// Store the original values
int originalIntValue = targetObject.IntValue;
string originalStringValue = targetObject.StringValue;

// Deserialize to the existing object
service.DeserializeTo(store, targetContainer, false, false);

// The targetObject should have received the state from the serialized object
// Note: This depends on the internal implementation of DeserializeTo
Comment on lines +2105 to +2106
// Should apply default values when applyDefaults is true
service.DeserializeTo(store, container, validateRecycledTypes: false, applyDefaults: true);
Comment on lines +2130 to +2131
// Should not apply default values when applyDefaults is false
service.DeserializeTo(store, container, validateRecycledTypes: false, applyDefaults: false);
Comment on lines +2215 to +2216
// First serialize the object completely
service.Serialize(store, originalObject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add deserialization unit tests to CodeDomComponentSerializationService

3 participants