Skip to content

Commit

Permalink
Migrate tests to Shouldly
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Jan 23, 2024
1 parent fca7d07 commit 9ae9847
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 291 deletions.
19 changes: 10 additions & 9 deletions src/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NUnit.Framework;
using Serilog;
using Serilog.Events;
using Shouldly;

namespace Destructurama.Attributed.Tests;

Expand Down Expand Up @@ -37,17 +38,17 @@ public void AttributesAreConsultedWhenDestructuring()
var sv = (StructureValue)evt.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsInstanceOf<ImmutableScalar>(props["ImmutableScalar"].LiteralValue());
Assert.AreEqual(new MutableScalar().ToString(), props["MutableScalar"].LiteralValue());
Assert.IsInstanceOf<StructureValue>(props["NotAScalar"]);
Assert.IsFalse(props.ContainsKey("Ignored"));
Assert.IsInstanceOf<NotAScalar>(props["ScalarAnyway"].LiteralValue());
Assert.IsInstanceOf<Struct1>(props["Struct1"].LiteralValue());
Assert.IsInstanceOf<Struct2>(props["Struct2"].LiteralValue());
props["ImmutableScalar"].LiteralValue().ShouldBeOfType<ImmutableScalar>();
props["MutableScalar"].LiteralValue().ShouldBe(new MutableScalar().ToString());
props["NotAScalar"].ShouldBeOfType<StructureValue>();
props.ContainsKey("Ignored").ShouldBeFalse();
props["ScalarAnyway"].LiteralValue().ShouldBeOfType<NotAScalar>();
props["Struct1"].LiteralValue().ShouldBeOfType<Struct1>();
props["Struct2"].LiteralValue().ShouldBeOfType<Struct2>();

var str = sv.ToString();
Assert.That(str.Contains("This is a username"));
Assert.False(str.Contains("This is a password"));
str.Contains("This is a username").ShouldBeTrue();
str.Contains("This is a password").ShouldBeFalse();
}

[LogAsScalar]
Expand Down
262 changes: 128 additions & 134 deletions src/Destructurama.Attributed.Tests/IgnoreNullPropertiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NUnit.Framework;
using Serilog;
using Serilog.Events;
using Shouldly;

namespace Destructurama.Attributed.Tests;

Expand Down Expand Up @@ -162,17 +163,17 @@ public void NotLoggedIfNull_Uninitialized()
var sv = (StructureValue)evt!.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(props.ContainsKey("Integer"));
Assert.IsTrue(props.ContainsKey("DateTime"));
Assert.IsTrue(props.ContainsKey("Struct"));
Assert.IsTrue(props.ContainsKey("StructPartiallyInitialized"));

Assert.IsFalse(props.ContainsKey("String"));
Assert.IsFalse(props.ContainsKey("NullableInteger"));
Assert.IsFalse(props.ContainsKey("IntegerAsObject"));
Assert.IsFalse(props.ContainsKey("Object"));
Assert.IsFalse(props.ContainsKey("NullableDateTime"));
Assert.IsFalse(props.ContainsKey("NullableStruct"));
props.ContainsKey("Integer").ShouldBeTrue();
props.ContainsKey("DateTime").ShouldBeTrue();
props.ContainsKey("Struct").ShouldBeTrue();
props.ContainsKey("StructPartiallyInitialized").ShouldBeTrue();

props.ContainsKey("String").ShouldBeFalse();
props.ContainsKey("NullableInteger").ShouldBeFalse();
props.ContainsKey("IntegerAsObject").ShouldBeFalse();
props.ContainsKey("Object").ShouldBeFalse();
props.ContainsKey("NullableDateTime").ShouldBeFalse();
props.ContainsKey("NullableStruct").ShouldBeFalse();
}

