¡@

Home 

c# Programming Glossary: mock

How do you mock out the file system in C# for unit testing?

http://stackoverflow.com/questions/1087351/how-do-you-mock-out-the-file-system-in-c-sharp-for-unit-testing

do you mock out the file system in C# for unit testing Are there any libraries.. C# for unit testing Are there any libraries or methods to mock out the file system in C# to write unit tests In my current.. I may need more than that in future. c# unit testing mocking share improve this question You could do it by creating..

How to detect the currently pressed key?

http://stackoverflow.com/questions/1100285/how-to-detect-the-currently-pressed-key

Moq: unit testing a method relying on HttpContext

http://stackoverflow.com/questions/1214178/moq-unit-testing-a-method-relying-on-httpcontext

string fullADName LOONEYTUNES BUGSBUNNY act need to mock up the HttpContext here somehow using Moq. string foundUserName.. on how to improve this code architecture c# unit testing mocking moq share improve this question Webforms is notoriously.. HttpContextWrapper HttpContext.Current Even better you can mock an HttpContextBase and set up your expectations on it using..

Design - Where should objects be registered when using Windsor

http://stackoverflow.com/questions/1410719/design-where-should-objects-be-registered-when-using-windsor

own objects. To test the BL the test bench could register mock classes for the DAL. Each layer can register the object of its.. would have to unload the real DAL object and register the mock objects. The application or test app registers all objects of..

How do I mock the HttpContext in ASP.NET MVC using Moq?

http://stackoverflow.com/questions/1452418/how-do-i-mock-the-httpcontext-in-asp-net-mvc-using-moq

do I mock the HttpContext in ASP.NET MVC using Moq TestMethod public.. requestContext Where can I get more information on mocking my RequestContext and HttpContext using Moq I am trying to.. my RequestContext and HttpContext using Moq I am trying to mock cookies and the general context. c# asp.net mvc mocking moq..

What C# mocking framework to use? [closed]

http://stackoverflow.com/questions/37359/what-c-sharp-mocking-framework-to-use

C# mocking framework to use closed I want to start using mock objects.. C# mocking framework to use closed I want to start using mock objects on my next C# project. After a quick Google search I've.. Ultimate So my question is what one is your favourite .NET mocking framework and why c# .net unit testing mocking share improve..

What do programmers mean when they say, “Code against an interface, not an object.”?

http://stackoverflow.com/questions/4456424/what-do-programmers-mean-when-they-say-code-against-an-interface-not-an-objec

only a MyClass if you want to replace MyClass with a mock object in order to unit test you can't. Better is to use an.. that interface and inherit from it to create any kind of mock or fake that you want or you can use any of the prefab mocking.. or fake that you want or you can use any of the prefab mocking libraries like Rhino.Mocks.MockRepository.StrictMock T which..

Mocking Static methods using Rhino.Mocks

http://stackoverflow.com/questions/540239/mocking-static-methods-using-rhino-mocks

Static methods using Rhino.Mocks Is it possible to mock a static method using Rhino.Mocks If Rhino does not support.. something which would let me accomplish the same c# tdd mocking rhino mocks share improve this question Is it possible.. would let me accomplish the same c# tdd mocking rhino mocks share improve this question Is it possible to mock a static..

Injecting dependencies into ASP.NET MVC 3 action filters. What's wrong with this approach?

http://stackoverflow.com/questions/7192543/injecting-dependencies-into-asp-net-mvc-3-action-filters-whats-wrong-with-this

that takes an IMyService at test time and inject a mock service that way. You're not tied down to any implementation..

Programming to interfaces while mapping with Fluent NHibernate

http://stackoverflow.com/questions/845536/programming-to-interfaces-while-mapping-with-fluent-nhibernate

this is to help make it more testable by being able to mock dependencies. However Fluent NHibernate doesn't love it when..

Unit Testing without Database: Linq to SQL

http://stackoverflow.com/questions/11348691/unit-testing-without-database-linq-to-sql

your code as before test var mockRepository new Mock ILijosBankRepository var service create object containing FreezeAllAccounts.....

Moq: unit testing a method relying on HttpContext

http://stackoverflow.com/questions/1214178/moq-unit-testing-a-method-relying-on-httpcontext

Moq. Including the logged in user etc. var mockContext new Mock HttpContextBase With this in place you can call GetSecurityContextUserName.. I highly suggest taking a look at Scott Hanselman's MvcMockHelpers class which has a version for use with Moq. It conveniently..

Best Practices of Test Driven Development Using C# and RhinoMocks [closed]

http://stackoverflow.com/questions/124210/best-practices-of-test-driven-development-using-c-sharp-and-rhinomocks

Practices of Test Driven Development Using C# and RhinoMocks closed In order to help my team write testable code I came.. testable. Some of the points refer to limitations of Rhino Mocks a mocking framework for C# but the rules may apply more generally.. methods are difficult or impossible to isolate and Rhino Mocks is unable to mock them. Program off interfaces not classes...

How do I mock the HttpContext in ASP.NET MVC using Moq?

http://stackoverflow.com/questions/1452418/how-do-i-mock-the-httpcontext-in-asp-net-mvc-using-moq

var context new Mock HttpContextBase var request new Mock HttpRequestBase context.. var context new Mock HttpContextBase var request new Mock HttpRequestBase context .Setup c c.Request .Returns request.Object..

Using IoC for Unit Testing

http://stackoverflow.com/questions/1465849/using-ioc-for-unit-testing

Test Double . You can use dynamic mocks like Moq or RhinoMocks to generate the Test Double but it is not required. var dep.. the Test Double but it is not required. var dep new Mock IMyDependency .Object var sut new MyClass dep In some cases..

Mocking Extension Methods with Moq

http://stackoverflow.com/questions/2295960/mocking-extension-methods-with-moq

Extension Methods with Moq I have a preexisting Interface..... Arrange var someInterfaceMock new Mock ISomeInterface someInterfaceMock.Setup x x.AnotherMethod.. Arrange var someInterfaceMock new Mock ISomeInterface someInterfaceMock.Setup x x.AnotherMethod .Verifiable..

Mock static property with moq

http://stackoverflow.com/questions/2416362/mock-static-property-with-moq

static property with moq I am pretty new to use moq . I am.. public void AppDomainAppVirtualPathTest var mock new Moq.Mock HttpRuntimeWrapper mock.Setup fake fake.AppDomainAppVirtualPath..

Unit Testing: DateTime.Now

http://stackoverflow.com/questions/2425721/unit-testing-datetime-now

you can replace TimeProvider.Current with a Test Double Mock object. Example using Moq var timeMock new Mock TimeProvider.. with a Test Double Mock object. Example using Moq var timeMock new Mock TimeProvider timeMock.SetupGet tp tp.UtcNow .Returns.. Double Mock object. Example using Moq var timeMock new Mock TimeProvider timeMock.SetupGet tp tp.UtcNow .Returns new DateTime..

Unit testing void methods?

http://stackoverflow.com/questions/246038/unit-testing-void-methods

The second one is slightly tricky.. you can either use a Mock google or search stackoverflow on mocking frameworks to mimic..

How can I test ModelState?

http://stackoverflow.com/questions/286124/how-can-i-test-modelstate

share improve this question You don't have to use a Mock if you're using the Repository Pattern for your data of course...

Using Moq to set indexers in C#

http://stackoverflow.com/questions/2916348/using-moq-to-set-indexers-in-c-sharp

How to Moq Setting an Indexed property var someClass new Mock ISomeClass someClass.SetupSet o o.SomeIndexedProperty 3 25 I.. it var someValues new int 10 20 30 40 var someClass new Mock ISomeClass someClass.Setup o o.SomeIndexedProperty It.IsAny..

Unit testing with EF4 “Code First” and Repository

http://stackoverflow.com/questions/3463017/unit-testing-with-ef4-code-first-and-repository

repos new WeightTrackerRepository new MockWeightTrackerContext Act List WeightEntry entries repos.GetAllWeightEntries.. Assert Assert.AreEqual 5 entries.Count And my MockWeightTrackerContext class MockWeightTrackerContext IWeightTrackerContext.. 5 entries.Count And my MockWeightTrackerContext class MockWeightTrackerContext IWeightTrackerContext public MockWeightTrackerContext..

Mock HttpContext.Current in Test Init Method

http://stackoverflow.com/questions/4379450/mock-httpcontext-current-in-test-init-method

HttpContext.Current in Test Init Method I'm trying to add unit.. FakeHttpContext string username var context new Mock HttpContextBase context.SetupGet ctx ctx.Request.IsAuthenticated.. sure i get this right. What is the correct way for me to Mock out the HttpContext so that it is shared across my controller..

Difference between Dependency Injection and Mocking framework (Ninject vs RhinoMock or Moq)

http://stackoverflow.com/questions/5433211/difference-between-dependency-injection-and-mocking-framework-ninject-vs-rhinom

between Dependency Injection and Mocking framework Ninject vs RhinoMock or Moq So what is the difference.. Dependency Injection and Mocking framework Ninject vs RhinoMock or Moq So what is the difference between Ninject a mocking.. difference between Ninject a mocking framework like RhinoMock or moq I google'd this but it is still unclear. c# .net dependency..