예제 #1
0
        public void UserAgentTest2()
        {
            VirtualManager virtualManager = new VirtualManager();
            FieldInfo      fi             = virtualManager.GetType().GetField("VIRTUAL_DTO", BindingFlags.NonPublic | BindingFlags.Static);

            Mock <VirtualDto> dto = new Mock <VirtualDto>();

            dto.Setup(m => m.VirtualName()).Returns("virtualName");

            fi.SetValue(null, dto.Object);


            _homeController = new HomeController(_mockHttpContextBase.Object, _mockAboutManager.Object, _mockContactManager.Object, virtualManager);

            string userAgent = "Chrome";

            _mockHttpContextBase.Setup(m => m.Request.UserAgent).Returns(userAgent).Verifiable();

            ViewResult result = (ViewResult)_homeController.UserAgent();

            _mockHttpContextBase.Verify(m => m.Request.UserAgent, Times.Once);

            HomeViewModel resultmodel = (HomeViewModel)result.Model;

            Assert.AreEqual(userAgent, resultmodel.Browser);
            Assert.AreEqual("virtualName", resultmodel.Virtual.VirtualName());
        }
        public void ReadTest()
        {
            VirtualManager virtualManager = new VirtualManager();

            VirtualDto result = virtualManager.Read();

            Assert.AreEqual("This is the original hard coded name", result.HardCodedName());
            Assert.AreEqual(new VirtualDto().HardCodedName(), result.HardCodedName());
            //
        }
예제 #3
0
        public HomeController(HttpContextBase httpContextBase, IAboutManager aboutManager, IContactManager contactManager, VirtualManager virtualManager)
            : base(httpContextBase)
        {
            if (null == aboutManager)
            {
                throw new ArgumentNullException(nameof(aboutManager));
            }

            if (null == contactManager)
            {
                throw new ArgumentNullException(nameof(contactManager));
            }

            if (null == virtualManager)
            {
                throw new ArgumentNullException(nameof(virtualManager));
            }

            _aboutManager   = aboutManager;
            _contactManager = contactManager;
            _virtualManager = virtualManager;
        }
예제 #4
0
 public HomeController()
 {
     _aboutManager   = new AboutManager(new DatabaseManager());
     _contactManager = new ContactManager(new DatabaseManager());
     _virtualManager = new VirtualManager();
 }