示例#1
0
 public void RoutesRepository_GetHashByTrack_NullReference_IncorrectData(string track)
 {
     // Arrange
     var repository = new RoutesRepository(_datacontext);
     //Act
     var result = repository.GetHashByTrack(track);
 }
        public void RoadsManager_GetFindRouteDetailsModel_NegativeTestsForArgumentNullException(string hash, string language)
        {
            //arrange
            var routesRepository = new RoutesRepository(_datacontext);
            var manager = new RoadsManager(routesRepository);

            //act
            Common.Models.DataContract.RouteDetailsData routeDetailsData = manager.GetRouteDetailsByHash(hash, language);
        }
示例#3
0
 public void RoutesRepository_GetHashByTrack_CorrectData(string track, string expectedResult)
 {
     // Arrange
     var repository = new RoutesRepository(_datacontext);
     //Act
     var result = repository.GetHashByTrack(track);
     //Assert
     Assert.AreEqual(result, expectedResult);
 }
示例#4
0
        public void RoadsManager_GetHashForRoute(string trek, string hash)
        {
            //arrange
            var repository = new RoutesRepository(_datacontext);

            var manager = new RoadsManager(repository);

            //act
            var result = manager.GetHashForRoute(trek);

            //asserts
            Assert.AreEqual(result, hash);
        }
示例#5
0
        public void RoadsManager_BuildRoutes_CheckNumbersOfResponse(int fromId, int toId, int count)
        {
            //arrange
            var repository = new RoutesRepository(_datacontext);

            var manager = new RoadsManager(repository);

            //act
            var result = manager.BuildRoutes(fromId, toId);

            //assert
            Assert.AreEqual(result.Count, count);
        }
示例#6
0
        public void RoutesRepository_GetRoutDetailsFeedbackFor_NullLanguage()
        {
            // Arrange
            int wrongOriginCityNodeID = 11;
            int destinationCityNodeID = 5;
            var repository = new RoutesRepository(_datacontext);
            var originCityNode = _datacontext.CityNodes.SingleOrDefault(m => m.CityNodeId == wrongOriginCityNodeID);
            var destinationCityNode = _datacontext.CityNodes.SingleOrDefault(m => m.CityNodeId == destinationCityNodeID);
            var routeNode = new RouteNode { RouteNodeId = 1, OriginCityNodeId = 11, DestinationCityNodeId = 5, OriginCityNode = originCityNode, DestinationCityNode = destinationCityNode };
            string lang = null;

            //Act
            var result = repository.GetRoutDetailsFeedbackFor(routeNode, lang);
        }
        public void RoadsManager_GetFindRouteDetailsModel_NegativeTests(string hash, string language)
        {
            //arrange
            var routesRepository = new RoutesRepository(_datacontext);
            var manager = new RoadsManager(routesRepository);

            //act
            Common.Models.DataContract.RouteDetailsData routeDetailsData = manager.GetRouteDetailsByHash(hash, language);

            //assert
            Assert.IsNotNull(routeDetailsData);
            Assert.IsNotNull(routeDetailsData.RouteDetailsItems);
            Assert.AreEqual(routeDetailsData.RouteDetailsItems.Count, 0);
        }
示例#8
0
        public void RoutesRepository_GetRoutDetailsFeedbackFor_PosistiveTest(int originCityNodeID, int destinationCityNodeID, string lang, string[] expected)
        {
            // Arrange
            var repository = new RoutesRepository(_datacontext);
            var originCityNode = _datacontext.CityNodes.SingleOrDefault(m => m.CityNodeId == originCityNodeID);
            var destinationCityNode = _datacontext.CityNodes.SingleOrDefault(m => m.CityNodeId == destinationCityNodeID);
            var routeNode = new RouteNode
            {
                RouteNodeId = 1,
                OriginCityNodeId = 11,
                DestinationCityNodeId = 5,
                OriginCityNode = originCityNode,
                DestinationCityNode = destinationCityNode
            };

            //Act
            var result = repository.GetRoutDetailsFeedbackFor(routeNode, lang);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, expected.Length);
            Assert.AreEqual(result[0].DestinationCityName, expected[0]);
            Assert.AreEqual(result[0].OriginCityName, expected[1]);
            for (int index = 0; index < result.Count; index++)
            {
                var resultItem = result[index];
                Assert.IsNotNull(resultItem);
            }
        }
