Hey Tim,
of course i can:
[TestCleanup()]
public void MyTestCleanup()
{
LogManager.Shutdown();
}
#endregion
[TestMethod]
public void TestBasicLogMethod()
{
using (Logger log = MockRepository.GenerateMock<Logger>
(null, null))
{
LogProvider.c_logger = log;
log.Expect(l => l.WriteToLog(LogSeverity.Debug,
"LogTest.AOPTests", "LogMethod", "OnEntry"));
log.Expect(l => l.WriteToLog(LogSeverity.Debug,
"LogTest.AOPTests", "LogMethod", "OnExit"));
LogMethod();
log.VerifyAllExpectations();
}
}
[TestMethod]
public void TestLogMethodForCategory()
{
using (Logger log = MockRepository.GenerateMock<Logger>
(null, null))
{
LogProvider.c_logger = log;
log.Expect(l => l.WriteToLog(LogSeverity.Debug,
LogCategories.LogFile | LogCategories.EventLog, "LogTest.AOPTests",
"LogMethod2", "OnEntry"));
log.Expect(l => l.WriteToLog(LogSeverity.Debug,
LogCategories.LogFile | LogCategories.EventLog, "LogTest.AOPTests",
"LogMethod2", "OnExit"));
LogMethod2();
log.VerifyAllExpectations();
}
}
[TestMethod]
public void TestLogMethodForSeverity()
{
using (Logger log = MockRepository.GenerateMock<Logger>
(null, null))
{
LogProvider.c_logger = log;
log.Expect(l => l.WriteToLog(LogSeverity.Warning,
"LogTest.AOPTests", "LogMethod3", "OnEntry"));
log.Expect(l => l.WriteToLog(LogSeverity.Warning,
"LogTest.AOPTests", "LogMethod3", "OnExit"));
LogMethod3();
log.VerifyAllExpectations();
}
}
On Nov 12, 4:43 am, Tim Barcz <[email protected]> wrote:
> Can you post all of the code here?
>
>
>
> On Wed, Nov 11, 2009 at 8:57 AM, tom308 <[email protected]> wrote:
>
> > Hi all!
> > i am new to TDD & Mocks (but very enthusiastic about it).
> > i am using MSTest & Rhino mock 3.5.
> > testing are OK when running each one separately, but when running
> > entire TestSet, the first one is OK but all other are failing.
> > My hunch is that i am holding the mocked object between tests, and
> > causing the problem (i saw that it is same object).
> > i also tried to use a repository instance insted of the static one,
> > but it didn't help.
> > can someone help ?
>
> > my tests are all from the same template:
>
> > [TestMethod]
> > public void TestBasicLogMethod()
> > {
> > using (Logger log = MockRepository.GenerateMock<Logger>
> > (null, null))
> > {
> > //set the instance into the logProvider private static
> > logger
> > LogProvider.c_logger = log;
>
> > log.Expect(l => l.WriteToLog(LogSeverity.Debug,
> > "LogTest.AOPTests", "LogMethod", "OnEntry"));
> > log.Expect(l => l.WriteToLog(LogSeverity.Debug,
> > "LogTest.AOPTests", "LogMethod", "OnExit"));
>
> > LogMethod();
> > log.VerifyAllExpectations();
> > }
> > }
>
> --
> Tim Barcz
> Microsoft C# MVP
> Microsoft ASPInsiderhttp://timbarcz.devlicio.ushttp://www.twitter.com/timbarcz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en
-~----------~----~----~----~------~----~------~--~---