public LocationsWebServicesController(ILocationServices _locationServices, ICodeServices _codeServices, IUserLocationServices _userLocationServices, ICommentServices _commentServices)
 {
     locationServices = _locationServices;
     codeServices = _codeServices;
     userLocationServices = _userLocationServices;
     commentServices = _commentServices;
     userLocationWebServices = new UserLocationWebServicesController(_codeServices, _userLocationServices, _commentServices);
 }
 public LocationsWebServicesController()
 {
     locationServices = new LocationServices(new SmartAudioCityGuideEntities());
     codeServices = new CodeServices(new SmartAudioCityGuideEntities());
     userLocationServices = new UserLocationServices(new SmartAudioCityGuideEntities());
     commentServices = new CommentServices(new SmartAudioCityGuideEntities());
     userLocationWebServices = new UserLocationWebServicesController();
 }
 public void addUserLocationTest()
 {
     Random randomString = new Random();
     string stringRandom = randomString.Next().ToString();
     iUserLocationServices.Setup(m => m.addUserLocation(It.IsAny<UserLocations>()));
     iCodeServices.Setup(m => m.findFirstCode()).Returns(stringRandom);
     UserLocationWebServicesController target = new UserLocationWebServicesController(iCodeServices.Object,iUserLocationServices.Object,iCommentServices.Object);
     string userId = "253525";
     string windowsPhoneId = "7123";
     string latitude = "2";
     string longitude = "3";
     string code = stringRandom;
     bool actual;
     actual = target.addUserLocation(userId, windowsPhoneId, latitude, longitude, code);
     Assert.AreEqual(true, actual);
     actual = target.addUserLocation(userId, windowsPhoneId, latitude, longitude, "12313");
     Assert.AreEqual(false, actual);
 }
 public void distanceToTest()
 {
     UserLocationWebServicesController target = new UserLocationWebServicesController(iCodeServices.Object, iUserLocationServices.Object, iCommentServices.Object);
     double longitude = 0F;
     double latitude = 0F;
     double otherLongitude = 0F;
     double otherLatitude = 0F;
     double actual;
     actual = target.distanceTo(longitude, latitude, otherLongitude, otherLatitude);
     Assert.AreEqual(0, actual);
     longitude = 10F;
     latitude = 0F;
     otherLongitude = 0F;
     otherLatitude = 0F;
     actual = target.distanceTo(longitude, latitude, otherLongitude, otherLatitude);
     Assert.AreEqual(10, actual);
     longitude = -5F;
     latitude = -10F;
     otherLongitude = 5F;
     otherLatitude = 10F;
     actual = target.distanceTo(longitude, latitude, otherLongitude, otherLatitude);
     Assert.AreEqual(actual, Math.Sqrt(500));
 }
 public void findClosestUserLocationByUserLocationTest()
 {
     List<UserLocations> list = new List<UserLocations>();
     UserLocations user = new UserLocations();
     user.latitude = 10;
     user.longitude = 20;
     user.id = 3;
     user.userId = 3;
     user.windowsPhoneId = "3";
     iCodeServices.Setup(m => m.findFirstCode()).Returns("1");
     iUserLocationServices.Setup(m => m.findUserByUserLocationAndDistance(It.IsAny<UserLocations>(), It.IsAny<double>())).Returns(list);
     iCommentServices.Setup(m => m.findCommentByIdComment(It.IsAny<int>()));
     UserLocationWebServicesController target = new UserLocationWebServicesController(iCodeServices.Object, iUserLocationServices.Object, iCommentServices.Object);
     string userLocationJson = serializer.Serialize(user);
     string code = "1";
     string actual;
     actual = target.findClosestUserLocationByUserLocation(userLocationJson, code);
     Assert.AreEqual("", actual);
     user.latitude = 15;
     list.Add(user);
     iUserLocationServices.Setup(m => m.findUserByUserLocationAndDistance(It.IsAny<UserLocations>(), It.IsAny<double>())).Returns(list);
     target = new UserLocationWebServicesController(iCodeServices.Object, iUserLocationServices.Object, iCommentServices.Object);
     actual = target.findClosestUserLocationByUserLocation(userLocationJson, code);
     Assert.IsNotNull(actual);
 }