You've already forked Sonarr
							
							
				mirror of
				https://github.com/Sonarr/Sonarr.git
				synced 2025-10-31 00:07:55 +02:00 
			
		
		
		
	fixed disk scan scheduler.
This commit is contained in:
		| @@ -25,7 +25,7 @@ namespace NzbDrone.Api.Commands | ||||
|             var commandType = | ||||
|                 _container.GetImplementations(typeof(ICommand)) | ||||
|                           .Single(c => c.Name.Replace("Command", "") | ||||
|                                .Equals(resource.Command, StringComparison.InvariantCultureIgnoreCase)); | ||||
|                           .Equals(resource.Command, StringComparison.InvariantCultureIgnoreCase)); | ||||
|  | ||||
|  | ||||
|             var command = Request.Body.FromJson<ICommand>(commandType); | ||||
|   | ||||
| @@ -8,14 +8,6 @@ namespace NzbDrone.Api.Extensions | ||||
| { | ||||
|     public class NancyJsonSerializer : ISerializer | ||||
|     { | ||||
|         private readonly IJsonSerializer _jsonSerializer; | ||||
|  | ||||
|         public NancyJsonSerializer(IJsonSerializer jsonSerializer) | ||||
|         { | ||||
|             _jsonSerializer = jsonSerializer; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public bool CanSerialize(string contentType) | ||||
|         { | ||||
|             return true; | ||||
| @@ -23,7 +15,7 @@ namespace NzbDrone.Api.Extensions | ||||
|  | ||||
|         public void Serialize<TModel>(string contentType, TModel model, Stream outputStream) | ||||
|         { | ||||
|             _jsonSerializer.Serialize(model, outputStream); | ||||
|             Json.Serialize(model, outputStream); | ||||
|         } | ||||
|  | ||||
|         public IEnumerable<string> Extensions { get; private set; } | ||||
|   | ||||
| @@ -2,15 +2,13 @@ | ||||
| using System.IO; | ||||
| using Nancy; | ||||
| using Nancy.Responses; | ||||
| using NzbDrone.Common; | ||||
| using NzbDrone.Common.Serializer; | ||||
|  | ||||
| namespace NzbDrone.Api.Extensions | ||||
| { | ||||
|     public static class JsonExtensions | ||||
|     { | ||||
|         private static readonly JsonSerializer Serializer = new JsonSerializer(); | ||||
|         private static readonly NancyJsonSerializer NancySerializer = new NancyJsonSerializer(Serializer); | ||||
|         private static readonly NancyJsonSerializer NancySerializer = new NancyJsonSerializer(); | ||||
|  | ||||
|         public static T FromJson<T>(this Stream body) where T : class, new() | ||||
|         { | ||||
| @@ -22,7 +20,7 @@ namespace NzbDrone.Api.Extensions | ||||
|             var reader = new StreamReader(body, true); | ||||
|             body.Position = 0; | ||||
|             var value = reader.ReadToEnd(); | ||||
|             return (T)Serializer.Deserialize(value, type); | ||||
|             return (T)Json.Deserialize(value, type); | ||||
|         } | ||||
|  | ||||
|         public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK) | ||||
|   | ||||
| @@ -2,27 +2,20 @@ | ||||
| using System.IO; | ||||
| using Microsoft.AspNet.SignalR.Json; | ||||
| using NzbDrone.Common.Composition; | ||||
| using NzbDrone.Common.Serializer; | ||||
|  | ||||
| namespace NzbDrone.Api.SignalR | ||||
| { | ||||
|     [Singleton] | ||||
|     public class Serializer : IJsonSerializer | ||||
|     { | ||||
|         private readonly Common.Serializer.IJsonSerializer _nzbDroneSerializer; | ||||
|         private readonly JsonNetSerializer _signalRSerializer; | ||||
|  | ||||
|         public Serializer(Common.Serializer.IJsonSerializer nzbDroneSerializer) | ||||
|         { | ||||
|             _signalRSerializer = new JsonNetSerializer(); | ||||
|             _nzbDroneSerializer = nzbDroneSerializer; | ||||
|  | ||||
|         } | ||||
|         private readonly JsonNetSerializer _signalRSerializer = new JsonNetSerializer(); | ||||
|  | ||||
|         public void Serialize(object value, TextWriter writer) | ||||
|         { | ||||
|             if (value.GetType().FullName.StartsWith("NzbDrone")) | ||||
|             { | ||||
|                 _nzbDroneSerializer.Serialize(value, writer); | ||||
|                 Json.Serialize(value, writer); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
| @@ -35,7 +28,7 @@ namespace NzbDrone.Api.SignalR | ||||
|         { | ||||
|             if (targetType.FullName.StartsWith("NzbDrone")) | ||||
|             { | ||||
|                 return _nzbDroneSerializer.Deserialize(json, targetType); | ||||
|                 return Json.Deserialize(json, targetType); | ||||
|             } | ||||
|  | ||||
|             return _signalRSerializer.Parse(json, targetType); | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using Moq; | ||||
| using NUnit.Framework; | ||||
| using NzbDrone.Common.Messaging; | ||||
| @@ -38,6 +39,17 @@ namespace NzbDrone.Common.Test.EventingTests | ||||
|             _executorA.Verify(c => c.Execute(commandA), Times.Once()); | ||||
|         } | ||||
|  | ||||
|         [Test] | ||||
|         public void should_publish_command_by_with_optional_arg_with_name() | ||||
|         { | ||||
|             Mocker.GetMock<IServiceFactory>().Setup(c => c.GetImplementations(typeof(ICommand))) | ||||
|                   .Returns(new List<Type> { typeof(CommandA), typeof(CommandB) }); | ||||
|  | ||||
|             Subject.PublishCommand(typeof(CommandA).FullName); | ||||
|             _executorA.Verify(c => c.Execute(It.IsAny<CommandA>()), Times.Once()); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         [Test] | ||||
|         public void should_not_publish_to_incompatible_executor() | ||||
|         { | ||||
| @@ -64,7 +76,10 @@ namespace NzbDrone.Common.Test.EventingTests | ||||
|  | ||||
|     public class CommandA : ICommand | ||||
|     { | ||||
|         public CommandA(int id = 0) | ||||
|         { | ||||
|  | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public class CommandB : ICommand | ||||
|   | ||||
| @@ -5,7 +5,8 @@ | ||||
|     /// </summary> | ||||
|     public interface IMessageAggregator | ||||
|     { | ||||
|         void PublishEvent<TEvent>(TEvent @event) where TEvent : IEvent; | ||||
|         void PublishCommand<TCommand>(TCommand command) where TCommand : ICommand; | ||||
|         void PublishEvent<TEvent>(TEvent @event) where TEvent : class,  IEvent; | ||||
|         void PublishCommand<TCommand>(TCommand command) where TCommand : class, ICommand; | ||||
|         void PublishCommand(string commandType); | ||||
|     } | ||||
| } | ||||
| @@ -1,8 +1,11 @@ | ||||
| using System; | ||||
| using System.Linq; | ||||
| using System.Reflection; | ||||
| using System.Threading.Tasks; | ||||
| using NLog; | ||||
| using NzbDrone.Common.Composition; | ||||
| using NzbDrone.Common.EnsureThat; | ||||
| using NzbDrone.Common.Serializer; | ||||
|  | ||||
| namespace NzbDrone.Common.Messaging | ||||
| { | ||||
| @@ -18,8 +21,10 @@ namespace NzbDrone.Common.Messaging | ||||
|             _serviceFactory = serviceFactory; | ||||
|         } | ||||
|  | ||||
|         public void PublishEvent<TEvent>(TEvent @event) where TEvent : IEvent | ||||
|         public void PublishEvent<TEvent>(TEvent @event) where TEvent : class ,IEvent | ||||
|         { | ||||
|             Ensure.That(() => @event).IsNotNull(); | ||||
|  | ||||
|             var eventName = GetEventName(@event.GetType()); | ||||
|  | ||||
|             _logger.Trace("Publishing {0}", eventName); | ||||
| @@ -63,8 +68,10 @@ namespace NzbDrone.Common.Messaging | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public void PublishCommand<TCommand>(TCommand command) where TCommand : ICommand | ||||
|         public void PublishCommand<TCommand>(TCommand command) where TCommand : class, ICommand | ||||
|         { | ||||
|             Ensure.That(() => command).IsNotNull(); | ||||
|  | ||||
|             var handlerContract = typeof(IExecute<>).MakeGenericType(command.GetType()); | ||||
|  | ||||
|             _logger.Trace("Publishing {0}", command.GetType().Name); | ||||
| @@ -75,7 +82,7 @@ namespace NzbDrone.Common.Messaging | ||||
|  | ||||
|             try | ||||
|             { | ||||
|                 handlerContract.GetMethod("Execute").Invoke(handler, new object[] {command}); | ||||
|                 handlerContract.GetMethod("Execute").Invoke(handler, new object[] { command }); | ||||
|                 PublishEvent(new CommandCompletedEvent(command)); | ||||
|             } | ||||
|             catch (TargetInvocationException e) | ||||
| @@ -95,5 +102,15 @@ namespace NzbDrone.Common.Messaging | ||||
|  | ||||
|             _logger.Debug("{0} <- {1}", command.GetType().Name, handler.GetType().Name); | ||||
|         } | ||||
|  | ||||
|         public void PublishCommand(string commandTypeName) | ||||
|         { | ||||
|             var commandType = _serviceFactory.GetImplementations(typeof(ICommand)) | ||||
|                 .Single(c => c.FullName.Equals(commandTypeName, StringComparison.InvariantCultureIgnoreCase)); | ||||
|  | ||||
|             //json.net is better at creating objects | ||||
|             var command = Json.Deserialize("{}", commandType); | ||||
|             PublishCommand((ICommand)command); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -103,7 +103,7 @@ | ||||
|     <Compile Include="EnsureThat\Resources\ExceptionMessages.Designer.cs" /> | ||||
|     <Compile Include="EnsureThat\StringExtensions.cs" /> | ||||
|     <Compile Include="EnsureThat\TypeParam.cs" /> | ||||
|     <Compile Include="Serializer\JsonSerializer.cs" /> | ||||
|     <Compile Include="Serializer\Json.cs" /> | ||||
|     <Compile Include="Messaging\CommandCompletedEvent.cs" /> | ||||
|     <Compile Include="Messaging\CommandStartedEvent.cs" /> | ||||
|     <Compile Include="Messaging\CommandFailedEvent.cs" /> | ||||
|   | ||||
							
								
								
									
										58
									
								
								NzbDrone.Common/Serializer/Json.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								NzbDrone.Common/Serializer/Json.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| using System; | ||||
| using System.IO; | ||||
| using Newtonsoft.Json; | ||||
| using Newtonsoft.Json.Converters; | ||||
| using Newtonsoft.Json.Serialization; | ||||
|  | ||||
| namespace NzbDrone.Common.Serializer | ||||
| { | ||||
|     public static class Json | ||||
|     { | ||||
|         private static readonly JsonSerializer JsonNetSerializer; | ||||
|  | ||||
|  | ||||
|         static Json() | ||||
|         { | ||||
|             JsonNetSerializer = new JsonSerializer() | ||||
|                 { | ||||
|                     DateTimeZoneHandling = DateTimeZoneHandling.Utc, | ||||
|                     NullValueHandling = NullValueHandling.Ignore, | ||||
|                     Formatting = Formatting.Indented, | ||||
|                     DefaultValueHandling = DefaultValueHandling.Include, | ||||
|                     ContractResolver = new CamelCasePropertyNamesContractResolver() | ||||
|                 }; | ||||
|  | ||||
|             JsonNetSerializer.Converters.Add(new StringEnumConverter { CamelCaseText = true }); | ||||
|         } | ||||
|  | ||||
|         public static T Deserialize<T>(string json) where T : class, new() | ||||
|         { | ||||
|             return JsonConvert.DeserializeObject<T>(json); | ||||
|         } | ||||
|  | ||||
|         public static object Deserialize(string json, Type type) | ||||
|         { | ||||
|             return JsonConvert.DeserializeObject(json, type); | ||||
|         } | ||||
|  | ||||
|         public static string Serialize(object obj) | ||||
|         { | ||||
|             return JsonConvert.SerializeObject(obj); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public static void Serialize<TModel>(TModel model, TextWriter outputStream) | ||||
|         { | ||||
|             var jsonTextWriter = new JsonTextWriter(outputStream); | ||||
|             JsonNetSerializer.Serialize(jsonTextWriter, model); | ||||
|             jsonTextWriter.Flush(); | ||||
|         } | ||||
|  | ||||
|         public static void Serialize<TModel>(TModel model, Stream outputStream) | ||||
|         { | ||||
|             Serialize(model, new StreamWriter(outputStream)); | ||||
|         } | ||||
|  | ||||
|  | ||||
|     } | ||||
| } | ||||
| @@ -1,66 +0,0 @@ | ||||
| using System; | ||||
| using System.IO; | ||||
| using Newtonsoft.Json; | ||||
| using Newtonsoft.Json.Converters; | ||||
| using Newtonsoft.Json.Serialization; | ||||
|  | ||||
| namespace NzbDrone.Common.Serializer | ||||
| { | ||||
|     public interface IJsonSerializer | ||||
|     { | ||||
|         T Deserialize<T>(string json) where T : class, new(); | ||||
|         string Serialize(object obj); | ||||
|         void Serialize<TModel>(TModel model, TextWriter textWriter); | ||||
|         void Serialize<TModel>(TModel model, Stream outputStream); | ||||
|         object Deserialize(string json, Type type); | ||||
|     } | ||||
|  | ||||
|     public class JsonSerializer : IJsonSerializer | ||||
|     { | ||||
|         private readonly Newtonsoft.Json.JsonSerializer _jsonNetSerializer; | ||||
|  | ||||
|         public JsonSerializer() | ||||
|         { | ||||
|             _jsonNetSerializer = new Newtonsoft.Json.JsonSerializer() | ||||
|                 { | ||||
|                     DateTimeZoneHandling = DateTimeZoneHandling.Utc, | ||||
|                     NullValueHandling = NullValueHandling.Ignore, | ||||
|                     Formatting = Formatting.Indented, | ||||
|                     DefaultValueHandling = DefaultValueHandling.Include, | ||||
|                     ContractResolver = new CamelCasePropertyNamesContractResolver() | ||||
|                 }; | ||||
|  | ||||
|             _jsonNetSerializer.Converters.Add(new StringEnumConverter { CamelCaseText = true }); | ||||
|         } | ||||
|  | ||||
|         public T Deserialize<T>(string json) where T : class, new() | ||||
|         { | ||||
|             return JsonConvert.DeserializeObject<T>(json); | ||||
|         } | ||||
|  | ||||
|         public object Deserialize(string json, Type type) | ||||
|         { | ||||
|             return JsonConvert.DeserializeObject(json, type); | ||||
|         } | ||||
|  | ||||
|         public string Serialize(object obj) | ||||
|         { | ||||
|             return JsonConvert.SerializeObject(obj); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public void Serialize<TModel>(TModel model, TextWriter outputStream) | ||||
|         { | ||||
|             var jsonTextWriter = new JsonTextWriter(outputStream); | ||||
|             _jsonNetSerializer.Serialize(jsonTextWriter, model); | ||||
|             jsonTextWriter.Flush(); | ||||
|         } | ||||
|  | ||||
|         public void Serialize<TModel>(TModel model, Stream outputStream) | ||||
|         { | ||||
|             Serialize(model, new StreamWriter(outputStream)); | ||||
|         } | ||||
|  | ||||
|  | ||||
|     } | ||||
| } | ||||
| @@ -10,6 +10,7 @@ namespace NzbDrone.Common | ||||
|         T Build<T>() where T : class; | ||||
|         IEnumerable<T> BuildAll<T>() where T : class; | ||||
|         object Build(Type contract); | ||||
|         IEnumerable<Type> GetImplementations(Type contract); | ||||
|     } | ||||
|  | ||||
|     public class ServiceFactory : IServiceFactory | ||||
| @@ -35,5 +36,10 @@ namespace NzbDrone.Common | ||||
|         { | ||||
|             return _container.Resolve(contract); | ||||
|         } | ||||
|  | ||||
|         public IEnumerable<Type> GetImplementations(Type contract) | ||||
|         { | ||||
|             return _container.GetImplementations(contract); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -41,8 +41,8 @@ namespace NzbDrone.Core.Test.Datastore | ||||
|         [SetUp] | ||||
|         public void Setup() | ||||
|         { | ||||
|             MapRepository.Instance.RegisterTypeConverter(typeof(List<EmbeddedType>), new EmbeddedDocumentConverter(new JsonSerializer())); | ||||
|             MapRepository.Instance.RegisterTypeConverter(typeof(EmbeddedType), new EmbeddedDocumentConverter(new JsonSerializer())); | ||||
|             MapRepository.Instance.RegisterTypeConverter(typeof(List<EmbeddedType>), new EmbeddedDocumentConverter()); | ||||
|             MapRepository.Instance.RegisterTypeConverter(typeof(EmbeddedType), new EmbeddedDocumentConverter()); | ||||
|             MapRepository.Instance.RegisterTypeConverter(typeof(Int32), new Int32Converter()); | ||||
|              | ||||
|         } | ||||
|   | ||||
| @@ -17,14 +17,12 @@ namespace NzbDrone.Core.DataAugmentation.DailySeries | ||||
|     { | ||||
|         private readonly IHttpProvider _httpProvider; | ||||
|         private readonly IConfigService _configService; | ||||
|         private readonly IJsonSerializer _jsonSerializer; | ||||
|         private readonly Logger _logger; | ||||
|  | ||||
|         public DailySeriesDataProxy(IHttpProvider httpProvider, IConfigService configService, IJsonSerializer jsonSerializer, Logger logger) | ||||
|         public DailySeriesDataProxy(IHttpProvider httpProvider, IConfigService configService, Logger logger) | ||||
|         { | ||||
|             _httpProvider = httpProvider; | ||||
|             _configService = configService; | ||||
|             _jsonSerializer = jsonSerializer; | ||||
|             _logger = logger; | ||||
|         } | ||||
|  | ||||
| @@ -34,7 +32,7 @@ namespace NzbDrone.Core.DataAugmentation.DailySeries | ||||
|             { | ||||
|                 var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds"); | ||||
|  | ||||
|                 var seriesIds = _jsonSerializer.Deserialize<List<int>>(dailySeriesIds); | ||||
|                 var seriesIds = Json.Deserialize<List<int>>(dailySeriesIds); | ||||
|  | ||||
|                 return seriesIds; | ||||
|             } | ||||
|   | ||||
| @@ -14,19 +14,19 @@ namespace NzbDrone.Core.DataAugmentation.Scene | ||||
|     { | ||||
|         private readonly IHttpProvider _httpProvider; | ||||
|         private readonly IConfigService _configService; | ||||
|         private readonly IJsonSerializer _jsonSerializer; | ||||
|          | ||||
|  | ||||
|         public SceneMappingProxy(IHttpProvider httpProvider, IConfigService configService, IJsonSerializer jsonSerializer) | ||||
|         public SceneMappingProxy(IHttpProvider httpProvider, IConfigService configService) | ||||
|         { | ||||
|             _httpProvider = httpProvider; | ||||
|             _configService = configService; | ||||
|             _jsonSerializer = jsonSerializer; | ||||
|              | ||||
|         } | ||||
|  | ||||
|         public List<SceneMapping> Fetch() | ||||
|         { | ||||
|             var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active"); | ||||
|             return _jsonSerializer.Deserialize<List<SceneMapping>>(mappingsJson); | ||||
|             return Json.Deserialize<List<SceneMapping>>(mappingsJson); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -8,12 +8,6 @@ namespace NzbDrone.Core.Datastore.Converters | ||||
| { | ||||
|     public class EmbeddedDocumentConverter : IConverter | ||||
|     { | ||||
|         private readonly IJsonSerializer _serializer; | ||||
|  | ||||
|         public EmbeddedDocumentConverter(IJsonSerializer serializer) | ||||
|         { | ||||
|             _serializer = serializer; | ||||
|         } | ||||
|  | ||||
|         public object FromDB(ColumnMap map, object dbValue) | ||||
|         { | ||||
| @@ -29,14 +23,14 @@ namespace NzbDrone.Core.Datastore.Converters | ||||
|                 return null; | ||||
|             } | ||||
|  | ||||
|             return  _serializer.Deserialize(stringValue, map.FieldType); | ||||
|             return  Json.Deserialize(stringValue, map.FieldType); | ||||
|         } | ||||
|  | ||||
|         public object ToDB(object clrValue) | ||||
|         { | ||||
|             if (clrValue == null) return null; | ||||
|  | ||||
|             var json = _serializer.Serialize(clrValue); | ||||
|             var json = Json.Serialize(clrValue); | ||||
|             return json; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Datastore | ||||
|                                                           .Where(c => c.GetInterfaces().Any(i => i == typeof(IEmbeddedDocument))); | ||||
|  | ||||
|  | ||||
|             var embeddedConvertor = new EmbeddedDocumentConverter(new JsonSerializer()); | ||||
|             var embeddedConvertor = new EmbeddedDocumentConverter(); | ||||
|             var genericListDefinition = typeof(List<>).GetGenericTypeDefinition(); | ||||
|             foreach (var embeddedType in embeddedTypes) | ||||
|             { | ||||
|   | ||||
| @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Indexers | ||||
|  | ||||
|         public TSetting ImportSettingsFromJson(string json) | ||||
|         { | ||||
|             Settings = new JsonSerializer().Deserialize<TSetting>(json) ?? new TSetting(); | ||||
|             Settings = Json.Deserialize<TSetting>(json) ?? new TSetting(); | ||||
|  | ||||
|             return Settings; | ||||
|         } | ||||
|   | ||||
| @@ -8,12 +8,6 @@ namespace NzbDrone.Core.Indexers.Newznab | ||||
| { | ||||
|     public class Newznab : IndexerWithSetting<NewznabSettings> | ||||
|     { | ||||
|         private readonly IJsonSerializer _jsonSerializer; | ||||
|  | ||||
|         public Newznab() | ||||
|         { | ||||
|             _jsonSerializer = new JsonSerializer(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public override IEnumerable<IndexerDefinition> DefaultDefinitions | ||||
| @@ -54,7 +48,7 @@ namespace NzbDrone.Core.Indexers.Newznab | ||||
|  | ||||
|         private string GetSettings(string url) | ||||
|         { | ||||
|             return _jsonSerializer.Serialize(new NewznabSettings { Url = url }); | ||||
|             return Json.Serialize(new NewznabSettings { Url = url }); | ||||
|         } | ||||
|  | ||||
|         public override IEnumerable<string> RecentFeed | ||||
|   | ||||
| @@ -5,6 +5,7 @@ using NLog; | ||||
| using NzbDrone.Common.Messaging; | ||||
| using NzbDrone.Core.Indexers; | ||||
| using NzbDrone.Core.Lifecycle; | ||||
| using NzbDrone.Core.MediaFiles.Commands; | ||||
| using NzbDrone.Core.Providers; | ||||
|  | ||||
| namespace NzbDrone.Core.Jobs | ||||
| @@ -36,7 +37,8 @@ namespace NzbDrone.Core.Jobs | ||||
|             var defaultTasks = new[] | ||||
|                 { | ||||
|                     new ScheduledTask{ Interval = 25, TypeName = typeof(RssSyncCommand).FullName}, | ||||
|                     new ScheduledTask{ Interval = 24*60, TypeName = typeof(UpdateXemMappings).FullName} | ||||
|                     new ScheduledTask{ Interval = 12*60, TypeName = typeof(UpdateXemMappings).FullName}, | ||||
|                     new ScheduledTask{ Interval = 6*60, TypeName = typeof(DiskScanCommand).FullName} | ||||
|                 }; | ||||
|  | ||||
|             var currentTasks = _scheduledTaskRepository.All(); | ||||
|   | ||||
| @@ -15,7 +15,6 @@ namespace NzbDrone.Integration.Test.Client | ||||
|         private readonly string _resource; | ||||
|  | ||||
|         private readonly Logger _logger; | ||||
|         private readonly JsonSerializer _jsonSerializer; | ||||
|  | ||||
|         public ClientBase(IRestClient restClient, string resource = null) | ||||
|         { | ||||
| @@ -27,10 +26,6 @@ namespace NzbDrone.Integration.Test.Client | ||||
|             _restClient = restClient; | ||||
|             _resource = resource; | ||||
|  | ||||
|             _jsonSerializer = new JsonSerializer(); | ||||
|  | ||||
|  | ||||
|  | ||||
|             _logger = LogManager.GetLogger("REST"); | ||||
|         } | ||||
|  | ||||
| @@ -109,7 +104,7 @@ namespace NzbDrone.Integration.Test.Client | ||||
|  | ||||
|             response.ErrorMessage.Should().BeBlank(); | ||||
|  | ||||
|             return _jsonSerializer.Deserialize<T>(response.Content); | ||||
|             return Json.Deserialize<T>(response.Content); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|   | ||||
| @@ -1,12 +1,11 @@ | ||||
| using NUnit.Framework; | ||||
| using NzbDrone.Common; | ||||
| using NUnit.Framework; | ||||
| using NzbDrone.Common.Serializer; | ||||
| using NzbDrone.Test.Common; | ||||
| 
 | ||||
| namespace NzbDrone.Libraries.Test.Json | ||||
| namespace NzbDrone.Libraries.Test.JsonTests | ||||
| { | ||||
|     [TestFixture] | ||||
|     public class JsonFixture : TestBase<JsonSerializer> | ||||
|     public class JsonFixture : TestBase | ||||
|     { | ||||
|         public class TypeWithNumbers | ||||
|         { | ||||
| @@ -18,9 +17,9 @@ namespace NzbDrone.Libraries.Test.Json | ||||
|         { | ||||
|             var quality = new TypeWithNumbers { Id = 12 }; | ||||
| 
 | ||||
|             var json = Subject.Serialize(quality); | ||||
|             var json = Json.Serialize(quality); | ||||
| 
 | ||||
|             Subject.Deserialize<TypeWithNumbers>(json); | ||||
|             Json.Deserialize<TypeWithNumbers>(json); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -45,7 +45,7 @@ | ||||
|     <Reference Include="System.Xml" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Compile Include="Json\JsonFixture.cs" /> | ||||
|     <Compile Include="JsonTests\JsonFixture.cs" /> | ||||
|     <Compile Include="Properties\AssemblyInfo.cs" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
| @@ -65,6 +65,9 @@ | ||||
|       <Name>NzbDrone.Test.Common</Name> | ||||
|     </ProjectReference> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Folder Include="Json\" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||
|   <Import Project="$(SolutionDir)\.nuget\nuget.targets" /> | ||||
|   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.  | ||||
|   | ||||
| @@ -76,7 +76,6 @@ namespace NzbDrone.Test.Common | ||||
|  | ||||
|  | ||||
|             Mocker.SetConstant(LogManager.GetLogger("TestLogger")); | ||||
|             Mocker.SetConstant<IJsonSerializer>(new JsonSerializer()); | ||||
|  | ||||
|             LogManager.ReconfigExistingLoggers(); | ||||
|  | ||||
| @@ -147,17 +146,17 @@ namespace NzbDrone.Test.Common | ||||
|             return Path.Combine(Directory.GetCurrentDirectory(), "Files", fileName); | ||||
|         } | ||||
|  | ||||
|         protected void VerifyEventPublished<TEvent>() where TEvent : IEvent | ||||
|         protected void VerifyEventPublished<TEvent>() where TEvent : class, IEvent | ||||
|         { | ||||
|             VerifyEventPublished<TEvent>(Times.Once()); | ||||
|         } | ||||
|  | ||||
|         protected void VerifyEventPublished<TEvent>(Times times) where TEvent : IEvent | ||||
|         protected void VerifyEventPublished<TEvent>(Times times) where TEvent : class, IEvent | ||||
|         { | ||||
|             Mocker.GetMock<IMessageAggregator>().Verify(c => c.PublishEvent(It.IsAny<TEvent>()), times); | ||||
|         } | ||||
|  | ||||
|         protected void VerifyEventNotPublished<TEvent>() where TEvent : IEvent | ||||
|         protected void VerifyEventNotPublished<TEvent>() where TEvent : class, IEvent | ||||
|         { | ||||
|             Mocker.GetMock<IMessageAggregator>().Verify(c => c.PublishEvent(It.IsAny<TEvent>()), Times.Never()); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user