示例#9
0
        public void RoutesRepository_GetSearchingDepth(string value, int expectedResult)
        {
            //arrange
            var setting = _datacontext.Settings.FirstOrDefault(e => e.SettingName == "SearchDepth");

            if (setting != null)
            {
                setting.SettingValue = value;
                _datacontext.SaveChanges();
            }

            var repository = new RoutesRepository(_datacontext);

            //act
            var result = repository.GetSearchingDepth();

            //assert
            Assert.AreEqual(result, expectedResult);
        }
示例#10
0
        public void RoutesRepository_GetRoutDetailsFeedbackFor_WronrgOriginCity(int оriginCityNodeID, int destinationCityNodeID, string lang)
        {
            // Arrange
            var repository = new RoutesRepository(_datacontext);
            var originCityNode = _datacontext.CityNodes.SingleOrDefault(m => m.CityNodeId == оriginCityNodeID);
            var destinationCityNode = _datacontext.CityNodes.SingleOrDefault(m => m.CityNodeId == destinationCityNodeID);
            var routeNode = new RouteNode { RouteNodeId = 1, OriginCityNodeId = 11, DestinationCityNodeId = 5, OriginCityNode = originCityNode, DestinationCityNode = destinationCityNode };
            //string lang = "en";

            //Act
            var result = repository.GetRoutDetailsFeedbackFor(routeNode, lang);
        }
示例#11
0
        public void RoadsManager_GetRouteEstimation_SendStringRoad_CheckCount(string road, int pointsCout)
        {
            //arrange
            var repository = new RoutesRepository(_datacontext);

            var manager = new RoadsManager(repository);

            //act
            var result = manager.GetRouteEstimation(road);

            //asserts
            Assert.AreEqual(result.CityPointsIds.Count(), pointsCout);
        }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SmartSuggestionsManager"/> class.
        /// </summary>
        public RoadsManager()
        {
            _routeRepository = new RoutesRepository();

            Initialize();
        }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SmartSuggestionsManager"/> class.
        /// </summary>
        /// <param name="repository">The repository.</param>
        public RoadsManager(RoutesRepository repository)
        {
            _routeRepository = repository;

            Initialize();
        }
示例#14
0
        /// <summary>
        /// Creates the feedback.
        /// </summary>
        /// <param name="feedbacksData">The feedbacks data.</param>
        public void CreateFeedback(RouteNodeWithFeedbacksData feedbacksData)
        {
            var feedbackItemRepository = new FeedbackItemRepository();
            var routeRepository = new RoutesRepository();

            RouteNode routeNode = routeRepository.GetRouteNode(
                feedbacksData.OriginCityNodeId, feedbacksData.DestinationCityNodeId);

            int feedbackId = feedbackItemRepository.AddNewFeedback(routeNode.RouteNodeId, feedbacksData.UserId,
                    feedbacksData.SubmitTime);

            feedbacksData.FeedbackValues.ForEach(feedbackValue => feedbackItemRepository.AddNewFeedbackValue(new FeedbackValueData()
            {
                FeedbackId = feedbackId,
                Value = feedbackValue.Value,
                FeedbackItemId = feedbackValue.FeedbackItemId
            }));
        }
