public void Initialize()
        {
            var restaurants = new List <Restaurant>()
            {
                new Restaurant(Guid.NewGuid(), "Grille 565",
                               new Address("565 Lincoln Ave", "15202", "Pittsburgh", "PA", "United States")),
                new Restaurant(Guid.NewGuid(), "202 Hometown Tacos",
                               new Address("202 Lincoln Ave", "15202", "Pittsburgh", "PA", "United States")),
                new Restaurant(Guid.NewGuid(), "Bryan's Speakeasy",
                               new Address("205 N Sprague Ave", "15202", "Pittsburgh", "PA", "United States")),
                new Restaurant(Guid.NewGuid(), "Katz's Delicatessen",
                               new Address("205 E Houston St", "10002", "New York", "NY", "United States"))
            };

            var users = new List <User>()
            {
                new User(Guid.NewGuid(), "John Doe",
                         new Address("123 Main", "15202", "Pittsburgh", "PA", "United States")),
                new User(Guid.NewGuid(), "Jane Doe",
                         new Address("123 Main", "15202", "Pittsburgh", "PA", "United States"))
            };

            var reviews = new List <Review>()
            {
                new Review(Guid.NewGuid(), users[0].Id, restaurants[0].Id, 4, 4, 4, 3, "Cozy!"),
                new Review(Guid.NewGuid(), users[1].Id, restaurants[1].Id, 3, 3, 3, 3, "meh")
            };

            _restaurantStore = new TestDataStore <Restaurant>(restaurants);
            _reviewDataStore = new TestDataStore <Review>(reviews);
            _userDataStore   = new TestDataStore <User>(users);
            _reviewApi       = new ReviewApi(_restaurantStore, _reviewDataStore, _userDataStore);
        }
