Пример #1
0
        public void PostTest_SuccessReturnsOK()
        {
            var RC = new ReviewsController(connection);

            var review = new PostReview();

            review.UserId       = 1;
            review.RestaurantId = 1;
            review.ReviewText   = "Please submit this review. the restaurant is great";

            var result = RC.Post(review);

            Assert.IsType <OkObjectResult>(result);
        }
Пример #2
0
        public void PostReview_ReviewIdCannotBeNegative()
        {
            //Arrange
            var sut = new PostReview
            {
                ReviewId = -1
            };

            //Act
            var testId = sut.IsValidId();

            //Assert
            Assert.False(testId, "should be false");
        }
Пример #3
0
        public void PostReview_ReviewsNeedAtLeastTwoWords()
        {
            //Arrange
            var sut = new PostReview
            {
                ReviewText = "Hello"
            };

            //Act
            var testText = sut.IsValidReviewText();

            //Assert
            Assert.False(testText, "should be false");
        }
Пример #4
0
        //TEST FUNCTION USED BY SADAT
        public ActionResult GetCompanyReview()
        {
            PostReview review = new PostReview()
            {
                companyName = "Google",
                review      = "Please work godDDDD",
                stars       = 5,
                timestamp   = "020202",
                username    = "******"
            };

            ViewBag.SADAT = PostReview(review);

            return(View());
        }
Пример #5
0
        public string PostReview(PostReview review)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://23.251.158.180/home/");
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            string              postBody = JsonConvert.SerializeObject(review);
            HttpContent         content  = new StringContent(postBody, Encoding.UTF8, "application/json");
            HttpResponseMessage response = client.PostAsync("SaveCompanyReview/", content).Result;

            // Read the response body as string
            string json = response.Content.ReadAsStringAsync().Result;

            return(json);

            // deserialize the JSON response returned from the Web API back to a login_info object
            //return JsonConvert.DeserializeObject<Review>(json);
        }
        public async Task <IActionResult> PostReview(Guid id, [FromBody] PostReview postReview)
        {
            await _reviewService.PostReviewAsync(GetCurrentUserId(), id, postReview.Rating, postReview.Content);

            return(Ok());
        }
Пример #7
0
        /// <summary>
        /// This method is called directly from the solution crawler and any solution/project file add/rename/remove events.
        /// It is also called via AddFilePathIfChanged(string filePath) when a file is saved outside of the context of a solution/project.
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="project"></param>
        /// <returns></returns>
        public void AddFilePathIfChanged(string filePathOs, string project, PostReview.ChangeType knownChangeType)
        {
            try
            {
                MyLog.DebugEnter(this, "AddFilePathIfChanged(\"" + filePathOs + "\", \"" + project + "\", " + knownChangeType + ")");

                if (String.IsNullOrEmpty(filePathOs))
                {
                    throw new ArgumentNullException(filePathOs, "filePath cannot be null/empty");
                }

                // Some SCCs are case sensitive; get the *exact* file case (or null if it does not exist)
                string filePathScc = MyUtils.GetCasedPath(filePathOs);
                if (String.IsNullOrEmpty(filePathScc))
                {
                    switch (knownChangeType)
                    {
                    case PostReview.ChangeType.Deleted:
                        // If knownChangeType == Deleted then trust that the casing is already correct.
                        filePathScc = filePathOs;
                        break;

                    case PostReview.ChangeType.Unknown:
                    case PostReview.ChangeType.Added:
                        // knownChangeType == Added during the Solution crawl and Solution/Project file adds.
                        // If we got this far then the VS *Solution/Project* says there is a file.
                        // But, the file can be an external/virtual/symbolic link/reference, not an actual file.
                        // If GetCasedFilePath returned null then this file does not exist.
                        // Ignore this situation and just continue the enumeration.
                        Debug.WriteLine("File \"" + filePathOs + "\" does not exist; ignoring.");
                        return;

                    default:
                        throw new FileNotFoundException("Could not get true cased filename needed for SCC.", filePathOs);
                    }
                }

                if (BackgroundInitialSolutionCrawl != null && BackgroundInitialSolutionCrawl.IsBusy)
                {
                    // Percent is currently always 0, since our progress is indeterminate
                    // TODO:(pv) Find some way to determine # of nodes in tree *before* processing
                    //      Maybe do a quick first pass w/ no post-review?
                    // NOTE:(pv) I did once have the debugger halt here complaining invalid state that the form is not active
                    BackgroundInitialSolutionCrawl.ReportProgress(0, filePathScc);
                }

                string diff;
                PostReview.ChangeType changeType = PostReview.DiffFile(BackgroundInitialSolutionCrawl, filePathScc, out diff);

                // If the change type is known by the caller, use it.
                // Otherwise, use the type determined by the PostReview.DiffFile(...)
                if (knownChangeType != PostReview.ChangeType.Unknown)
                {
                    changeType = knownChangeType;
                }

                filePathOs = filePathOs.ToLower();

                switch (changeType)
                {
                case PostReview.ChangeType.Added:
                case PostReview.ChangeType.Copied:
                case PostReview.ChangeType.Deleted:
                case PostReview.ChangeType.Modified:
                    PostReview.SubmitItem change = new PostReview.SubmitItem(filePathScc, project, changeType, diff);
                    lock (changes)
                    {
                        changes[filePathOs] = change;
                    }
                    break;

                case PostReview.ChangeType.External:
                case PostReview.ChangeType.Normal:
                case PostReview.ChangeType.Unknown:
                default:
                    // ignore
                    break;
                }

                if (changeType == PostReview.ChangeType.Deleted)
                {
                    // Stop tracking the file for changes.
                    fileTracker.Unsubscribe(filePathOs, true);
                }
                else
                {
                    // Track the file for *future* changes, even if there are no *current* changes.
                    // This is a no-op if the path is already being tracked.
                    fileTracker.Subscribe(filePathOs, true);
                }

                // Map the file path to the project so that future file changes can find out what project the file is in given just the file path.
                // This will overwrite any existing value...which seems fine for now.
                mapItemProjectNames[filePathOs] = project;
            }
            finally
            {
                MyLog.DebugLeave(this, "AddFilePathIfChanged(\"" + filePathOs + "\", \"" + project + "\", " + knownChangeType + ")");
            }
        }