Hi,

I am a newbie in testing frameworks and rhino mocks is the first one I am 
trying to implement in visual studio 2012 for a c# project.

I have included the rhino mocks *.dll as a reference and made two classes 
in a single project.

I got the code from @ 
http://aspalliance.com/1400_Beginning_to_Mock_with_Rhino_Mocks_and_MbUnit__Part_1.4

program.cs
====
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SampleRhinoMocksTestingApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            ImageManagement image = new ImageManagement();
            string path = image.GetImageForTimeOfDay(new 
DateTimeController());
            Console.WriteLine(path);
            Console.ReadLine(); 
        }
    }

    public class DateTimeController : IDateTime
    {
        public int GetHour()
        {
            return DateTime.Now.Hour;
        }
    }

    public class ImageManagement
    {
        public string GetImageForTimeOfDay(IDateTime time)
        {
            int currentHour = time.GetHour();

            if (currentHour > 6 && currentHour < 21)
            {
                return "sun.jpg";
            }
            else
            {
                return "moon.jpg";
            }
        }
    }  

    public interface IDateTime
    {
        int GetHour();
    }
}
====

TestClass.cs
====
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rhino.Mocks;
using SampleRhinoMocksTestingApplication;

namespace RhinoTests
{
    [TestClass]
    class Program
    {
        [TestMethod] 
        public void DaytimeTest()
        {
            MockRepository mocks = new MockRepository();
            IDateTime timeController = mocks.StrictMock<IDateTime>();

            using (mocks.Record())
            {
                Expect.Call(timeController.GetHour()).Return(15);
            }

            using (mocks.Playback())
            {
                string expectedImagePath = "sun.jpg";
                ImageManagement image = new ImageManagement();
                string path = image.GetImageForTimeOfDay(timeController);
                Assert.AreEqual(expectedImagePath, path);
            }
        }

        [TestMethod] 
        public void NighttimeTest()
        {
            MockRepository mocks = new MockRepository();
            IDateTime timeController = mocks.StrictMock<IDateTime>();
            using (mocks.Record())
            {
                Expect.Call(timeController.GetHour()).Return(1);
            }

            using (mocks.Playback())
            {
                string expectedImagePath = "moon.jpg";
                ImageManagement image = new ImageManagement();
                string path = image.GetImageForTimeOfDay(timeController);
                Assert.AreEqual(expectedImagePath, path);
            }
        }
    }
}
====

I have been able to build the project successfully.

But when I go to menu bar in visual studio 2012 to; Test -> Windows -> Test 
Explorer; the test explorer open but I am unable to find any of the test 
methods in the list.

I have search the internet for configuring up rhino mocks in visual studio 
2012 but unable to find a good guide. Please let me know to how to set up 
the framework or anything I am missing.

Thanks.

-littlechap22

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rhinomocks/-/LEpigLEIxB0J.
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.

Reply via email to