| 
									
										
										
										
											2013-08-26 12:35:53 -07:00
										 |  |  | using System; | 
					
						
							| 
									
										
										
										
											2013-04-21 20:18:08 -07:00
										 |  |  | using FluentAssertions; | 
					
						
							|  |  |  | using NUnit.Framework; | 
					
						
							|  |  |  | using NzbDrone.Api.RootFolders; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace NzbDrone.Integration.Test | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     [TestFixture] | 
					
						
							|  |  |  |     public class RootFolderIntegrationTest : IntegrationTest | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-11-13 12:08:37 -08:00
										 |  |  |         [Test] | 
					
						
							|  |  |  |         public void should_have_no_root_folder_initially() | 
					
						
							| 
									
										
										
										
											2013-08-18 15:19:55 -07:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2013-11-13 12:08:37 -08:00
										 |  |  |             RootFolders.All().Should().BeEmpty(); | 
					
						
							| 
									
										
										
										
											2013-08-18 15:19:55 -07:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-21 20:18:08 -07:00
										 |  |  |         [Test] | 
					
						
							| 
									
										
										
										
											2013-11-13 12:08:37 -08:00
										 |  |  |         public void should_add_and_delete_root_folders() | 
					
						
							| 
									
										
										
										
											2013-04-21 20:18:08 -07:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2013-11-13 12:08:37 -08:00
										 |  |  |             ConnectSignalR(); | 
					
						
							| 
									
										
										
										
											2013-04-21 20:18:08 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |             var rootFolder = new RootFolderResource | 
					
						
							| 
									
										
										
										
											2013-11-13 12:08:37 -08:00
										 |  |  |             { | 
					
						
							|  |  |  |                 Path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) | 
					
						
							|  |  |  |             }; | 
					
						
							| 
									
										
										
										
											2013-04-21 20:18:08 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |             var postResponse = RootFolders.Post(rootFolder); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             postResponse.Id.Should().NotBe(0); | 
					
						
							|  |  |  |             postResponse.FreeSpace.Should().NotBe(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             RootFolders.All().Should().OnlyContain(c => c.Id == postResponse.Id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-23 18:56:00 -07:00
										 |  |  |             RootFolders.Delete(postResponse.Id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             RootFolders.All().Should().BeEmpty(); | 
					
						
							| 
									
										
										
										
											2013-11-13 12:08:37 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             SignalRMessages.Should().Contain(c => c.Name == "rootfolder"); | 
					
						
							| 
									
										
										
										
											2013-04-23 18:56:00 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-08-31 13:31:58 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         [Test] | 
					
						
							|  |  |  |         public void invalid_path_should_return_bad_request() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var rootFolder = new RootFolderResource | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 Path = "invalid_path" | 
					
						
							|  |  |  |             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             var postResponse = RootFolders.InvalidPost(rootFolder); | 
					
						
							|  |  |  |             postResponse.Should().NotBeEmpty(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-04-21 20:18:08 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | } |