public void AddHome(Home home) { var service = CreateService(); var entry = new AtomEntry(); entry.Title.Text = "Home Zope House"; entry.Content.Type = "application/vnd.google-earth.kml+xml"; XmlDocument doc = new XmlDocument(); string placeMark = string.Format(@"<Placemark xmlns='http://www.opengis.net/kml/2.2'> <name>HomeZope Home</name> <description/> <Point> <coordinates>{0},{1},0.0</coordinates> </Point> </Placemark>", home.Longitude, home.Latitude); doc.LoadXml(placeMark); entry.Content.ExtensionElements.Add(new XmlExtension(doc.DocumentElement)); var insertedEntry = service.Insert(new Uri("http://maps.google.com/maps/feeds/features/208433541473729117510/0004779109f86bbabd62d/full"), entry); home.GoogleFeatureId = insertedEntry.Id.Uri.ToString(); //var m = new MemoryStream(); //insertedEntry.SaveToXml(m); //m.Position = 0; //var xml = new StreamReader(m).ReadToEnd(); }
public void InsertExistDeleteTest() { var service = new MapDataService(); var home = new Home(); home.Latitude = -89.520753; home.Longitude = 34.360902; service.AddHome(home); Assert.IsFalse(string.IsNullOrEmpty(home.GoogleFeatureId)); Assert.IsTrue(service.Exist(home.GoogleFeatureId)); service.Delete(home.GoogleFeatureId); Assert.IsFalse(service.Exist(home.GoogleFeatureId)); }
public void TestGetOrCreateHomeWithNewHomeShouldCreateANewHome() { var mockPersistance = new Moq.Mock<IPersistanceFramework>(); mockPersistance.Setup(m => m.CreateQueryContext<Home>()).Returns( TestHomes); var homeToBeCreated = new Home(); mockPersistance.Setup(m => m.Create<Home>()).Returns(homeToBeCreated); var repository = new HomeRepository(mockPersistance.Object); var results = repository.GetOrCreateHome("new address", 1, 1); Assert.AreNotEqual(TestHomes.First().Id, results.Id); homeToBeCreated.AddressFull = "new address"; mockPersistance.VerifyAll(); }
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(); }
public void AddHomeTest() { var factory = new FakeRepositoryFactory(); var controller = new HomeController(factory); Guid nhid = Guid.NewGuid(); var context = new ControllerContext(); context.RouteData.Values.Add("nhid", nhid.ToString()); controller.ControllerContext = context; var home = new Home(); factory.MockHomeRepository.Setup(hr => hr.GetOrCreateHome("newAddress", 1, 1)).Returns(home); factory.MockHomeRepository.Setup(hr => hr.SaveChanges()); factory.MockNeighborhoodRepository.Setup(nr => nr.AddHome(nhid, home)); factory.MockNeighborhoodRepository.Setup(nr => nr.SaveChanges()); var result = controller.AddHome("newAddress", 1, 1); factory.MockHomeRepository.VerifyAll(); factory.MockNeighborhoodRepository.VerifyAll(); Assert.AreEqual("Homes", ((RedirectToRouteResult)result).RouteValues["action"].ToString()); }
public void AddHome(Home home) { throw new NotImplementedException(); }
/// <summary> /// Deprecated Method for adding a new object to the Homes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToHomes(Home home) { base.AddObject("Homes", home); }
/// <summary> /// Create a new Home object. /// </summary> /// <param name="id">Initial value of the Id property.</param> public static Home CreateHome(global::System.Guid id) { Home home = new Home(); home.Id = id; return home; }