Skip to content

Commit

Permalink
Fix coverage results (#192)
Browse files Browse the repository at this point in the history
* Add UT

* Fix namespaces and coverage

* change exclude

* fix quotes
  • Loading branch information
shargon committed Mar 2, 2020
1 parent cf4f8c8 commit adf9425
Show file tree
Hide file tree
Showing 49 changed files with 85 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
- name: Add package coverlet.msbuild
run: find tests -name *.csproj | xargs -I % dotnet add % package coverlet.msbuild
- name: Test Neo.Compiler.MSIL.UnitTests
run: dotnet test tests/Neo.Compiler.MSIL.UnitTests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/ /p:Exclude="[Neo.SmartContract.*]*"
run: dotnet test tests/Neo.Compiler.MSIL.UnitTests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/ /p:Exclude=\"[Neo.SmartContract.*]*,[Neo.Compiler.MSIL.UnitTests]*,[Neo.Compiler.MSIL.UnitTests.*]*\"
- name: Test Neo.SmartContract.Framework.UnitTests
run: dotnet test tests/Neo.SmartContract.Framework.UnitTests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov /p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json /p:Exclude="[Neo.SmartContract.*]*" /p:CoverletOutputFormat=lcov
run: dotnet test tests/Neo.SmartContract.Framework.UnitTests /p:CollectCoverage=true /p:CoverletOutput=${GITHUB_WORKSPACE}/coverage/lcov /p:MergeWith=${GITHUB_WORKSPACE}/coverage/coverage.json /p:Exclude=\"[Neo.SmartContract.*]*,[Neo.Compiler.MSIL.UnitTests]*,[Neo.Compiler.MSIL.UnitTests.*]*\" /p:CoverletOutputFormat=lcov
- name: Coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract1.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
public class Contract1 : SmartContract.Framework.SmartContract
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract2.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
public class Contract2 : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Text;
using System.Numerics;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
struct State
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.ComponentModel;
using System.Numerics;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
public class Contract_Event : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Neo.SmartContract.Framework;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_a : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Neo.SmartContract.Framework;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_a : SmartContract.Framework.SmartContract
{
Expand Down
15 changes: 14 additions & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_NULL.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Neo.SmartContract.Framework.Services.Neo;
using Neo.SmartContract.Framework;
namespace Neo.Compiler.MSIL.TestClasses

namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_NULL : SmartContract.Framework.SmartContract
{
Expand Down Expand Up @@ -40,10 +41,22 @@ public static string NullCollation(string code)
string myname = code ?? "linux";
return myname;
}

public static bool IfNull(object obj)
{
if ((bool)obj)
{
return true;
}

return false;
}

public static object NullCollationAndCollation(string code)
{
return Storage.Get(code)?.AsBigInteger() ?? 123;
}

public static object NullCollationAndCollation2(string code)
{
Storage.Put(code, "111");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_staticvar : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Neo.SmartContract.Framework.Services.System;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_staticvar : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_SwitchValid : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_SwitchInvalid : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;
using System.ComponentModel;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
public class Contract_WrongEvent : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Neo.SmartContract.Framework;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_syscall : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using System.Text;

namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_autoentrypoint : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_shift : SmartContract.Framework.SmartContract
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.TestClasses
namespace Neo.Compiler.MSIL.UnitTests.TestClasses
{
class Contract_shift_bigint : SmartContract.Framework.SmartContract
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/TestClasses/NoContract.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Neo.SmartContract.Framework;

namespace Neo.Compiler.MSIL.TestClasses
{
class NoContract
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.VM.Types;
using System;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest1
Expand Down
5 changes: 2 additions & 3 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_ABI_Event.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;
using Neo.Compiler.MSIL.UnitTests.Utils;
using System;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_ABI_Event
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Appcall.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_AppCall
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Array.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.VM.Types;
using System.Linq;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_Array
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_AutoEntrypoint.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.VM;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_AutoEntryPoint
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_EntryPoints.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_EntryPoints
Expand Down
15 changes: 13 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_NULL.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.SmartContract.Manifest;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_NULL
Expand Down Expand Up @@ -39,6 +39,17 @@ public void IsNull()
Assert.IsFalse(item.ToBoolean());
}

[TestMethod]
public void IfNull()
{
testengine.Reset();
var result = testengine.ExecuteTestCaseStandard("ifNull", StackItem.Null);
var item = result.Pop();

Assert.IsInstanceOfType(item, typeof(Integer));
Assert.IsFalse(item.ToBoolean());
}

[TestMethod]
public void NullCoalescing()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Shift.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.SmartContract;
using System;
using System.Collections.Generic;
using System.Numerics;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_Shift
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_StaticVar.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.VM.Types;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_StaticVar
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Switch.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.VM;

namespace Neo.Compiler.MSIL
namespace Neo.Compiler.MSIL.UnitTests
{
[TestClass]
public class UnitTest_Switch
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/Utils/BuildScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using System.IO;

namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
public class BuildScript
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/Utils/DefLogger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
internal class DefLogger : ILogger
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/Utils/NeonTestTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Security.Cryptography;
using System.Text;

namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
internal static class NeonTestTool
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/Utils/TestDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;
using System.Linq;

namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
public class TestDataCache<TKey, TValue> : DataCache<TKey, TValue>
where TKey : IEquatable<TKey>, ISerializable
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/Utils/TestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System;
using System.Collections.Generic;

namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
public class TestEngine : ApplicationEngine
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Neo.IO;
using Neo.IO.Caching;

namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
public class TestMetaDataCache<T> : MetaDataCache<T> where T : class, ICloneable<T>, ISerializable, new()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Compiler.MSIL.UnitTests/Utils/TestSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Neo.Network.P2P.Payloads;
using Neo.Persistence;

namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
public class TestSnapshot : StoreView
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neo.Compiler.MSIL.Utils
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
class TestStorageContext
{
Expand Down
5 changes: 1 addition & 4 deletions tests/Neo.Compiler.MSIL.UnitTests/Utils/base58.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace ThinNeo.Cryptography.Cryptography
namespace Neo.Compiler.MSIL.UnitTests.Utils
{
public static class Base58
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.SmartContract.Framework.UnitTests/FeatureTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using System.Linq;

namespace Neo.SmartContract.Framework.UnitTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.Ledger;
using Neo.VM.Types;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.Compiler.MSIL.UnitTests.Utils;
using Neo.IO;
using Neo.Ledger;
using Neo.VM;
Expand Down
Loading

0 comments on commit adf9425

Please sign in to comment.