Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
A
Anvoker.Maps
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
An Ionescu
Anvoker.Maps
Commits
a5fad1ad
Commit
a5fad1ad
authored
Nov 20, 2018
by
An Ionescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding MultiMap unit tests.
parent
56e12778
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
279 additions
and
0 deletions
+279
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap.meta
Assets/Editor/Anvoker.Collections/Maps/MultiMap.meta
+8
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/Constructors.cs
.../Editor/Anvoker.Collections/Maps/MultiMap/Constructors.cs
+66
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/Constructors.cs.meta
...or/Anvoker.Collections/Maps/MultiMap/Constructors.cs.meta
+11
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/FixtureSource_IntDecimal.cs
...ker.Collections/Maps/MultiMap/FixtureSource_IntDecimal.cs
+65
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/FixtureSource_IntDecimal.cs.meta
...ollections/Maps/MultiMap/FixtureSource_IntDecimal.cs.meta
+11
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary.cs
...or/Anvoker.Collections/Maps/MultiMap/NestedIDictionary.cs
+48
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary.cs.meta
...voker.Collections/Maps/MultiMap/NestedIDictionary.cs.meta
+11
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary_IntDecimal.cs
...Collections/Maps/MultiMap/NestedIDictionary_IntDecimal.cs
+48
-0
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary_IntDecimal.cs.meta
...ctions/Maps/MultiMap/NestedIDictionary_IntDecimal.cs.meta
+11
-0
No files found.
Assets/Editor/Anvoker.Collections/Maps/MultiMap.meta
0 → 100644
View file @
a5fad1ad
fileFormatVersion: 2
guid: ee2345ce74b53b94a9dc75c94e4da301
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/Editor/Anvoker.Collections/Maps/MultiMap/Constructors.cs
0 → 100644
View file @
a5fad1ad
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
NUnit.Framework
;
namespace
Anvoker.Collections.Maps.Tests.MultiMap
{
/// <summary>
/// Unit tests for <see cref="MultiMap{TKey, TVal}"/>'s constructors.
/// </summary>
[
TestFixture
]
public
class
Constructors
{
/// <summary>
/// Checks that the parameterless constructor leaves the new MultiMap
/// in the expected state.
/// </summary>
[
Test
]
public
void
ParameterlessConstructor
()
{
var
multiMap
=
new
MultiMap
<
string
,
int
>();
Assert
.
AreEqual
(
0
,
multiMap
.
Count
);
Assert
.
AreEqual
(
0
,
multiMap
.
Keys
.
Count
);
Assert
.
AreEqual
(
0
,
multiMap
.
Values
.
Count
);
Assert
.
AreEqual
(
EqualityComparer
<
string
>.
Default
,
multiMap
.
ComparerKey
);
Assert
.
AreEqual
(
EqualityComparer
<
int
>.
Default
,
multiMap
.
ComparerValue
);
}
/// <summary>
/// Checks that the constructor with the capacity parameter leaves
/// the new MultiMap in the expected state.
/// </summary>
[
Test
]
public
void
CapacityConstructor
()
{
var
multiMap
=
new
MultiMap
<
string
,
int
>(
10
);
Assert
.
AreEqual
(
0
,
multiMap
.
Count
);
Assert
.
AreEqual
(
0
,
multiMap
.
Keys
.
Count
);
Assert
.
AreEqual
(
0
,
multiMap
.
Values
.
Count
);
Assert
.
AreEqual
(
EqualityComparer
<
string
>.
Default
,
multiMap
.
ComparerKey
);
Assert
.
AreEqual
(
EqualityComparer
<
int
>.
Default
,
multiMap
.
ComparerValue
);
}
/// <summary>
/// Checks that the constructor with the comparer parameters leaves
/// the new MultiMap in the expected state.
/// </summary>
[
Test
]
public
void
ComparerConstructor
()
{
var
comparerKey
=
StringComparer
.
OrdinalIgnoreCase
;
var
comparerValue
=
StringComparer
.
InvariantCulture
;
var
multiMap
=
new
MultiMap
<
string
,
string
>(
comparerKey
,
comparerValue
);
Assert
.
AreEqual
(
0
,
multiMap
.
Count
);
Assert
.
AreEqual
(
comparerKey
,
multiMap
.
ComparerKey
);
Assert
.
AreEqual
(
comparerValue
,
multiMap
.
ComparerValue
);
Assert
.
AreEqual
(
0
,
multiMap
.
Keys
.
Count
);
Assert
.
AreEqual
(
0
,
multiMap
.
Values
.
Count
);
}
}
}
Assets/Editor/Anvoker.Collections/Maps/MultiMap/Constructors.cs.meta
0 → 100644
View file @
a5fad1ad
fileFormatVersion: 2
guid: 20c0e5437dc90824bb08e7913fb78467
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Editor/Anvoker.Collections/Maps/MultiMap/FixtureSource_IntDecimal.cs
0 → 100644
View file @
a5fad1ad
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
NUnit.Framework
;
namespace
Anvoker.Collections.Maps.Tests.MultiMap
{
/// <summary>
/// Provides test data for <see cref="NestedIDictionary_IntDecimal"/>.
/// </summary>
internal
static
class
FixtureSource_IntDecimal
{
private
static
readonly
int
[]
intKeys
=
new
int
[]
{
25
,
37
,
99
,
20
,
-
5
};
private
static
readonly
int
[]
intKeysExcluded
=
new
int
[]
{
24
,
2
,
-
8
};
private
static
readonly
decimal
[][]
decimalValues
=
new
decimal
[][]
{
new
decimal
[]
{
0.1
m
},
new
decimal
[]
{
5.25
m
,
0.0
m
},
new
decimal
[]
{
5.25
m
,
0.0
m
,
2.0
m
,
5.0
m
},
new
decimal
[]
{
1.75
m
},
new
decimal
[]
{
3.75
m
},
};
/// <summary>
/// Provides the arguments for a test fixture that is decorated with
/// <see cref="TestCaseSourceAttribute"/> and has a constructor with
/// matching parameter types.
/// </summary>
/// <returns>An array of objects where each object is a collection
/// that contains all of the necessary parameters to run a constructor
/// of matching type.</returns>
public
static
object
[]
FixtureArgs
()
=>
new
object
[]
{
ConstructIntDecimalCase
()
};
private
static
object
[]
ConstructIntDecimalCase
()
{
var
multiMap
=
new
MultiMap
<
int
,
decimal
>()
{
{
intKeys
[
0
],
decimalValues
[
0
]
},
{
intKeys
[
1
],
decimalValues
[
1
]
},
{
intKeys
[
2
],
decimalValues
[
2
]
},
{
intKeys
[
3
],
decimalValues
[
3
]
},
{
intKeys
[
4
],
decimalValues
[
4
]
}
};
return
new
object
[]
{
multiMap
,
intKeys
,
(
ICollection
<
decimal
>[])
decimalValues
,
intKeysExcluded
};
}
}
}
\ No newline at end of file
Assets/Editor/Anvoker.Collections/Maps/MultiMap/FixtureSource_IntDecimal.cs.meta
0 → 100644
View file @
a5fad1ad
fileFormatVersion: 2
guid: b1ce25a70ec7d754dbf876e89bc0145b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary.cs
0 → 100644
View file @
a5fad1ad
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
NUnit.Framework
;
namespace
Anvoker.Collections.Maps.Tests.MultiMap.IDictionary
{
/// <summary>
/// Does nothing but specify some of the types for
/// <see cref="NestedIDictionaryBase{TKey, TVal, TIDict, TValCol}"/>,
/// leaving only the key and value types as generic.
/// </summary>
/// <typeparam name="TKey">Type of the keys in the
/// <see cref="MultiMap{TKey, TVal}"/>.</typeparam>
/// <typeparam name="TVal">Type of the values in the
/// <see cref="MultiMap{TKey, TVal}"/>.</typeparam>
public
class
NestedIDictionary
<
TKey
,
TVal
>
:
NestedIDictionaryBase
<
TKey
,
TVal
,
MultiMap
<
TKey
,
TVal
>,
ICollection
<
TVal
>>
{
/// <summary>
/// Initializes a new instance of the
/// <see cref="NestedIDictionary{TKey, TVal}"/> class with and the
/// specified keys and values.
/// </summary>
/// <param name="multiMap">An instance of
/// <see cref="MultiMap{TKey, TVal}"/> already initialized with the
/// specified keys and values.</param>
/// <param name="initialKeys">An enumeration of keys also found in the
/// specified <paramref name="multiMap"/>.
/// <para>Used to verify tests.</para></param>
/// <param name="initialValueCollections">An enumeration of collections
/// of values also found in <paramref name="multiMap"/>.
/// <para>Used to verify tests.</para></param>
/// <param name="excludedKeys">An enumeration of value of the same type
/// as the keys in <paramref name="multiMap"/>, none of which are
/// contained in <paramref name="multiMap"/>.
/// <para>Used to test for false positives.</para></param>
public
NestedIDictionary
(
MultiMap
<
TKey
,
TVal
>
multiMap
,
TKey
[]
initialKeys
,
ICollection
<
TVal
>[]
initialValueCollections
,
TKey
[]
excludedKeys
)
:
base
(
multiMap
,
initialKeys
,
initialValueCollections
,
excludedKeys
)
{
}
}
}
\ No newline at end of file
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary.cs.meta
0 → 100644
View file @
a5fad1ad
fileFormatVersion: 2
guid: 4999d849d360bba4292e6aa94995556f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary_IntDecimal.cs
0 → 100644
View file @
a5fad1ad
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
NUnit.Framework
;
using
NUnit.Framework.Api
;
namespace
Anvoker.Collections.Maps.Tests.MultiMap.IDictionary
{
/// <summary>
/// Runs tests from
/// <see cref="NestedIDictionaryBase{TKey, TVal, TIDict, TValCol}"/>
/// on <see cref="MultiMap{TKey, TVal}"/> using test data from
/// <see cref="FixtureSource_IntDecimal"/>.
/// </summary>
[
TestFixture
,
TestFixtureSource
(
typeof
(
FixtureSource_IntDecimal
),
nameof
(
FixtureSource_IntDecimal
.
FixtureArgs
))]
public
class
IntDecimal
:
NestedIDictionary
<
int
,
decimal
>
{
/// <summary>
/// Initializes a new instance of the
/// <see cref="IntDecimal"/> class with and the
/// specified keys and values of <see cref="int"/> and
/// <see cref="decimal"/> type respectively.
/// </summary>
/// <param name="multiMap">An instance of
/// <see cref="MultiMap{TKey, TVal}"/> already initialized with the
/// specified keys and values.</param>
/// <param name="initialKeys">An enumeration of keys also found in the
/// specified <paramref name="multiMap"/>.
/// <para>Used to verify tests.</para></param>
/// <param name="initialValueCollections">An enumeration of collections
/// of values also found in <paramref name="multiMap"/>.
/// <para>Used to verify tests.</para></param>
/// <param name="excludedKeys">An enumeration of value of the same type
/// as the keys in <paramref name="multiMap"/>, none of which are
/// contained in <paramref name="multiMap"/>.
/// <para>Used to test for false positives.</para></param>
public
IntDecimal
(
MultiMap
<
int
,
decimal
>
multiMap
,
int
[]
initialKeys
,
ICollection
<
decimal
>[]
initialValueCollections
,
int
[]
excludedKeys
)
:
base
(
multiMap
,
initialKeys
,
initialValueCollections
,
excludedKeys
)
{
}
}
}
\ No newline at end of file
Assets/Editor/Anvoker.Collections/Maps/MultiMap/NestedIDictionary_IntDecimal.cs.meta
0 → 100644
View file @
a5fad1ad
fileFormatVersion: 2
guid: 688f05cfcf191d14088bf8e5465d3775
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment