mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-21 06:45:32 -06:00
Added length tests.
This commit is contained in:
parent
ab449ad363
commit
7997adbdc7
2 changed files with 40 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ ReturnedValue NetArray::method_length(const FunctionObject *b, const Value *this
|
|||
THROW_GENERIC_ERROR("The wrapped object can't be treated as an array.");
|
||||
}
|
||||
|
||||
return Encode(scope.engine->newNumberObject(arrayFacade->getLength(netValue->getNetReference())));
|
||||
return Encode(arrayFacade->getLength(netValue->getNetReference()));
|
||||
}
|
||||
|
||||
ReturnedValue NetArray::getIndexed(const Managed *m, uint index, bool *hasProperty)
|
||||
|
|
|
|||
39
src/net/Qml.Net.Tests/Qml/ArrayTests.cs
Normal file
39
src/net/Qml.Net.Tests/Qml/ArrayTests.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Qml.Net.Tests.Qml
|
||||
{
|
||||
public class ArrayTests : BaseQmlTests<ArrayTests.ArrayTestsQml>
|
||||
{
|
||||
public class ArrayTestsQml
|
||||
{
|
||||
public virtual int[] GetArray()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Test(object value)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Can_get_length()
|
||||
{
|
||||
var array = new[] {3, 4, 6};
|
||||
Mock.Setup(x => x.GetArray()).Returns(array);
|
||||
Mock.Setup(x => x.Test(3));
|
||||
|
||||
RunQmlTest(
|
||||
"test",
|
||||
@"
|
||||
var array = Net.toJsArray(test.getArray())
|
||||
test.test(array.length)
|
||||
");
|
||||
|
||||
Mock.Verify(x => x.GetArray(), Times.Once);
|
||||
Mock.Verify(x => x.Test(3), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue