private static string GetOldFileName(FileChange f)
 {
     FileModification mod = f as FileModification;
     if (mod != null)
     {
         return mod.NewFileName;
     }
     else
     {
         return null;
     }
 }
Esempio n. 2
0
            public void CreatesReviewWithCurrentUserAsOwnerFromDiff()
            {
                // Arrange
                var userId = 42;
                var ctl = CreateController();
                var model = new NewReviewViewModel() { Name = "123", Diff = new TestPostedFile("Test") };
                var changes = new FileChange[] { new FileAddition(), new FileDeletion(), new FileModification() };
                ctl.MockDiff
                   .Setup(s => s.CreateFromGitDiff(It.Is<StreamReader>(r => ReferenceEquals(r.BaseStream, model.Diff.InputStream))))
                   .Returns(changes);
                ctl.MockAuth
                   .Setup(s => s.GetCurrentUserId())
                   .Returns(userId);

                // Act
                var result = ctl.New(model);

                // Assert
                ActionAssert.IsRedirectResult(result, new { controller = "Reviews", action = "View", id = ctl.TestData.LastId });
                Assert.Contains(new Review() {
                    Id = ctl.TestData.LastId,
                    UserId = 42,
                    Name = "123",
                    Files = changes.ToList()
                }, ctl.Reviews.Data.Reviews, new PropertyEqualityComparer());
            }
 private static string GetFolderName(FileChange arg)
 {
     int lastSlash = arg.FileName.LastIndexOf('/');
     return lastSlash > 0 ? arg.FileName.Substring(0, lastSlash) : "/";
 }