diff --git a/LICENSE b/LICENSE index 39352dbf..3203649c 100644 --- a/LICENSE +++ b/LICENSE @@ -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 @@ -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. diff --git a/README.md b/README.md index 0ead3b22..3b9c326c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Telerik.JustMock.Tests/MockResetFixture.cs b/Telerik.JustMock.Tests/MockResetFixture.cs new file mode 100644 index 00000000..09460544 --- /dev/null +++ b/Telerik.JustMock.Tests/MockResetFixture.cs @@ -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(); + Mock.Arrange(() => staticFoo.FooNotImplemented()); + } + + [ClassCleanup] + public static void ClassCleanup() + { + Mock.Reset(); + Assert.Throws(() => staticFoo.FooNotImplemented()); + } +#elif !NUNIT && !XUNIT + private static Foo staticFoo; + [ClassInitialize] + public static void ClassInitialize(TestContext ctx){ + staticFoo = Mock.Create(); + Mock.Arrange(() => staticFoo.FooNotImplemented()); + } + + [ClassCleanup] + public static void ClassCleanup() + { + Mock.Reset(); + Assert.Throws(() => staticFoo.FooNotImplemented()); + } + +#endif + private Foo myFoo; + [TestInitialize] + public void TestInit() + { + myFoo = Mock.Create(); + Mock.Arrange(() => myFoo.FooNotImplemented()); + } + + [TestCleanup] + public void TestCleanup() + { + Mock.Reset(); + Assert.Throws(() => myFoo.FooNotImplemented()); + } + + [TestMethod] + public void ThrowNotImplementedAfterMockReset() + { + // Arrange + var myFoo = Mock.Create(); + + // Act + Mock.Reset(); + + // Assert + Assert.Throws(() => myFoo.FooNotImplemented()); + } + + [TestMethod] + public void DoNotThrowErrorWithMockReset() + { + // Act + Mock.Reset(); + + // Assert + myFoo.FooNotImplemented(); + + } + + class Foo + { + public void FooNotImplemented() + { + throw new NotImplementedException(); + } + } + + } +} diff --git a/Telerik.JustMock.Tests/Telerik.JustMock.Tests.projitems b/Telerik.JustMock.Tests/Telerik.JustMock.Tests.projitems index 69b424c9..5c9bf993 100644 --- a/Telerik.JustMock.Tests/Telerik.JustMock.Tests.projitems +++ b/Telerik.JustMock.Tests/Telerik.JustMock.Tests.projitems @@ -47,6 +47,7 @@ +