示例#15
0
        /// <summary>
        /// Adds the new feedback and get URL to route.
        /// </summary>
        /// <param name="routesNodeWithFeedbacksData">The routes node with feedbacks data.</param>
        /// <returns>Return URL to route with new feedbacks</returns>
        public string AddNewFeedbackAndGetUrlToRoute(List<RouteNodeWithFeedbacksData> routesNodeWithFeedbacksData)
        {
            RoutesRepository routeRepository = new RoutesRepository();
            FeedbackItemRepository feedbackItemRepository = new FeedbackItemRepository();
            StringBuilder track = new StringBuilder(routesNodeWithFeedbacksData.Count * 5 + routesNodeWithFeedbacksData.Count - 1);

            bool backwardOrder = routesNodeWithFeedbacksData[0].OriginCityNodeId >
                     routesNodeWithFeedbacksData[routesNodeWithFeedbacksData
                     .Count - 1].DestinationCityNodeId;

            routesNodeWithFeedbacksData.ForEach(routeWithFeedback =>
            {
                RouteNode routeNode = routeRepository.GetRouteNode(
                routeWithFeedback.OriginCityNodeId, routeWithFeedback.DestinationCityNodeId) ??
                    new RouteNode()
                    {
                        RouteNodeId = routeRepository.CreateRouteNode(routeWithFeedback.OriginCityNodeId,
                            routeWithFeedback.DestinationCityNodeId)
                    };

                int feedbackId = feedbackItemRepository.AddNewFeedback(routeNode.RouteNodeId, routeWithFeedback.UserId,
                    routeWithFeedback.SubmitTime);

                routeWithFeedback.FeedbackValues.ForEach(feedbackValue => feedbackItemRepository.AddNewFeedbackValue(new FeedbackValueData()
                {
                    FeedbackId = feedbackId,
                    Value = feedbackValue.Value,
                    FeedbackItemId = feedbackValue.FeedbackItemId
                }));

                if (!backwardOrder)
                {
                    track.Append(routeWithFeedback.OriginCityNodeId).Append("-");
                    if (routeWithFeedback.Equals(routesNodeWithFeedbacksData.Last()))
                    {
                        track.Append(routeWithFeedback.DestinationCityNodeId);
                    }
                }
                else
                {
                    track.Insert(0, routeWithFeedback.OriginCityNodeId).Insert(0, "-");
                    if (routeWithFeedback.Equals(routesNodeWithFeedbacksData.Last()))
                    {
                        track.Insert(0, routeWithFeedback.DestinationCityNodeId);
                    }
                }
            });
            BuildRoutes(routesNodeWithFeedbacksData[0].OriginCityNodeId,
                routesNodeWithFeedbacksData[routesNodeWithFeedbacksData.Count - 1].DestinationCityNodeId);

            string hash = routeRepository.GetHashByTrack(track.ToString());
            return String.Format("{0}-{1}-To-{2}", hash,
                routesNodeWithFeedbacksData.First().OriginCityNode,
                routesNodeWithFeedbacksData.Last().DestinationCityNode)
                .Replace(" ", "-")
                .Replace(",", "");
        }
        public void RoadsManager_GetFindRouteDetailsModel_PositiveTests(string hash, string language, string[] expected)
        {
            var routesRepository = new RoutesRepository(_datacontext);
            var manager = new RoadsManager(routesRepository);

            Common.Models.DataContract.RouteDetailsData routeDetailsData = manager.GetRouteDetailsByHash(hash, language);

            Assert.IsNotNull(routeDetailsData);
            Assert.IsNotNull(routeDetailsData.RouteDetailsItems);
            Assert.AreEqual(routeDetailsData.RouteDetailsItems.Count, expected.Length-1);
            for (int index = 0; index < routeDetailsData.RouteDetailsItems.Count; index++)
            {
                var routeDetailsItem = routeDetailsData.RouteDetailsItems[index];

                Assert.IsNotNull(routeDetailsItem);
                foreach (var routeDetailsFeedback in routeDetailsItem)
                {
                    Assert.IsNotNull(routeDetailsFeedback);
                    Assert.AreEqual(routeDetailsFeedback.OriginCityName, expected[index]);
                    Assert.AreEqual(routeDetailsFeedback.DestinationCityName,
                        index == (expected.Length - 1) ? expected[expected.Length - 1] : expected[index + 1]);
                    Assert.IsNotNull(routeDetailsFeedback.DestinationCityId);
                    Assert.IsNotNull(routeDetailsFeedback.OriginCityId);
                    Assert.IsNotNull(routeDetailsFeedback.SubmitTime);
                    Assert.IsNotNull(routeDetailsFeedback.UserName);
                    Assert.IsNotNull(routeDetailsFeedback.FeedbackId);
                    Assert.IsNotNull(routeDetailsFeedback.FeedbackValues);
                    foreach (var feedbackValueData in routeDetailsFeedback.FeedbackValues)
                    {
                        Assert.IsNotNull(feedbackValueData);
                        Assert.IsNotNull(feedbackValueData.FeedbackId);
                        Assert.IsNotNull(feedbackValueData.FeedbackItem);
                        Assert.IsNotNull(feedbackValueData.FeedbackItemId);
                        Assert.IsNotNull(feedbackValueData.FeedbackValueId);
                        Assert.IsNotNull(feedbackValueData.Value);
                        Assert.IsNotNullOrEmpty(feedbackValueData.FeedbackItem.DescriptionTranslationKey);
                        Assert.IsNotNull(feedbackValueData.FeedbackItem.FeedbackItemId);
                        Assert.IsNotNull(feedbackValueData.FeedbackItem.FeedbackModelId);
                        Assert.IsNotNull(feedbackValueData.FeedbackItem.IsNumeric);
                        Assert.IsNotNull(feedbackValueData.FeedbackItem.Mandatory);
                        Assert.IsNotNullOrEmpty(feedbackValueData.FeedbackItem.NameTranslationKey);
                        Assert.IsNotNull(feedbackValueData.FeedbackItem.SortNumber);
                    }
                }
            }
        }