Skip to content

Commit

Permalink
merge develop into master (#224)
Browse files Browse the repository at this point in the history
* 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
3 people authored Dec 3, 2024
1 parent d6df950 commit ff2b573
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 1 deletion.
12 changes: 11 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Packaged distributions of JustMock Lite obtained from NuGet are made
available pursuant to the Progress® Telerik® JustMock EULA at
https://www.telerik.com/purchase/license-agreements, unless you have
entered into a separate software license agreement with the licensor
that covers JustMock Lite.

Source code obtained from the Progress Telerik JustMock Lite GitHub
repository is made available under Apache-2.0, a copy of which is
included below.

Apache License
Version 2.0, January 2004
Expand Down Expand Up @@ -187,7 +196,8 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2010-2018 Telerik EAD
Copyright 2010-2024 Progress Software Corporation and/or its subsidiaries
or affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ JustMock
- **Mock Microsoft EntityFramework** - Allows you to easily create in-memory mocks of the DbSet and DbContext types.
- And many more

### Licensing

Packaged distributions of Progress Telerik JustMock Lite obtained from NuGet are made available pursuant to the Progress Telerik JustMock EULA at https://www.telerik.com/purchase/license-agreements, unless you have entered into a separate MSA with the licensor.

Source code obtained from the Progress Telerik JustMock Lite GitHub repository is made available under Apache-2.0.

### Examples

```csharp
Expand Down
120 changes: 120 additions & 0 deletions Telerik.JustMock.Tests/MockResetFixture.cs
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();
}
}

}
}
1 change: 1 addition & 0 deletions Telerik.JustMock.Tests/Telerik.JustMock.Tests.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<Compile Include="$(MSBuildThisFileDirectory)MatchersFixture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MiscFixture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MockFixture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MockResetFixture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)NinjectAutoMockFixture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)NonPublicFixture.cs" />
<Compile Include="$(MSBuildThisFileDirectory)OccurrenceFixture.cs" />
Expand Down

0 comments on commit ff2b573

Please sign in to comment.