コード例 #1
0
        public void TestUserHomeController()
        {
            UserHomeController controller = new UserHomeController();
            ViewResult         result     = controller.NearByClasses() as ViewResult;

            Assert.IsNotNull(result);
        }
コード例 #2
0
        public void TestCreatingUserHomeWithNewHome()
        {
            var mock = new Moq.Mock<IPersistanceFramework>();
            var controller = new UserHomeController();
            new PrivateObject(controller).SetFieldOrProperty("Persistance",mock.Object);
            mock.Setup(p => p.CreateQueryContext<Home>()).Returns(HomesList);
            var newHomeThatShouldBeCreated = new Home();
            mock.Setup(p => p.Create<Home>()).Returns(newHomeThatShouldBeCreated);
            mock.Setup(p => p.SaveChanges());

            var enteredHome = new UserHome();
            enteredHome.Name = "TestName";

            var userId = Guid.NewGuid();
            controller.CreateChildByAddress(userId, enteredHome, "TestAddress", 1, 1);

            Assert.AreEqual(userId, enteredHome.AppUserId);
            Assert.AreEqual("TestAddress", enteredHome.Home.AddressFull);

            mock.VerifyAll();
        }