Exemplo n.º 2
0
        public static void Run()
        {
            var apiInstance = new ReviewApi(Constants.GetConfig());

            try
            {
                var options = new ApplyRevisionsOptions
                {
                    SourceFile = new FileInfo {
                        FilePath = "source_files/word/source_with_revs.docx"
                    },
                    OutputPath = "output/result.docx"
                };

                var revisions = apiInstance.GetRevisions(new GetRevisionsRequest(options.SourceFile));

                foreach (var revision in revisions)
                {
                    revision.Action = RevisionInfo.ActionEnum.Accept;
                }

                options.Revisions = revisions;

                var response = apiInstance.ApplyRevisions(new ApplyRevisionsRequest(options));

                Console.WriteLine("ApplyRevisions: Output file link: " + response.Href);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
Exemplo n.º 3
0
        public async Task GetDetailsAsync_WithUserApiKey_ExistingId_ReturnsReview(string reviewId)
        {
            string userApiKey = GetApiKey();

            IReviewApi apiUnderTest = new ReviewApi(_clientWithNoApiKey);

            Review result = await apiUnderTest.GetReviewDetailsAsync(reviewId, userApiKey);

            Assert.IsNotNull(result);
            Assert.AreEqual(reviewId, result.Id);
        }
Exemplo n.º 4
0
        public void RejectAllRevisions()
        {
            var options = new ApplyRevisionsOptions
            {
                SourceFile = TestFiles.SourceWithRevs.ToFileInfo(),
                RejectAll  = true,
                OutputPath = "/resultFilePath/" + TestFiles.SourceWithRevs.FileName,
            };
            var response = ReviewApi.ApplyRevisions(new ApplyRevisionsRequest(options));

            Assert.AreEqual(response.Rel, options.OutputPath);
        }
Exemplo n.º 5
0
        public async Task GetDetailsAsync_WithSharedApiKey_ExistingId_ReturnsReview(string reviewId)
        {
            string sharedApiKey = GetApiKey();

            ITmdbEasyClient client = GetTestClient(sharedApiKey);

            IReviewApi apiUnderTest = new ReviewApi(client);

            Review result = await apiUnderTest.GetReviewDetailsAsync(reviewId);

            Assert.IsNotNull(result);
            Assert.AreEqual(reviewId, result.Id);
        }
Exemplo n.º 6
0
        public void BeforeAllTests()
        {
            var config = new Configuration(_appSid, _appKey)
            {
                ApiBaseUrl = _apiBaseUrl
            };

            CompareApi = new CompareApi(config);
            ReviewApi  = new ReviewApi(config);
            InfoApi    = new InfoApi(config);
            FileApi    = new FileApi(config);
            FolderApi  = new FolderApi(config);
            StorageApi = new StorageApi(config);

            UploadTestFiles();
        }
Exemplo n.º 7
0
        public static IFeature Create(ICommandParser commandParser, IWebClient webClient,
                                      Configuration configuration)
        {
            var githubApi = new GithubDiffApi(webClient, configuration.Get("github-token"));
            var reviewApi = new ReviewApi(githubApi,
                                          new Func <IDiffReviewer>[] {
                () => new DontAddTabCharacters(),
                () => new UseWindowsNewlines(),
                () => new GeneralBadThing("todo", "TODO found", RegexOptions.IgnoreCase),
                () => new GeneralBadThing("NotImplementedException", "NotImplementedException found"),
                () => new GeneralBadThing("NotSupportedException", "NotSupportedException found"),
                () => new GeneralBadThing(@"<SpecificVersion>\s*[fF]alse\s*</SpecificVersion>", "SpecificVersion=False found"),
                () => new AvoidAppConfig(),
            });
            var processor = new GithubReviewMessageProcessor(commandParser, reviewApi, configuration.Get("github-default-user"), configuration.Get("github-default-repo"));

            return(new BasicFeature("githubreview",
                                    "[experimental] run some automated checks against github pull requests", "- `review fooRepo#123` review a pull request\n- `review fooRepo@bug/SC-1234` review a branch (against master)\n- `review fooCorp/fooRepo@abc123` review a specific commit",
                                    processor));
        }
Exemplo n.º 8
0
        public void ApplyRevisions()
        {
            var options = new ApplyRevisionsOptions
            {
                SourceFile = TestFiles.SourceWithRevs.ToFileInfo(),
                Revisions  = new[]
                {
                    new RevisionInfo {
                        Id = 0, Action = RevisionInfo.ActionEnum.Accept
                    },
                    new RevisionInfo {
                        Id = 1, Action = RevisionInfo.ActionEnum.Reject
                    }
                }.ToList(),
                OutputPath = "/resultFilePath/" + TestFiles.SourceWithRevs.FileName,
            };
            var response = ReviewApi.ApplyRevisions(new ApplyRevisionsRequest(options));

            Assert.AreEqual(response.Rel, options.OutputPath);
        }
Exemplo n.º 9
0
        public static void Run()
        {
            var apiInstance = new ReviewApi(Constants.GetConfig());

            try
            {
                var sourceFile = new FileInfo
                {
                    FilePath = "source_files/word/source_with_revs.docx"
                };

                var request = new GetRevisionsRequest(sourceFile);

                var revisions = apiInstance.GetRevisions(request);
                Console.WriteLine("GetListOfRevisions: Revisions count: " + revisions.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
        public static void Run()
        {
            var apiInstance = new ReviewApi(Constants.GetConfig());

            try
            {
                var options = new ApplyRevisionsOptions
                {
                    SourceFile = new FileInfo {
                        FilePath = "source_files/word/source_with_revs.docx"
                    },
                    RejectAll  = true,
                    OutputPath = "output/result.docx"
                };

                var response = apiInstance.ApplyRevisions(new ApplyRevisionsRequest(options));

                Console.WriteLine("RejectAllRevisions: Output file link: " + response.Href);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
Exemplo n.º 11
0
        public void GetRevisions()
        {
            var response = ReviewApi.GetRevisions(new GetRevisionsRequest(TestFiles.SourceWithRevs.ToFileInfo()));

            Assert.AreEqual(2, response.Count);
        }