or

class MyClass{ public void Method1() { } public void Method2() { } public void Method3() { }}class ClassUnderTest{ public void DoSomething(MyClass myClass) { myClass.Method3(); }}[Test]void MyClass_methods_are_never_called(){ // ARRANGE var myClass = Mock.Create<MyClass>(); Mock.Arrange(() => myClass.Method1()).OccursNever(); Mock.Arrange(() => myClass.Method2()).OccursNever(); Mock.Arrange(() => myClass.Method3()).OccursNever(); // ACT var classUnderTest = new ClassUnderTest(); classUnderTest.DoSomething(myClass); // ASSERT Mock.Assert(myClass); // this will fail}
Assert.IsTrue(Mock.IsProfilerEnabled);
[16:41:15][Step 6/7] NuSoft.Printer.Rs232.Tests.dll[16:41:15][NuSoft.Printer.Rs232.Tests.dll] NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted[16:41:15][NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted] Test(s) failed. Expected: True But was: False[16:41:15][NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted] Test(s) failed. Expected: True But was: False at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args) at NUnit.Framework.Assert.IsTrue(Boolean condition) at NuSoft.Printer.Rs232.Tests.PrinterTest.CheckProfiler() in c:\TeamCity\buildAgent\work\64cb9cb36a4269ed\NuSoft.Printer.Rs232.Tests\PrinterTest.cs:line 18 at NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted() in c:\TeamCity\buildAgent\work\64cb9cb36a4269ed\NuSoft.Printer.Rs232.Tests\PrinterTest.cs:line 24I followed manual http://www.telerik.com/help/justmock/integration-teamcity.html section Integrating JustMock within TeamCity using MS Test or NUnit build steps with dotCover and Profiler is linked to dotCover (the only one installed is the one bundled with TeamCity) and JUSTMOCK_INSTANCE=1 variable is present in build parameters.
tests run in VS2012, also when configured accordingly to Integrating JustMock within TeamCity using MS Test or NUnit build steps.
Telerik.JustMock - 2013.2.611.0
TeamCity - 7.1.5 (build 24400)
is there any thing that can be done in order to configure justmock to run on teamcity with nUint and dotCover?
var mockDocumentRepository = Mock.Create<IDocumentRepository>(); Mock.Arrange(() => mockDocumentRepository.FetchDocumentsByListCriteria(Arg.IsAny<ListCriteria>(), Arg.AnyInt, Arg.AnyInt, out virtualCount)).Returns(GetFakeDocumentListWithChildren_OneChildLevel());
public void Persist(){ try { OperationsData data = new OperationsData(); this.ExceptionId = data.PersistException(this.Id, this.ExceptionCode, this.ComponentName, this.SeverityIndicator.ToString(), this.ProcessName, this.BusinessExceptionDetail, this.StackTrace); } catch (Exception ex) {...}}[TestMethod()]public void SuccessfulPersistTest(){ /// Arrange long expectedExceptionID = 12345; long ID = 678901; string exceptionCode = string.Empty; string componentName = string.Empty; string severityIndicator = string.Empty; string processName = string.Empty; string businessExceptionDetail = string.Empty; string stackTrace = string.Empty; OperationsData_Accessor operationsData = new OperationsData_Accessor(); operationsData.Arrange(od => od.PersistException(ID, exceptionCode, componentName, severityIndicator, processName, businessExceptionDetail, stackTrace)) .IgnoreInstance() .Returns(expectedExceptionID); ///Action ComponentException_Accessor target = new ComponentException_Accessor(); target.Persist(); ///Assert Assert.AreEqual(expectedExceptionID, target.ExceptionId); operationsData.Assert();}OperationsData_Accessor operationsData = Mock.Create<OperationsData_Accessor>(Constructor.Mocked);
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)at . . (MethodInfo )at . . (MockInvocation )at . .Intercept(MockInvocation )at . .Intercept(MockInvocation )at . .Intercept(IInvocation )var _mockServiceContext = Mock.Create<SPServiceContext>();var _mockUserProfileManager = Mock.Create<UserProfileManager>(new object[] {_mockServiceContext});_mockServiceContext = Mock.Create<SPServiceContext>();using System;using System.Linq;using Microsoft.VisualStudio.TestTools.UnitTesting;using MockEvent;using Telerik.JustMock;namespace TestEvent{ [TestClass] public class JustMockTest1 { [TestMethod] public void TestMethod1() { var mc = new MyClass(); var args = new EventArgs(); Mock.Raise(() => mc.TestEvent += null, args); } }}using System;using System.Linq;namespace MockEvent{ public class MyClass { public event TestMethod TestEvent; public delegate void TestMethod(object sender, EventArgs args); public MyClass() { TestEvent += MyClass_TestEvent; } void MyClass_TestEvent(object sender, EventArgs args) { Console.WriteLine("Running Event"); } }}