-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use common signing (#208) o closes telerik/MATTeam#710 * Support for .NET Standard 2.1 (#209) o converted JustMock project .NET Core App 2.0 target to .NET Standard 2.1 o removed JustMock project .NET Framework 4.5.0 target o re-target all JustMock dependent projects to .NET Framework 4.7.2 * Raise Async Event causes Method Signature Error (#211) * Raise Async Event causes Method Signature Error o closes #745 * Raise Async Event causes Method Signature Error o applied review comments * Support for .NET 9 preview 6 (#212) o fixed ref returns interception * Fix the vulnerable transitive dependency to System.Security.Permissions 5.0.0 (#213) o closes telerik/MATTeam#753 * fix: Implement methods for automocking #759 - Implement Arrange and ReturnsAsync methods for Task; - Implement Arrange method for ValueTask; * fix: Add tests for automocking - Add test for Arrange an ReturnsAsync; * chore: Change copyright information * chore: Replace tabs with spaces (#216) * chore: Replace tabs with spaces - Closes #782 * fix: Broken symbols --------- Co-authored-by: Maria Chervenkova <[email protected]> * fix: Set NEWOBJ_INTERCEPTION_ON_OVERWRITE var to be disabled by default (#217) Co-authored-by: Maria Chervenkova <[email protected]> * Fix .NET versions in the readme files (#218) * fix: Create tests for Mock.Reset (#220) * fix: Create tests for Mock.Reset * fix: SonarQube scanner findings - Refactor test code to remove copy-paste --------- Co-authored-by: Maria Chervenkova <[email protected]> * Update license files (#221) * Update license files (#222) * Update license files (#223) o replace the link --------- Co-authored-by: Ivo Stoilov <[email protected]> Co-authored-by: Maria Chervenkova <[email protected]>
- Loading branch information
1 parent
d6df950
commit ff2b573
Showing
4 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
#region JustMock Test Attributes | ||
#if NUNIT | ||
using NUnit.Framework; | ||
using TestCategory = NUnit.Framework.CategoryAttribute; | ||
using TestClass = NUnit.Framework.TestFixtureAttribute; | ||
using TestMethod = NUnit.Framework.TestAttribute; | ||
using TestInitialize = NUnit.Framework.SetUpAttribute; | ||
using TestCleanup = NUnit.Framework.TearDownAttribute; | ||
using AssertionException = NUnit.Framework.AssertionException; | ||
#if NUNIT3 | ||
using ClassInitialize = NUnit.Framework.OneTimeSetUpAttribute; | ||
using ClassCleanup = NUnit.Framework.OneTimeTearDownAttribute; | ||
#endif | ||
#elif XUNIT | ||
using Xunit; | ||
using Telerik.JustMock.XUnit.Test.Attributes; | ||
using TestCategory = Telerik.JustMock.XUnit.Test.Attributes.XUnitCategoryAttribute; | ||
using TestClass = Telerik.JustMock.XUnit.Test.Attributes.EmptyTestClassAttribute; | ||
using TestMethod = Xunit.FactAttribute; | ||
using TestInitialize = Telerik.JustMock.XUnit.Test.Attributes.EmptyTestInitializeAttribute; | ||
using TestCleanup = Telerik.JustMock.XUnit.Test.Attributes.EmptyTestCleanupAttribute; | ||
using AssertionException = Telerik.JustMock.XUnit.AssertFailedException; | ||
#elif VSTEST_PORTABLE | ||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; | ||
using AssertionException = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AssertFailedException; | ||
#else | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using AssertionException = Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException; | ||
#endif | ||
#endregion | ||
|
||
namespace Telerik.JustMock.Tests | ||
{ | ||
[TestClass] | ||
public class MockResetFixture | ||
{ | ||
#if NUNIT3 | ||
private static Foo staticFoo; | ||
[ClassInitialize] | ||
public static void ClassInitialize() | ||
{ | ||
staticFoo = Mock.Create<Foo>(); | ||
Mock.Arrange(() => staticFoo.FooNotImplemented()); | ||
} | ||
|
||
[ClassCleanup] | ||
public static void ClassCleanup() | ||
{ | ||
Mock.Reset(); | ||
Assert.Throws<NotImplementedException>(() => staticFoo.FooNotImplemented()); | ||
} | ||
#elif !NUNIT && !XUNIT | ||
private static Foo staticFoo; | ||
[ClassInitialize] | ||
public static void ClassInitialize(TestContext ctx){ | ||
staticFoo = Mock.Create<Foo>(); | ||
Mock.Arrange(() => staticFoo.FooNotImplemented()); | ||
} | ||
|
||
[ClassCleanup] | ||
public static void ClassCleanup() | ||
{ | ||
Mock.Reset(); | ||
Assert.Throws<NotImplementedException>(() => staticFoo.FooNotImplemented()); | ||
} | ||
|
||
#endif | ||
private Foo myFoo; | ||
[TestInitialize] | ||
public void TestInit() | ||
{ | ||
myFoo = Mock.Create<Foo>(); | ||
Mock.Arrange(() => myFoo.FooNotImplemented()); | ||
} | ||
|
||
[TestCleanup] | ||
public void TestCleanup() | ||
{ | ||
Mock.Reset(); | ||
Assert.Throws<NotImplementedException>(() => myFoo.FooNotImplemented()); | ||
} | ||
|
||
[TestMethod] | ||
public void ThrowNotImplementedAfterMockReset() | ||
{ | ||
// Arrange | ||
var myFoo = Mock.Create<Foo>(); | ||
|
||
// Act | ||
Mock.Reset(); | ||
|
||
// Assert | ||
Assert.Throws<NotImplementedException>(() => myFoo.FooNotImplemented()); | ||
} | ||
|
||
[TestMethod] | ||
public void DoNotThrowErrorWithMockReset() | ||
{ | ||
// Act | ||
Mock.Reset(); | ||
|
||
// Assert | ||
myFoo.FooNotImplemented(); | ||
|
||
} | ||
|
||
class Foo | ||
{ | ||
public void FooNotImplemented() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters