-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(unit-tests): increase code coverage #252
Conversation
This commit adds: - Improvements to existing unit test code - Improvements to existing unit test naming - Unit tests for `EFCacheKeyPrefixProvider` class - Unit tests for `EFCacheKeyProvider` class - Unit tests for `EFCacheKey` class - Unit tests for `EFCacheServiceCheck` class - Unit tests for `EFDataReaderLoader` class - Unit tests for `EFDebugLogger` class - Unit tests for `EFServiceCollectionExtensions` class - Unit tests for `LockProvider` class - Unit tests for `StringExtensions` class - Unit tests for `TableEntityInfo` class - Unit tests for `XxHash64Unsafe` class
{ | ||
// Arrange | ||
var dbReaderMock = new Mock<DbDataReader>(); | ||
var schemaTable = new DataTable(); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
// Arrange | ||
var dbReaderMock = new Mock<DbDataReader>(); | ||
|
||
dbReaderMock.Setup(r => r.GetSchemaTable()).Returns((DataTable?)null); |
Check warning
Code scanning / CodeQL
Useless upcast Warning
null
DataTable
dbReaderMock.Setup(r => r.FieldCount).Returns(1); | ||
dbReaderMock.Setup(r => r.GetValue(0)).Returns("value"); | ||
dbReaderMock.Setup(r => r.Read()).Returns(true); | ||
dbReaderMock.Setup(r => r.GetStream(0)).Returns(new MemoryStream(expected)); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
x.EventId == CacheableLogEventId.CachingSystemStarted | ||
&& x.Message == "TestMessage" | ||
&& x.CommandText == "TestCommand" | ||
&& x.ServiceProvider == _serviceProviderMock.Object)), |
Check warning
Code scanning / CodeQL
Reference equality test on System.Object Warning
this
// Assert | ||
_cacheInvalidationEventMock.Verify(e => e.Invoke(It.Is<EFCacheInvalidationInfo>( | ||
x => | ||
x.CacheDependencies == cacheDependencies |
Check warning
Code scanning / CodeQL
Reference equality test on System.Object Warning
this
_cacheInvalidationEventMock.Verify(e => e.Invoke(It.Is<EFCacheInvalidationInfo>( | ||
x => | ||
x.CacheDependencies == cacheDependencies | ||
&& x.ClearAllCachedEntries == true |
Check notice
Code scanning / CodeQL
Unnecessarily complex Boolean expression Note
x => | ||
x.CacheDependencies == cacheDependencies | ||
&& x.ClearAllCachedEntries == true | ||
&& x.ServiceProvider == _serviceProviderMock.Object)), |
Check warning
Code scanning / CodeQL
Reference equality test on System.Object Warning
this
@@ -8,10 +8,10 @@ | |||
public void IsNull_ShouldReturnTrue_WhenValueIsNull() | |||
{ | |||
// Arrange && Act | |||
var result = ((object)null).IsNull(); | |||
var actual = ((object)null).IsNull(); |
Check warning
Code scanning / CodeQL
Useless upcast Warning
null
Object
var hashProvider = new XxHash64Unsafe(); | ||
|
||
// Act && Assert | ||
Assert.Throws<ArgumentNullException>(() => hashProvider.ComputeHash(((string)null)!)); |
Check warning
Code scanning / CodeQL
Useless upcast Warning
null
String
var hashProvider = new XxHash64Unsafe(); | ||
|
||
// Act && Assert | ||
Assert.Throws<ArgumentNullException>(() => hashProvider.ComputeHash(((byte[])null)!)); |
Check warning
Code scanning / CodeQL
Useless upcast Warning
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
EFCacheKeyPrefixProvider
classEFCacheKeyProvider
classEFCacheKey
classEFCacheServiceCheck
classEFDataReaderLoader
classEFDebugLogger
classEFServiceCollectionExtensions
classLockProvider
classStringExtensions
classTableEntityInfo
classXxHash64Unsafe
classWhat is the new behavior?
EFCacheKeyPrefixProvider
class is covered by100%
EFCacheKeyProvider
class is covered by96%
EFCacheKey
class is covered by100%
EFCacheServiceCheck
class is covered by97%
EFDataReaderLoader
class is covered by93%
EFDebugLogger
class is covered by100%
EFServiceCollectionExtensions
class is covered by100%
LockProvider
class is covered by100%
StringExtensions
class is covered by100%
TableEntityInfo
class is covered by100%
XxHash64Unsafe
class is covered by100%
Overall code coverage increased from
35%
to53%
:Does this PR introduce a breaking change?
Other information
This work improves the overall quality of the project.
Best Regards,
Dmitrii Kiselev