public void Deserialize_WrapsAnException_WithTheJobLoadException() { var serializedData = new InvocationData(null, null, null, null); Assert.Throws<JobLoadException>( () => serializedData.Deserialize()); }
public void Deserialize_ThrowsAnException_WhenMethodCanNotBeFound() { var serializedData = new InvocationData( typeof(InvocationDataFacts).AssemblyQualifiedName, "NonExistingMethod", JobHelper.ToJson(new [] { typeof(string) }), ""); Assert.Throws<JobLoadException>( () => serializedData.Deserialize()); }
public void Deserialize_ThrowsAnException_WhenTypeCanNotBeFound() { var serializedData = new InvocationData( "NonExistingType", "Perform", "", ""); Assert.Throws<JobLoadException>( () => serializedData.Deserialize()); }
public void Deserialize_CorrectlyDeserializes_AllTheData() { var type = typeof(InvocationDataFacts); var methodInfo = type.GetMethod("Sample"); var serializedData = new InvocationData( type.AssemblyQualifiedName, methodInfo.Name, JobHelper.ToJson(new [] { typeof(string) }), JobHelper.ToJson(new [] { "Hello" })); var job = serializedData.Deserialize(); Assert.Equal(type, job.Type); Assert.Equal(methodInfo, job.Method); Assert.Equal("Hello", job.Arguments[0]); }
public JobData GetJobData(string id) { var storedData = Redis.GetAllEntriesFromHash( String.Format(RedisStorage.Prefix + "job:{0}", id)); if (storedData.Count == 0) return null; string type = null; string method = null; string parameterTypes = null; string arguments = null; string createdAt = null; if (storedData.ContainsKey("Type")) { type = storedData["Type"]; } if (storedData.ContainsKey("Method")) { method = storedData["Method"]; } if (storedData.ContainsKey("ParameterTypes")) { parameterTypes = storedData["ParameterTypes"]; } if (storedData.ContainsKey("Arguments")) { arguments = storedData["Arguments"]; } if (storedData.ContainsKey("CreatedAt")) { createdAt = storedData["CreatedAt"]; } Job job = null; JobLoadException loadException = null; var invocationData = new InvocationData(type, method, parameterTypes, arguments); try { job = invocationData.Deserialize(); } catch (JobLoadException ex) { loadException = ex; } return new JobData { Job = job, State = storedData.ContainsKey("State") ? storedData["State"] : null, CreatedAt = JobHelper.FromNullableStringTimestamp(createdAt) ?? DateTime.MinValue, LoadException = loadException }; }