[Test]
Expand Down Expand Up @@ -223,54 +224,52 @@ public void NotLoggedIfNull_Initialized()
var sv = (StructureValue)evt!.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(props.ContainsKey("String"));
Assert.IsTrue(props.ContainsKey("Integer"));
Assert.IsTrue(props.ContainsKey("NullableInteger"));
Assert.IsTrue(props.ContainsKey("Object"));
Assert.IsTrue(props.ContainsKey("IntegerAsObject"));
Assert.IsTrue(props.ContainsKey("DateTime"));
Assert.IsTrue(props.ContainsKey("NullableDateTime"));
Assert.IsTrue(props.ContainsKey("Struct"));
Assert.IsTrue(props.ContainsKey("NullableStruct"));
Assert.IsTrue(props.ContainsKey("StructPartiallyInitialized"));

Assert.AreEqual("Foo", props["String"].LiteralValue());
Assert.AreEqual(10, props["Integer"].LiteralValue());
Assert.AreEqual(5, props["NullableInteger"].LiteralValue());
Assert.AreEqual("Bar", props["Object"].LiteralValue());
Assert.AreEqual(0, props["IntegerAsObject"].LiteralValue());
Assert.AreEqual(dateTime, props["DateTime"].LiteralValue());
Assert.AreEqual(dateTime, props["NullableDateTime"].LiteralValue());
Assert.IsInstanceOf<StructureValue>(props["Struct"]);
Assert.IsInstanceOf<StructureValue>(props["NullableStruct"]);
Assert.IsInstanceOf<StructureValue>(props["StructPartiallyInitialized"]);

var structProps = ((StructureValue)props["Struct"]).Properties
.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(structProps.ContainsKey("Integer"));
Assert.IsTrue(structProps.ContainsKey("NullableInteger"));
Assert.IsTrue(structProps.ContainsKey("DateTime"));
Assert.IsTrue(structProps.ContainsKey("NullableDateTime"));
Assert.IsTrue(structProps.ContainsKey("Object"));
Assert.AreEqual(20, structProps["Integer"].LiteralValue());
Assert.AreEqual(15, structProps["NullableInteger"].LiteralValue());
Assert.AreEqual(dateTime, structProps["DateTime"].LiteralValue());
Assert.AreEqual(dateTime, structProps["NullableDateTime"].LiteralValue());
Assert.AreEqual("Bar", structProps["Object"].LiteralValue());

var partiallyItitializedProps = ((StructureValue)props["StructPartiallyInitialized"]).Properties
.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(partiallyItitializedProps.ContainsKey("Integer"));
Assert.IsTrue(partiallyItitializedProps.ContainsKey("NullableInteger"));
Assert.IsTrue(partiallyItitializedProps.ContainsKey("DateTime"));
Assert.IsTrue(partiallyItitializedProps.ContainsKey("NullableDateTime"));
Assert.IsFalse(partiallyItitializedProps.ContainsKey("Object"));
Assert.AreEqual(20, partiallyItitializedProps["Integer"].LiteralValue());
Assert.AreEqual(15, partiallyItitializedProps["NullableInteger"].LiteralValue());
Assert.AreEqual(dateTime, partiallyItitializedProps["DateTime"].LiteralValue());
Assert.AreEqual(dateTime, partiallyItitializedProps["NullableDateTime"].LiteralValue());
props.ContainsKey("String").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("Integer").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("NullableInteger").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("Object").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("IntegerAsObject").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("DateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("NullableDateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("Struct").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("NullableStruct").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("StructPartiallyInitialized").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
Inefficient use of 'ContainsKey' and
indexer
.

props["String"].LiteralValue().ShouldBe("Foo");
props["Integer"].LiteralValue().ShouldBe(10);
props["NullableInteger"].LiteralValue().ShouldBe(5);
props["Object"].LiteralValue().ShouldBe("Bar");
props["IntegerAsObject"].LiteralValue().ShouldBe(0);
props["DateTime"].LiteralValue().ShouldBe(dateTime);
props["NullableDateTime"].LiteralValue().ShouldBe(dateTime);
props["Struct"].ShouldBeOfType<StructureValue>();
props["NullableStruct"].ShouldBeOfType<StructureValue>();
props["StructPartiallyInitialized"].ShouldBeOfType<StructureValue>();

var structProps = ((StructureValue)props["Struct"]).Properties.ToDictionary(p => p.Name, p => p.Value);

structProps.ContainsKey("Integer").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("NullableInteger").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("DateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("NullableDateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("Object").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps["Integer"].LiteralValue().ShouldBe(20);
structProps["NullableInteger"].LiteralValue().ShouldBe(15);
structProps["DateTime"].LiteralValue().ShouldBe(dateTime);
structProps["NullableDateTime"].LiteralValue().ShouldBe(dateTime);
structProps["Object"].LiteralValue().ShouldBe("Bar");

var partiallyItitializedProps = ((StructureValue)props["StructPartiallyInitialized"]).Properties.ToDictionary(p => p.Name, p => p.Value);

partiallyItitializedProps.ContainsKey("Integer").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("NullableInteger").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("DateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("NullableDateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("Object").ShouldBeFalse();
partiallyItitializedProps["Integer"].LiteralValue().ShouldBe(20);
partiallyItitializedProps["NullableInteger"].LiteralValue().ShouldBe(15);
partiallyItitializedProps["DateTime"].LiteralValue().ShouldBe(dateTime);
partiallyItitializedProps["NullableDateTime"].LiteralValue().ShouldBe(dateTime);
}

[Test]
Expand All @@ -290,8 +289,8 @@ public void WithMask_NotLoggedIfNull_Uninitialized()
var sv = (StructureValue)evt!.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsFalse(props.ContainsKey("String"));
Assert.IsFalse(props.ContainsKey("Object"));
props.ContainsKey("String").ShouldBeFalse();
props.ContainsKey("Object").ShouldBeFalse();
}

[Test]
Expand All @@ -316,11 +315,11 @@ public void WithMask_NotLoggedIfNull_Initialized()
var sv = (StructureValue)evt!.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(props.ContainsKey("String"));
Assert.IsTrue(props.ContainsKey("Object"));
props.ContainsKey("String").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("Object").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.

Assert.AreEqual("Foo***", props["String"].LiteralValue());
Assert.AreEqual("Bar***", props["Object"].LiteralValue());
props["String"].LiteralValue().ShouldBe("Foo***");
props["Object"].LiteralValue().ShouldBe("Bar***");
}

[Test]
Expand All @@ -345,7 +344,7 @@ public void EnumerableIgnored()
log.Information("Here is {@Customized}", customized);

var sv = evt!.Properties["Customized"];
Assert.IsInstanceOf<SequenceValue>(sv);
sv.ShouldBeOfType<SequenceValue>();
}

[Test]
Expand Down Expand Up @@ -373,15 +372,14 @@ public void EnumerableDestructedAsStruct()
var sv = (StructureValue)evt!.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(props.ContainsKey("Integer"));
Assert.IsFalse(props.ContainsKey("NullableInteger"));
Assert.IsTrue(props.ContainsKey("Dependency"));
props.ContainsKey("Integer").ShouldBeTrue();
props.ContainsKey("NullableInteger").ShouldBeFalse();
props.ContainsKey("Dependency").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.

var dependencyProps = ((StructureValue)props["Dependency"]).Properties
.ToDictionary(p => p.Name, p => p.Value);
var dependencyProps = ((StructureValue)props["Dependency"]).Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(dependencyProps.ContainsKey("Integer"));
Assert.IsFalse(dependencyProps.ContainsKey("NullableInteger"));
dependencyProps.ContainsKey("Integer").ShouldBeTrue();
dependencyProps.ContainsKey("NullableInteger").ShouldBeFalse();
}

[Test]
Expand All @@ -401,17 +399,17 @@ public void NotLoggedIfNullAttribute_Uninitialized()
var sv = (StructureValue)evt!.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(props.ContainsKey("Integer"));
Assert.IsTrue(props.ContainsKey("DateTime"));
Assert.IsTrue(props.ContainsKey("Struct"));
Assert.IsTrue(props.ContainsKey("StructPartiallyInitialized"));

Assert.IsFalse(props.ContainsKey("String"));
Assert.IsFalse(props.ContainsKey("NullableInteger"));
Assert.IsFalse(props.ContainsKey("IntegerAsObject"));
Assert.IsFalse(props.ContainsKey("Object"));
Assert.IsFalse(props.ContainsKey("NullableDateTime"));
Assert.IsFalse(props.ContainsKey("NullableStruct"));
props.ContainsKey("Integer").ShouldBeTrue();
props.ContainsKey("DateTime").ShouldBeTrue();
props.ContainsKey("Struct").ShouldBeTrue();
props.ContainsKey("StructPartiallyInitialized").ShouldBeTrue();

props.ContainsKey("String").ShouldBeFalse();
props.ContainsKey("NullableInteger").ShouldBeFalse();
props.ContainsKey("IntegerAsObject").ShouldBeFalse();
props.ContainsKey("Object").ShouldBeFalse();
props.ContainsKey("NullableDateTime").ShouldBeFalse();
props.ContainsKey("NullableStruct").ShouldBeFalse();
}

[Test]
Expand Down Expand Up @@ -462,57 +460,53 @@ public void NotLoggedIfNullAttribute_Initialized()
var sv = (StructureValue)evt!.Properties["Customized"];
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(props.ContainsKey("String"));
Assert.IsTrue(props.ContainsKey("Integer"));
Assert.IsTrue(props.ContainsKey("NullableInteger"));
Assert.IsTrue(props.ContainsKey("Object"));
Assert.IsTrue(props.ContainsKey("IntegerAsObject"));
Assert.IsTrue(props.ContainsKey("DateTime"));
Assert.IsTrue(props.ContainsKey("NullableDateTime"));
Assert.IsTrue(props.ContainsKey("Struct"));
Assert.IsTrue(props.ContainsKey("NullableStruct"));
Assert.IsTrue(props.ContainsKey("StructPartiallyInitialized"));

Assert.AreEqual("Foo", props["String"].LiteralValue());
Assert.AreEqual(10, props["Integer"].LiteralValue());
Assert.AreEqual(5, props["NullableInteger"].LiteralValue());
Assert.AreEqual("Bar", props["Object"].LiteralValue());
Assert.AreEqual(0, props["IntegerAsObject"].LiteralValue());
Assert.AreEqual(dateTime, props["DateTime"].LiteralValue());
Assert.AreEqual(dateTime, props["NullableDateTime"].LiteralValue());
Assert.IsInstanceOf<StructureValue>(props["Struct"]);
Assert.IsInstanceOf<StructureValue>(props["NullableStruct"]);
Assert.IsInstanceOf<StructureValue>(props["StructPartiallyInitialized"]);

var structProps = ((StructureValue)props["Struct"]).Properties
.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(structProps.ContainsKey("Integer"));
Assert.IsTrue(structProps.ContainsKey("NullableInteger"));
Assert.IsTrue(structProps.ContainsKey("DateTime"));
Assert.IsTrue(structProps.ContainsKey("NullableDateTime"));
Assert.IsTrue(structProps.ContainsKey("Object"));
Assert.AreEqual(20, structProps["Integer"].LiteralValue());
Assert.AreEqual(15, structProps["NullableInteger"].LiteralValue());
Assert.AreEqual(dateTime, structProps["DateTime"].LiteralValue());
Assert.AreEqual(dateTime, structProps["NullableDateTime"].LiteralValue());
Assert.AreEqual("Bar", structProps["Object"].LiteralValue());

var partiallyItitializedProps = ((StructureValue)props["StructPartiallyInitialized"]).Properties
.ToDictionary(p => p.Name, p => p.Value);

Assert.IsTrue(partiallyItitializedProps.ContainsKey("Integer"));
Assert.IsTrue(partiallyItitializedProps.ContainsKey("NullableInteger"));
Assert.IsTrue(partiallyItitializedProps.ContainsKey("DateTime"));
Assert.IsTrue(partiallyItitializedProps.ContainsKey("NullableDateTime"));
Assert.IsTrue(partiallyItitializedProps.ContainsKey("Object"));
Assert.AreEqual(20, partiallyItitializedProps["Integer"].LiteralValue());
Assert.AreEqual(15, partiallyItitializedProps["NullableInteger"].LiteralValue());
Assert.AreEqual(dateTime, partiallyItitializedProps["DateTime"].LiteralValue());
Assert.AreEqual(dateTime, partiallyItitializedProps["NullableDateTime"].LiteralValue());

props.ContainsKey("String").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("Integer").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("NullableInteger").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("Object").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("IntegerAsObject").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("DateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("NullableDateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("Struct").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("NullableStruct").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
props.ContainsKey("StructPartiallyInitialized").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
Inefficient use of 'ContainsKey' and
indexer
.

props["String"].LiteralValue().ShouldBe("Foo");
props["Integer"].LiteralValue().ShouldBe(10);
props["NullableInteger"].LiteralValue().ShouldBe(5);
props["Object"].LiteralValue().ShouldBe("Bar");
props["IntegerAsObject"].LiteralValue().ShouldBe(0);
props["DateTime"].LiteralValue().ShouldBe(dateTime);
props["NullableDateTime"].LiteralValue().ShouldBe(dateTime);
props["Struct"].ShouldBeOfType<StructureValue>();
props["NullableStruct"].ShouldBeOfType<StructureValue>();
props["StructPartiallyInitialized"].ShouldBeOfType<StructureValue>();

var structProps = ((StructureValue)props["Struct"]).Properties.ToDictionary(p => p.Name, p => p.Value);

structProps.ContainsKey("Integer").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("NullableInteger").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("DateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("NullableDateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps.ContainsKey("Object").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
structProps["Integer"].LiteralValue().ShouldBe(20);
structProps["NullableInteger"].LiteralValue().ShouldBe(15);
structProps["DateTime"].LiteralValue().ShouldBe(dateTime);
structProps["NullableDateTime"].LiteralValue().ShouldBe(dateTime);
structProps["Object"].LiteralValue().ShouldBe("Bar");

var partiallyItitializedProps = ((StructureValue)props["StructPartiallyInitialized"]).Properties.ToDictionary(p => p.Name, p => p.Value);

partiallyItitializedProps.ContainsKey("Integer").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("NullableInteger").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("DateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("NullableDateTime").ShouldBeTrue();

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.
partiallyItitializedProps.ContainsKey("Object").ShouldBeTrue();
partiallyItitializedProps["Integer"].LiteralValue().ShouldBe(20);
partiallyItitializedProps["NullableInteger"].LiteralValue().ShouldBe(15);
partiallyItitializedProps["DateTime"].LiteralValue().ShouldBe(dateTime);
partiallyItitializedProps["NullableDateTime"].LiteralValue().ShouldBe(dateTime);
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
using NUnit.Framework;
using Serilog;
using Serilog.Events;
using Shouldly;

namespace Destructurama.Attributed.Tests;

[TestFixture]
public class LogWithNameAttributedTests
{

[Test]
public void AttributesAreConsultedWhenDestructuring()
{
Expand All @@ -30,7 +30,7 @@ public void AttributesAreConsultedWhenDestructuring()
var props = sv.Properties.ToDictionary(p => p.Name, p => p.Value);

var literalValue = props["FullName"].LiteralValue();
Assert.AreEqual("John Doe", literalValue);
literalValue.ShouldBe("John Doe");
}

#region LogWithName
Expand Down
Loading

0 comments on commit 9ae9847

Please sign in to comment.