Skip to content

Find a better way of accessing the PropertyDictionary #156

@colinangusmackay

Description

@colinangusmackay

The PropertyDictionary is a bit cumbersome. Want a way to access it more easily.

  • Get the value easily
  • Detect when keys exist or don't easily.
  • Indexer access covers most scenarios, but may throw exceptions if it doesn't exist (maybe this is an acceptable way to fail the test)

Idea 1

public void ExampleOfUsage()
{
   var log = TestCaptureLogger.GetLogs().First();
   log.HasProperty("SomeProperty").ShouldBeTrue();
   log["SomeProperty"].ShouldBe("SomeValue");
}

Idea 2

public void ExampleOfUsage()
{
   var log = TestCaptureLogger.GetLogs().First();
   LogProperty<string> prop = log["SomeProperty"]; // Always returns something
   prop.Exists.ShouldBeTrue();
   prop.IsOfType<string>().ShouldBeTrue();
   prop.Value.ShouldBe("SomeValue");
   prop.ShouldBe("SomeValue"); // Implicit cast to T
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions