Method MaxNewInstances
MaxNewInstances(TypeSet, Int32)
Defines that no more than a specified number of new instances of any type in the
provided typeSet
are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(TypeSet typeSet, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
TypeSet | typeSet | A TypeSet containing the types of the instances that should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(Type[], Boolean, Int32)
Defines that no more than a specified number of new instances of the provided types
(and optionally their subclasses) are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(Type[] types, bool includeSubclasses, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | types | An array containing the System.Types of the instances that should be checked. |
System.Boolean | includeSubclasses | Indicates whether instances of subclasses of the specified types should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(Type[], Int32)
Defines that no more than a specified number of new instances of the provided types
are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(Type[] types, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | types | An array containing the System.Types of the instances that should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(Type, Boolean, Int32)
Defines that no more than a specified number of new instances of the provided type
(and optionally its subclasses) are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(Type type, bool includeSubclasses, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The System.Type of the instances that should be checked. |
System.Boolean | includeSubclasses | Indicates whether instances of subclasses of the specified types should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(Type, Int32)
Defines that no more than a specified number of new instances of the provided type
are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(Type type, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The System.Type of the instances that should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(String[], Boolean, Int32)
Defines that no more than a specified number of new instances of Types
that matches the provided names
(and optionally their subclasses) are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(string[] typeNames, bool includeSubclasses, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | typeNames | An array containing the names of the |
System.Boolean | includeSubclasses | Indicates whether instances of subclasses of the specified types should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(String[], Int32)
Defines that no more than a specified number of new instances of Types
that matches the provided names
are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(string[] typeNames, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | typeNames | An array containing the names of the |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(String, Boolean, Int32)
Defines that no more than a specified number of new instances of Types
that matches the provided name
(and optionally their subclasses) are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(string typeName, bool includeSubclasses, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.String | typeName | The type name of the instances that should be checked. |
System.Boolean | includeSubclasses | Indicates whether instances of subclasses of the specified types should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.
MaxNewInstances(String, Int32)
Defines that no more than a specified number of new instances of Types
that matches the provided name
are allowed to exist when this definition is asserted using
MemAssertion.
MemAssertion.Assert.
Declaration
public AssertionsDefinition MaxNewInstances(string typeName, int instanceCount)
Parameters
Type | Name | Description |
---|---|---|
System.String | typeName | The type name of the instances that should be checked. |
System.Int32 | instanceCount | Defines the maximum number of new instances that are allowed to exist of the specified types. |
Returns
Type | Description |
---|---|
AssertionsDefinition | Returns |
Remarks
Calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will allow up to instanceCount
new instances
of the specified types to exist. If more than instanceCount
new instances exist, then
calling MemAssertion.
MemAssertion.Assert
using this AssertionsDefinition will fail.
note
The AllowXXX
(AllowInstances(TypeSet), AllowNewInstances(TypeSet)) and
MaxXXX
(MaxInstances(TypeSet, Int32), MaxNewInstances(TypeSet, Int32),
MaxBytes(TypeSet, Int64), MaxNewBytes(TypeSet, Int64)) methods takes
precedence over the NoXXX
(NoInstances(TypeSet), NoNewInstances(TypeSet)) methods.
For more information see AssertionsDefinition.