Пример #1
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();
        }
Пример #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserHomes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserHomes(UserHome userHome)
 {
     base.AddObject("UserHomes", userHome);
 }
Пример #3
0
 /// <summary>
 /// Create a new UserHome object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static UserHome CreateUserHome(global::System.Guid id)
 {
     UserHome userHome = new UserHome();
     userHome.Id = id;
     return userHome;
 }