FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ImageHash/tests/ImageHash.Test/ImageHashExtensionsTest.cs at develop · coenm/ImageHash · GitHub
coenm
/
ImageHash
Public
Notifications
You must be signed in to change notification settings
Fork
27
Star
241
Code
Issues
5
Pull requests
10
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ImageHash
/
tests
/
ImageHash.Test
/
ImageHashExtensionsTest.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (51 loc) · 1.9 KB
Breadcrumbs
ImageHash
/
tests
/
ImageHash.Test
/
ImageHashExtensionsTest.cs
Copy path
File metadata and controls
59 lines (51 loc) · 1.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
namespace
CoenM
.
ImageHash
.
Test
{
using
System
;
using
System
.
Diagnostics
.
CodeAnalysis
;
using
System
.
IO
;
using
System
.
Threading
.
Tasks
;
using
CoenM
.
ImageHash
.
Test
.
Data
;
using
EasyTestFileXunit
;
using
FakeItEasy
;
using
FluentAssertions
;
using
SixLabors
.
ImageSharp
;
using
SixLabors
.
ImageSharp
.
PixelFormats
;
using
Xunit
;
using
Sut
=
CoenM
.
ImageHash
.
ImageHashExtensions
;
[
SuppressMessage
(
"ReSharper"
,
"InvokeAsExtensionMethod"
,
Justification
=
"Testing static extension method class"
)
]
[
UsesEasyTestFile
]
public
class
ImageHashExtensionsTest
{
private
readonly
IImageHash
_hashAlgorithm
;
public
ImageHashExtensionsTest
(
)
{
_hashAlgorithm
=
A
.
Fake
<
IImageHash
>
(
)
;
}
[
Fact
]
public
async
Task
HashStreamShouldReadStreamAsImageAndPassDataToHashAlgorithmTest
(
)
{
// arrange
A
.
CallTo
(
(
)
=>
_hashAlgorithm
.
Hash
(
A
<
Image
<
Rgba32
>
>
.
_
)
)
.
Returns
(
0UL
)
;
using
Stream
stream
=
await
TestData
.
AlysonHannigan200x200_0
.
AsStream
(
)
;
// act
var
result
=
Sut
.
Hash
(
_hashAlgorithm
,
stream
)
;
// assert
A
.
CallTo
(
(
)
=>
_hashAlgorithm
.
Hash
(
A
<
Image
<
Rgba32
>
>
.
_
)
)
.
MustHaveHappenedOnceExactly
(
)
;
result
.
Should
(
)
.
Be
(
0UL
)
;
}
[
Theory
]
[
InlineData
(
true
,
false
)
]
[
InlineData
(
false
,
true
)
]
[
InlineData
(
true
,
true
)
]
public
void
NullArgumentShouldThrowArgumentNullExceptionTest
(
bool
hashImplIsNull
,
bool
streamIsNull
)
{
// arrange
IImageHash
imageHashImplementation
=
hashImplIsNull
?
null
:
A
.
Dummy
<
IImageHash
>
(
)
;
Stream
stream
=
streamIsNull
?
null
:
new
MemoryStream
(
)
;
// act
Action
act
=
(
)
=>
Sut
.
Hash
(
imageHashImplementation
!
,
stream
!
)
;
// assert
act
.
Should
(
)
.
Throw
<
ArgumentNullException
>
(
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL