Skip to content

Commit

Permalink
Add a test that uses the ViewHierarchy.Windows property
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Feb 27, 2023
1 parent a8886e2 commit ab8da5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/Sentry.Tests/ViewHierarchyNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Sentry.Tests;

public class ViewHierarchyNodeTests
{
private class TestViewHierarchyNode : ViewHierarchyNode
internal class TestViewHierarchyNode : ViewHierarchyNode
{
public TestViewHierarchyNode(string type) : base(type) { }
public bool WriteAdditionalPropertiesGotCalled { get; private set; }
Expand Down
26 changes: 26 additions & 0 deletions test/Sentry.Tests/ViewHierarchyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,30 @@ public void WriteTo_ContainsRenderingSystemAndWindows()
"\"windows\":[]" +
"}");
}

[Fact]
public void WriteTo_ContainsRenderingSystemAndOneWindow()
{
// Arrange
using var stream = new MemoryStream();
using var writer = new Utf8JsonWriter(stream);
var sut = new ViewHierarchy("Test_Rendering_System");
sut.Windows.Add(new ViewHierarchyNodeTests.TestViewHierarchyNode("Test_Node"));

// Act
sut.WriteTo(writer, null);

writer.Flush();
stream.Seek(0, SeekOrigin.Begin);

// Assert
var serializedViewHierarchy = new StreamReader(stream, Encoding.ASCII).ReadToEnd();
serializedViewHierarchy.Should().Be(
"{" +
"\"rendering_system\":\"Test_Rendering_System\"," +
"\"windows\":[" +
"{\"type\":\"Test_Node\",\"children\":[]}" +
"]" +
"}");
}
}

0 comments on commit ab8da5c

Please sign in to comment.