public void SetParameter_CanAcceptNulls_AsValues()
        {
            UseJobStorageConnectionWithSession((session, jobStorage) =>
            {
                var newJob = FluentNHibernateWriteOnlyTransactionTests.InsertNewJob(session);
                var jobId  = newJob.Id.ToString();
                //does nothing

                jobStorage.SetJobParameter(jobId, "Name", null);

                var parameter = session.Query <_JobParameter>().Single(i => i.Job == newJob && i.Name == "Name");

                Assert.Equal(null, parameter.Value);
            });
        }
        public void GetParameter_ReturnsParameterValue_WhenJobExists()
        {
            UseJobStorageConnectionWithSession((session, jobStorage) =>
            {
                var newJob = FluentNHibernateWriteOnlyTransactionTests.InsertNewJob(session);
                session.Insert(new _JobParameter {
                    Job = newJob, Name = "name", Value = "Value"
                });
                //does nothing


                var Value = jobStorage.GetJobParameter(newJob.Id.ToString(), "name");

                Assert.Equal("Value", Value);
            });
        }
        public void SetParameters_CreatesNewParameter_WhenParameterWithTheGivenNameDoesNotExists()
        {
            UseJobStorageConnectionWithSession((session, jobStorage) =>
            {
                var newJob = FluentNHibernateWriteOnlyTransactionTests.InsertNewJob(session);

                var jobId = newJob.Id.ToString();

                jobStorage.SetJobParameter(jobId, "Name", "Value");
                //does nothing

                var parameter = session.Query <_JobParameter>().Single(i => i.Job == newJob && i.Name == "Name");

                Assert.Equal("Value", parameter.Value);
            });
        }
Esempio n. 4
0
        public void SetParameter_UpdatesValue_WhenParameterWithTheGivenName_AlreadyExists()
        {
            UseJobStorageConnectionWithSession((session, jobStorage) =>
            {
                var newJob = FluentNHibernateWriteOnlyTransactionTests.InsertNewJob(session);
                var jobId  = newJob.Id.ToString();

                jobStorage.SetJobParameter(jobId, "Name", "Value");
                jobStorage.SetJobParameter(jobId, "Name", "AnotherValue");
                session.Flush();
                session.Clear();
                var parameter = session.Query <_JobParameter>().Single(i => i.Job == newJob && i.Name == "Name");

                Assert.Equal("AnotherValue", parameter.Value);
            });
        }
Esempio n. 5
0
        public void GetStateData_ReturnsCorrectData_WhenPropertiesAreCamelcased()
        {
            UseJobStorageConnectionWithSession((session, jobStorage) =>
            {
                var data = new Dictionary <string, string>
                {
                    { "Key", "Value" }
                };
                var newJob = FluentNHibernateWriteOnlyTransactionTests.InsertNewJob(session);
                session.Insert(new _JobState {
                    Job = newJob, Name = "old-state", CreatedAt = session.Storage.UtcNow
                });
                var jobState = new _JobState
                {
                    Job       = newJob,
                    Name      = "Name",
                    Reason    = "Reason",
                    CreatedAt = session.Storage.UtcNow,
                    Data      = JobHelper.ToJson(data)
                };
                session.Insert(jobState);
                session.Flush();
                newJob.StateName   = jobState.Name;
                newJob.StateReason = jobState.Reason;
                newJob.StateData   = jobState.Data;
                session.Update(newJob);
                session.Flush();
                session.Clear();


                var jobId = newJob.Id;

                var result = jobStorage.GetStateData(jobId.ToString());
                Assert.NotNull(result);

                Assert.Equal("Value", result.Data["Key"]);
            });
        }