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(); }
/// <summary> /// Deprecated Method for adding a new object to the UserHomes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUserHomes(UserHome userHome) { base.AddObject("UserHomes", userHome); }
/// <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; }